Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Apr 2019 18:25:15 +0000 (UTC)
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345773 - projects/capsicum-test/contrib/capsicum-test
Message-ID:  <201904011825.x31IPFYV073384@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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@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");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904011825.x31IPFYV073384>