svn commit: r345773 - projects/capsicum-test/contrib/capsicum-test
Enji Cooper
ngie at FreeBSD.org
Mon Apr 1 18:25:16 UTC 2019
Author: ngie
Date: Mon Apr 1 18:25:14 2019
New Revision: 345773
URL: https://svnweb.freebsd.org/changeset/base/345773
Log:
Import review changes
1. Collapse the declaration/assignment for `trap_enotcap_enabled_len` to reduce
complexity.
2. Move the `GTEST_SKIP()` backwards compatible definition out into the global
space.
3. Sort conditional platform #includes with __FreeBSD__ before __linux__.
Requested by: David Drysdale <drysdale at google.com> [1,2], emaste [3]
Pull Request: https://github.com/google/capsicum-test/pull/42
Modified:
projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc
Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc
==============================================================================
--- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 18:17:48 2019 (r345772)
+++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 18:25:14 2019 (r345773)
@@ -1,9 +1,9 @@
#include <sys/types.h>
-#if defined(__FreeBSD__)
-#include <sys/sysctl.h>
-#elif defined(__linux__)
+#ifdef __linux__
#include <sys/vfs.h>
#include <linux/magic.h>
+#elif defined(__FreeBSD__)
+#include <sys/sysctl.h>
#endif
#include <ctype.h>
#include <errno.h>
@@ -16,6 +16,11 @@
#include "gtest/gtest.h"
#include "capsicum-test.h"
+// For versions of googletest that lack GTEST_SKIP.
+#ifndef GTEST_SKIP
+#define GTEST_SKIP GTEST_FAIL
+#endif
+
std::string tmpdir;
class SetupEnvironment : public ::testing::Environment
@@ -33,19 +38,11 @@ class SetupEnvironment : public ::testing::Environment
std::cerr << tmpdir << std::endl;
}
void CheckCapsicumSupport() {
- // For versions of googletest that lack GTEST_SKIP.
-#ifndef GTEST_SKIP
-#define GTEST_SKIP GTEST_FAIL
-#define GTEST_SKIP_defined
-#endif
-
#ifdef __FreeBSD__
- size_t trap_enotcap_enabled_len;
int rc;
bool trap_enotcap_enabled;
+ size_t trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled);
- trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled);
-
if (feature_present("security_capabilities") == 0) {
GTEST_SKIP() << "Skipping tests because capsicum support is not "
<< "enabled in the kernel.";
@@ -61,10 +58,6 @@ class SetupEnvironment : public ::testing::Environment
<< "Skipping tests to avoid non-determinism with results";
}
#endif /* FreeBSD */
-
-#ifdef GTEST_SKIP_defined
-#undef GTEST_SKIP
-#endif
}
void CreateTemporaryRoot() {
char *tmpdir_name = tempnam(nullptr, "cptst");
More information about the svn-src-projects
mailing list