Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2019 01:09:10 +0000 (UTC)
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r348138 - in stable/12: cddl/usr.sbin/zfsd cddl/usr.sbin/zfsd/tests contrib/googletest contrib/googletest/googletest contrib/googletest/googletest/docs contrib/googletest/googletest/inc...
Message-ID:  <201905230109.x4N19A1r015367@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Thu May 23 01:09:10 2019
New Revision: 348138
URL: https://svnweb.freebsd.org/changeset/base/348138

Log:
  MFC r345203,r345205,r345353,r345645,r345708,r345709,r345735,r345770,r346081,r346270,r346574,r346576:
  
  r345203:
  
  Initial googlemock/googletest integration into the build/FreeBSD test suite
  
  This initial integration takes googlemock/googletest release 1.8.1, integrates
  the library, tests, and sample unit tests into the build.
  
  googlemock/googletest's inclusion is optionally available via `MK_GOOGLETEST`.
  `MK_GOOGLETEST` is dependent on `MK_TESTS` and is enabled by default when
  built with a C++11 capable toolchain.
  
  Google tests can be specified via the `GTESTS` variable, which, in comparison
  with the other test drivers, is more simplified/streamlined, as Googletest only
  supports C++ tests; not raw C or shell tests (C tests can be written in C++
  using the standard embedding methods).
  
  No dependent libraries are assumed for the tests. One must specify `gmock`,
  `gmock_main`, `gtest`, or `gtest_main`, via `LIBADD` for the program.
  
  More information about googlemock and googletest can be found on the
  Googletest [project page](https://github.com/google/googletest), and the
  [GoogleMock](https://github.com/google/googletest/blob/v1.8.x/googlemock/docs/Documentation.md)
  and
  [GoogleTest](https://github.com/google/googletest/tree/v1.8.x/googletest/docs)
  docs.
  
  These tests are originally integrated into the build as plain driver tests, but
  will be natively integrated into Kyua in a later version.
  
  Known issues/Errata:
  * [WhenDynamicCastToTest.AmbiguousCast fails on FreeBSD](https://github.com/google/googletest/issues/2172)
  
  r345205:
  
  Integrate cddl/usr.sbin/zfds/tests into the FreeBSD test suite
  
  This change integrates the unit tests for zfsd into the test suite using the
  integration method described in r345203.
  
  This change removes the `LOCALBASE` includes added for the port version of
  googlemock/googletest, as well as unnecessary `LIBADD`/`DPADD` and `CXXFLAGS`
  defines, which are included in the `GTEST_CXXFLAGS` variable, as part of
  r345203.
  
  r345353 (by asomers):
  
  googletest: backport GTEST_SKIP to googletest 1.8.1
  
  This commit backports revisions 00938b2b228f3b70d3d9e51f29a1505bdad43f1e and
  59f90a338bce2376b540ee239cf4e269bf6d68ad from googletest's master branch to
  our included version of googletest, which is based on 1.8.1. It adds the
  GTEST_SKIP feature, which is very useful for a project like FreeBSD where
  some tests depend on particular system configurations.
  
  Obtained from:	github.com/google/googletest
  
  r345645:
  
  Spam CXXFLAGS with `-I${DESTDIR}/usr/include/private`, instead of GTEST_CXXFLAGS
  
  This makes it easier for googletest users to leverage googletest, instead of
  forcing them to plug GTEST_CXXFLAGS into CXXFLAGS manually (resulting in
  unnecessary duplication).
  
  I will be following this up with a more proper fix in src.libnames.mk, as
  src.libnames.mk should be automatically adding this directory to
  CFLAGS/CXXFLAGS when private libraries are referenced. Not doing so can result
  in mismatches between base-provided private library's and ports-provided
  library's headers.
  
  While here, tweak the comment to clarify what the intent is behind spamming
  CXXFLAGS.
  
  r345708:
  
  Standardize `-std=c++* as `CXXSTD`
  
  CXXSTD was added as the C++ analogue to CSTD.
  
  CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
  otherwise for older versions of g++.
  
  This change standardizes the CXXSTD variable, originally added to
  googletest.test.inc.mk as part of r345203.
  
  As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.
  
  Notes:
  
  This value is not sanity checked in bsd.sys.mk, however, given the two
  most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
  likely to work with both toolchains. This method will be refined in the future
  to support more variants of C++, as not all versions of clang++ and g++ (for
  instance) support C++14, C++17, etc.
  
  Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
  Example:
  
  Before this commit:
  ```
  CXXFLAGS+=	-std=c++14
  ```
  
  After this commit:
  ```
  CXXSTD=	c++14
  ```
  
  Relnotes:	yes
  Tested with:	make tinderbox
  
  r345709:
  
  Allow users to override CSTD/CXXSTD on a per-prog basis
  
  The current logic for CSTD/CXXSTD requires homogenity as far as the
  supported C/C++ standards, which is a sensible default. However, when
  dealing with differing versions of C++, some code may compile with C++11, but
  not C++17 (for instance). So in order to avoid having people convert over their
  code to the new standard, give the users the ability to specify the standard on
  a per-program basis.
  
  This will allow a user to override the supporting standard for a set of
  programs, mixing C++11 with C++14 (for instance).
  
  Apprved by:	emaste (mentor)
  
  r345735:
  
  Allow programs to set `NO_SHARED` on a per-PROG basis
  
  This is particularly useful when installing programs for tests that need to be
  linked statically, e.g., mini-me from capsicum-test, which is linked statically
  to avoid the dynamic library lookup in the upstream project.
  
  r345770:
  
  Import proof-of-concept for handling `GTEST_SKIP()` in `Environment::SetUp`
  
  Per the upstream pull-request [1]:
  
  ```
    gtest prior to this change would completely ignore `GTEST_SKIP()` if
    called in `Environment::SetUp()`, instead of bailing out early, unlike
    `Test::SetUp()`, which would cause the tests themselves to be skipped.
    The only way (prior to this change) to skip the tests would be to
    trigger a fatal error via `GTEST_FAIL()`.
  
    Desirable behavior, in this case, when dealing with
    `Environment::SetUp()` is to check for prerequisites on a system
    (example, kernel supports a particular featureset, e.g., capsicum), and
    skip the tests. The alternatives prior to this change would be
    undesirable:
  
    - Failing sends the wrong message to the test user, as the result of the
      tests is indeterminate, not failed.
    - Having to add per-test class abstractions that override `SetUp()` to
      test for the capsicum feature set, then skip all of the tests in their
      respective SetUp fixtures, would be a lot of human and computational
      work; checking for the feature would need to be done for all of the
      tests, instead of once for all of the tests.
  
    For those reasons, making `Environment::SetUp()` handle `GTEST_SKIP()`,
    by not executing the testcases, is the most desirable solution.
  
    In order to properly diagnose what happened when running the tests if
    they are skipped, print out the diagnostics in an ad hoc manner.
  
    Update the documentation to note this change and integrate a new test,
    gtest_skip_in_environment_setup_test, into the test suite.
  
    This change addresses #2189.
  
    Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
  ```
  
  The goal with my merging in this change is to avoid requiring extensive
  refactoring/retesting of test suites when ensuring prerequisites are met,
  e.g., checking for a CAPABILITIES-enabled kernel before running capsicum-test
  (see D19758 for more details).
  
  The proof-of-concept is being imported before accepted by the upstream
  project due to the fact that the upstream project is undergoing a potential
  development freeze and the maintainers aren't responding to my PR.
  
  1. https://github.com/google/googletest/pull/2203
  
  r346081 (by trasz):
  
  Make zfsd(8) build obey CFLAGS.
  
  Obtained from:	CheriBSD
  
  r346270 (by trasz):
  
  Drop -g from CFLAGS for zfsd(8).  No idea why it was ever there.
  
  r346574:
  
  Rework CXXSTD setting via r345708
  
  This change allows the user to once again override the C++ standard, restoring
  high-level pre-r345708 behavior.
  
  This also unbreaks building lib/ofed/libibnetdisc/Makefile with a non-C++11
  capable compiler, e.g., g++ 4.2.1, as the library supported being built with
  older C++ standards.
  
  r346576:
  
  Fix up CXXSTD support originally added in r345708
  
  r345708 worked for the base system, but unfortunately, caused a lot of
  disruption for third-party packages that relied on C++, since bsd.sys.mk is
  used by applications outside the base system. The defaults picked didn't match
  the compiler's defaults and broke some builds that didn't specify a standard,
  as well as some that overrode the value by setting `-std=gnu++14` (for
  example) manually.
  
  This change takes a more relaxed approach to appending `-std=${CXXSTD}` to
  CXXFLAGS, by only doing so when the value is specified, as opposed to
  overriding the standard set by an end-user. This avoids the need for having
  to bake NOP default into bsd.sys.mk for supported compiler-toolchain
  versions.
  
  In order to make this change possible, add CXXSTD to Makefile snippets which
  relied on the default value (c++11) added in r345708.

Added:
  stable/12/contrib/googletest/
     - copied from r345203, head/contrib/googletest/
  stable/12/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc
     - copied unchanged from r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc
  stable/12/contrib/googletest/googletest/test/gtest_skip_test.cc
     - copied unchanged from r345353, head/contrib/googletest/googletest/test/gtest_skip_test.cc
  stable/12/lib/googletest/
     - copied from r345203, head/lib/googletest/
  stable/12/share/examples/tests/tests/googletest/
     - copied from r345203, head/share/examples/tests/tests/googletest/
  stable/12/share/mk/googletest.test.inc.mk
     - copied, changed from r345203, head/share/mk/googletest.test.inc.mk
  stable/12/share/mk/googletest.test.mk
     - copied unchanged from r345203, head/share/mk/googletest.test.mk
  stable/12/tools/build/options/WITHOUT_GOOGLETEST
     - copied unchanged from r345203, head/tools/build/options/WITHOUT_GOOGLETEST
Modified:
  stable/12/cddl/usr.sbin/zfsd/Makefile
  stable/12/cddl/usr.sbin/zfsd/Makefile.common
  stable/12/cddl/usr.sbin/zfsd/tests/Makefile
  stable/12/contrib/googletest/googletest/CMakeLists.txt
  stable/12/contrib/googletest/googletest/Makefile.am
  stable/12/contrib/googletest/googletest/docs/advanced.md
  stable/12/contrib/googletest/googletest/include/gtest/gtest-test-part.h
  stable/12/contrib/googletest/googletest/include/gtest/gtest.h
  stable/12/contrib/googletest/googletest/include/gtest/internal/gtest-internal.h
  stable/12/contrib/googletest/googletest/src/gtest-internal-inl.h
  stable/12/contrib/googletest/googletest/src/gtest-test-part.cc
  stable/12/contrib/googletest/googletest/src/gtest.cc
  stable/12/contrib/googletest/googletest/test/BUILD.bazel
  stable/12/contrib/googletest/googletest/test/googletest-test-part-test.cc
  stable/12/contrib/googletest/googletest/test/gtest_all_test.cc
  stable/12/contrib/mandoc/lib.in
  stable/12/etc/mtree/BSD.tests.dist
  stable/12/etc/mtree/BSD.usr.dist
  stable/12/lib/Makefile
  stable/12/lib/clang/llvm.build.mk
  stable/12/lib/googletest/gtest_main/tests/Makefile
  stable/12/lib/libc++/Makefile
  stable/12/lib/libc++experimental/Makefile
  stable/12/lib/libc++fs/Makefile
  stable/12/lib/libc/tests/stdlib/Makefile
  stable/12/lib/libclang_rt/Makefile.inc
  stable/12/lib/libcxxrt/Makefile
  stable/12/lib/libgcc_eh/Makefile.inc
  stable/12/lib/libomp/Makefile
  stable/12/lib/ofed/libibnetdisc/Makefile
  stable/12/share/examples/tests/tests/Makefile
  stable/12/share/mk/Makefile
  stable/12/share/mk/bsd.README
  stable/12/share/mk/bsd.progs.mk
  stable/12/share/mk/bsd.sys.mk
  stable/12/share/mk/bsd.test.mk
  stable/12/share/mk/src.libnames.mk
  stable/12/share/mk/src.opts.mk
  stable/12/tools/build/mk/OptionalObsoleteFiles.inc
  stable/12/usr.bin/dtc/Makefile
  stable/12/usr.sbin/pmc/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/cddl/usr.sbin/zfsd/Makefile
==============================================================================
--- stable/12/cddl/usr.sbin/zfsd/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/cddl/usr.sbin/zfsd/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -1,12 +1,13 @@
 # $FreeBSD$
 
+.include <src.opts.mk>
+
 .include "Makefile.common"
 
 PROG_CXX=	zfsd
 MAN=		zfsd.8
 
-.include <bsd.prog.mk>
+HAS_TESTS=
+SUBDIR.${MK_GOOGLETEST}+= tests
 
-# The unittests require devel/googletest and devel/googlemock from ports.
-# Don't automatically build them.
-SUBDIR=
+.include <bsd.prog.mk>

Modified: stable/12/cddl/usr.sbin/zfsd/Makefile.common
==============================================================================
--- stable/12/cddl/usr.sbin/zfsd/Makefile.common	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/cddl/usr.sbin/zfsd/Makefile.common	Thu May 23 01:09:10 2019	(r348138)
@@ -28,12 +28,11 @@ INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/li
 INCFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
 INCFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
 INCFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+INCFLAGS+= -I${SRCTOP}/cddl/usr.sbin
 
-CFLAGS= -g -DNEED_SOLARIS_BOOLEAN ${INCFLAGS}
+CFLAGS+= -DNEED_SOLARIS_BOOLEAN ${INCFLAGS}
 
-DPADD=  ${LIBDEVDCTL} ${LIBZFS} ${LIBZFS_CORE} ${LIBUTIL} ${LIBGEOM} \
-	${LIBBSDXML} ${LIBSBUF} ${LIBNVPAIR} ${LIBUUTIL}
-LIBADD=  devdctl zfs zfs_core util geom bsdxml sbuf nvpair uutil
+LIBADD+=	devdctl zfs zfs_core util geom bsdxml sbuf nvpair uutil
 
 cscope:
 	find ${.CURDIR} -type f -a \( -name "*.[ch]" -o -name "*.cc" \) \

Modified: stable/12/cddl/usr.sbin/zfsd/tests/Makefile
==============================================================================
--- stable/12/cddl/usr.sbin/zfsd/tests/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/cddl/usr.sbin/zfsd/tests/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -3,30 +3,12 @@
 .include "${.CURDIR}/../Makefile.common"
 .PATH:	${.CURDIR:H}
 
-PLAIN_TESTS_CXX=	zfsd_unittest
-SRCS.zfsd_unittest:=		${SRCS:Nzfsd_main.cc}
-SRCS.zfsd_unittest+=		libmocks.c zfsd_unittest.cc
-SRCS=
+GTESTS=			zfsd_unittest
 
-# Use #include <zfsd/xxx.h> in test programs.
-INCFLAGS+=	-I${.CURDIR:H:H}
+SRCS.zfsd_unittest:=	${SRCS:Nzfsd_main.cc}
+SRCS.zfsd_unittest+=	libmocks.c zfsd_unittest.cc
+.undef SRCS
 
-.if defined(DESTDIR) || defined(SYSROOT)
-INCFLAGS+=		-I${SYSROOT:U${DESTDIR}}/usr/include
-LDFLAGS.zfsd_unittest+=	-L${SYSROOT:U${DESTDIR}}/lib \
-			-L${SYSROOT:U${DESTDIR}}/usr/lib
-.endif
-
-# Googletest options
-INCFLAGS+=	-I${LOCALBASE}/include -D_THREAD_SAFE -pthread
-LDFLAGS.zfsd_unittest+=	-L${LOCALBASE}/lib -D_THREAD_SAFE -pthread
-LDADD.zfsd_unittest+=		${LOCALBASE}/lib/libgtest.a
-
-# GoogleMock options
-LDADD.zfsd_unittest+= ${LOCALBASE}/lib/libgmock.a ${LOCALBASE}/lib/libgmock_main.a
-
-# Googlemock fails if we don't have this line
-# https://groups.google.com/forum/#!msg/googletestframework/h8ixEPCFm0o/amwfu4xGJb0J
-CFLAGS.zfsd_unittest+= -DGTEST_HAS_PTHREAD
+LIBADD.zfsd_unittest+=	gmock_main
 
 .include <bsd.test.mk>

Modified: stable/12/contrib/googletest/googletest/CMakeLists.txt
==============================================================================
--- head/contrib/googletest/googletest/CMakeLists.txt	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/CMakeLists.txt	Thu May 23 01:09:10 2019	(r348138)
@@ -217,6 +217,8 @@ if (gtest_build_tests)
     test/gtest-typed-test2_test.cc)
   cxx_test(gtest_unittest gtest_main)
   cxx_test(gtest-unittest-api_test gtest)
+  cxx_test(gtest_skip_in_environment_setup_test gtest_main)
+  cxx_test(gtest_skip_test gtest_main)
 
   ############################################################
   # C++ tests built with non-standard compiler flags.

Modified: stable/12/contrib/googletest/googletest/Makefile.am
==============================================================================
--- head/contrib/googletest/googletest/Makefile.am	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/Makefile.am	Thu May 23 01:09:10 2019	(r348138)
@@ -290,6 +290,12 @@ test_gtest_all_test_SOURCES = test/gtest_all_test.cc
 test_gtest_all_test_LDADD = lib/libgtest_main.la \
                             lib/libgtest.la
 
+TESTS += test/gtest_skip_in_environment_setup_test
+check_PROGRAMS += test/gtest_skip_in_environment_setup_test
+test_gtest_skip_in_environment_setup_test_SOURCES = test/gtest_skip_in_environment_setup_test.cc
+test_gtest_skip_in_environment_setup_test_LDADD= lib/libgtest_main.la \
+                                                 lib/libgtest.la
+
 # Tests that fused gtest files compile and work.
 FUSED_GTEST_SRC = \
   fused-src/gtest/gtest-all.cc \

Modified: stable/12/contrib/googletest/googletest/docs/advanced.md
==============================================================================
--- head/contrib/googletest/googletest/docs/advanced.md	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/docs/advanced.md	Thu May 23 01:09:10 2019	(r348138)
@@ -1289,8 +1289,10 @@ Environment* AddGlobalTestEnvironment(Environment* env
 ```
 
 Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of
-the environment object, then runs the tests if there was no fatal failures, and
-finally calls `TearDown()` of the environment object.
+each environment object, then runs the tests if none of the environments
+reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()`
+always calls `TearDown()` with each environment object, regardless of whether
+or not the tests were run.
 
 It's OK to register multiple environment objects. In this case, their `SetUp()`
 will be called in the order they are registered, and their `TearDown()` will be

Modified: stable/12/contrib/googletest/googletest/include/gtest/gtest-test-part.h
==============================================================================
--- head/contrib/googletest/googletest/include/gtest/gtest-test-part.h	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/include/gtest/gtest-test-part.h	Thu May 23 01:09:10 2019	(r348138)
@@ -53,7 +53,8 @@ class GTEST_API_ TestPartResult {
   enum Type {
     kSuccess,          // Succeeded.
     kNonFatalFailure,  // Failed but the test can continue.
-    kFatalFailure      // Failed and the test should be terminated.
+    kFatalFailure,     // Failed and the test should be terminated.
+    kSkip              // Skipped.
   };
 
   // C'tor.  TestPartResult does NOT have a default constructor.
@@ -89,17 +90,20 @@ class GTEST_API_ TestPartResult {
   // Gets the message associated with the test part.
   const char* message() const { return message_.c_str(); }
 
+  // Returns true iff the test part was skipped.
+  bool skipped() const { return type_ == kSkip; }
+
   // Returns true iff the test part passed.
   bool passed() const { return type_ == kSuccess; }
 
-  // Returns true iff the test part failed.
-  bool failed() const { return type_ != kSuccess; }
-
   // Returns true iff the test part non-fatally failed.
   bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
 
   // Returns true iff the test part fatally failed.
   bool fatally_failed() const { return type_ == kFatalFailure; }
+
+  // Returns true iff the test part failed.
+  bool failed() const { return fatally_failed() || nonfatally_failed(); }
 
  private:
   Type type_;

Modified: stable/12/contrib/googletest/googletest/include/gtest/gtest.h
==============================================================================
--- head/contrib/googletest/googletest/include/gtest/gtest.h	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/include/gtest/gtest.h	Thu May 23 01:09:10 2019	(r348138)
@@ -440,6 +440,9 @@ class GTEST_API_ Test {
   // Returns true iff the current test has a non-fatal failure.
   static bool HasNonfatalFailure();
 
+  // Returns true iff the current test was skipped.
+  static bool IsSkipped();
+
   // Returns true iff the current test has a (either fatal or
   // non-fatal) failure.
   static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
@@ -574,8 +577,11 @@ class GTEST_API_ TestResult {
   int test_property_count() const;
 
   // Returns true iff the test passed (i.e. no test part failed).
-  bool Passed() const { return !Failed(); }
+  bool Passed() const { return !Skipped() && !Failed(); }
 
+  // Returns true iff the test was skipped.
+  bool Skipped() const;
+
   // Returns true iff the test failed.
   bool Failed() const;
 
@@ -854,6 +860,9 @@ class GTEST_API_ TestCase {
   // Gets the number of successful tests in this test case.
   int successful_test_count() const;
 
+  // Gets the number of skipped tests in this test case.
+  int skipped_test_count() const;
+
   // Gets the number of failed tests in this test case.
   int failed_test_count() const;
 
@@ -936,6 +945,11 @@ class GTEST_API_ TestCase {
     return test_info->should_run() && test_info->result()->Passed();
   }
 
+  // Returns true iff test skipped.
+  static bool TestSkipped(const TestInfo* test_info) {
+    return test_info->should_run() && test_info->result()->Skipped();
+  }
+
   // Returns true iff test failed.
   static bool TestFailed(const TestInfo* test_info) {
     return test_info->should_run() && test_info->result()->Failed();
@@ -1258,6 +1272,9 @@ class GTEST_API_ UnitTest {
   // Gets the number of successful tests.
   int successful_test_count() const;
 
+  // Gets the number of skipped tests.
+  int skipped_test_count() const;
+
   // Gets the number of failed tests.
   int failed_test_count() const;
 
@@ -1834,6 +1851,11 @@ class TestWithParam : public Test, public WithParamInt
 };
 
 // Macros for indicating success/failure in test code.
+
+// Skips test in runtime.
+// Skipping test aborts current function.
+// Skipped tests are neither successful nor failed.
+#define GTEST_SKIP() GTEST_SKIP_("Skipped")
 
 // ADD_FAILURE unconditionally adds a failure to the current test.
 // SUCCEED generates a success - it doesn't automatically make the

Modified: stable/12/contrib/googletest/googletest/include/gtest/internal/gtest-internal.h
==============================================================================
--- head/contrib/googletest/googletest/include/gtest/internal/gtest-internal.h	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/include/gtest/internal/gtest-internal.h	Thu May 23 01:09:10 2019	(r348138)
@@ -1208,7 +1208,10 @@ class NativeArray {
 #define GTEST_SUCCESS_(message) \
   GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
 
-// Suppress MSVC warning 4702 (unreachable code) for the code following
+#define GTEST_SKIP_(message) \
+  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)
+
+// Suppress MSVC warning 4072 (unreachable code) for the code following
 // statement if it returns or throws (or doesn't return or throw in some
 // situations).
 #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \

Modified: stable/12/contrib/googletest/googletest/src/gtest-internal-inl.h
==============================================================================
--- head/contrib/googletest/googletest/src/gtest-internal-inl.h	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/src/gtest-internal-inl.h	Thu May 23 01:09:10 2019	(r348138)
@@ -544,6 +544,9 @@ class GTEST_API_ UnitTestImpl {
   // Gets the number of successful tests.
   int successful_test_count() const;
 
+  // Gets the number of skipped tests.
+  int skipped_test_count() const;
+
   // Gets the number of failed tests.
   int failed_test_count() const;
 

Modified: stable/12/contrib/googletest/googletest/src/gtest-test-part.cc
==============================================================================
--- head/contrib/googletest/googletest/src/gtest-test-part.cc	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/src/gtest-test-part.cc	Thu May 23 01:09:10 2019	(r348138)
@@ -47,12 +47,16 @@ std::string TestPartResult::ExtractSummary(const char*
 
 // Prints a TestPartResult object.
 std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
-  return os
-      << result.file_name() << ":" << result.line_number() << ": "
-      << (result.type() == TestPartResult::kSuccess ? "Success" :
-          result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
-          "Non-fatal failure") << ":\n"
-      << result.message() << std::endl;
+  return os << result.file_name() << ":" << result.line_number() << ": "
+            << (result.type() == TestPartResult::kSuccess
+                    ? "Success"
+                    : result.type() == TestPartResult::kSkip
+                          ? "Skipped"
+                          : result.type() == TestPartResult::kFatalFailure
+                                ? "Fatal failure"
+                                : "Non-fatal failure")
+            << ":\n"
+            << result.message() << std::endl;
 }
 
 // Appends a TestPartResult to the array.

Modified: stable/12/contrib/googletest/googletest/src/gtest.cc
==============================================================================
--- head/contrib/googletest/googletest/src/gtest.cc	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/src/gtest.cc	Thu May 23 01:09:10 2019	(r348138)
@@ -796,6 +796,11 @@ int UnitTestImpl::successful_test_count() const {
   return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);
 }
 
+// Gets the number of skipped tests.
+int UnitTestImpl::skipped_test_count() const {
+  return SumOverTestCaseList(test_cases_, &TestCase::skipped_test_count);
+}
+
 // Gets the number of failed tests.
 int UnitTestImpl::failed_test_count() const {
   return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
@@ -2207,6 +2212,16 @@ void TestResult::Clear() {
   elapsed_time_ = 0;
 }
 
+// Returns true off the test part was skipped.
+static bool TestPartSkipped(const TestPartResult& result) {
+  return result.skipped();
+}
+
+// Returns true iff the test was skipped.
+bool TestResult::Skipped() const {
+  return !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0;
+}
+
 // Returns true iff the test failed.
 bool TestResult::Failed() const {
   for (int i = 0; i < total_part_count(); ++i) {
@@ -2511,8 +2526,9 @@ void Test::Run() {
   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
   impl->os_stack_trace_getter()->UponLeavingGTest();
   internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
-  // We will run the test only if SetUp() was successful.
-  if (!HasFatalFailure()) {
+  // We will run the test only if SetUp() was successful and didn't call
+  // GTEST_SKIP().
+  if (!HasFatalFailure() && !IsSkipped()) {
     impl->os_stack_trace_getter()->UponLeavingGTest();
     internal::HandleExceptionsInMethodIfSupported(
         this, &Test::TestBody, "the test body");
@@ -2537,6 +2553,11 @@ bool Test::HasNonfatalFailure() {
       HasNonfatalFailure();
 }
 
+// Returns true iff the current test was skipped.
+bool Test::IsSkipped() {
+  return internal::GetUnitTestImpl()->current_test_result()->Skipped();
+}
+
 // class TestInfo
 
 // Constructs a TestInfo object. It assumes ownership of the test factory
@@ -2685,9 +2706,10 @@ void TestInfo::Run() {
       factory_, &internal::TestFactoryBase::CreateTest,
       "the test fixture's constructor");
 
-  // Runs the test if the constructor didn't generate a fatal failure.
+  // Runs the test if the constructor didn't generate a fatal failure or invoke
+  // GTEST_SKIP().
   // Note that the object will not be null
-  if (!Test::HasFatalFailure()) {
+  if (!Test::HasFatalFailure() && !Test::IsSkipped()) {
     // This doesn't throw as all user code that can throw are wrapped into
     // exception handling code.
     test->Run();
@@ -2715,6 +2737,11 @@ int TestCase::successful_test_count() const {
   return CountIf(test_info_list_, TestPassed);
 }
 
+// Gets the number of successful tests in this test case.
+int TestCase::skipped_test_count() const {
+  return CountIf(test_info_list_, TestSkipped);
+}
+
 // Gets the number of failed tests in this test case.
 int TestCase::failed_test_count() const {
   return CountIf(test_info_list_, TestFailed);
@@ -2866,6 +2893,8 @@ static std::string FormatTestCaseCount(int test_case_c
 // between the two when viewing the test result.
 static const char * TestPartResultTypeToString(TestPartResult::Type type) {
   switch (type) {
+    case TestPartResult::kSkip:
+      return "Skipped";
     case TestPartResult::kSuccess:
       return "Success";
 
@@ -3119,6 +3148,7 @@ class PrettyUnitTestResultPrinter : public TestEventLi
 
  private:
   static void PrintFailedTests(const UnitTest& unit_test);
+  static void PrintSkippedTests(const UnitTest& unit_test);
 };
 
   // Fired before each iteration of tests starts.
@@ -3187,18 +3217,25 @@ void PrettyUnitTestResultPrinter::OnTestStart(const Te
 // Called after an assertion failure.
 void PrettyUnitTestResultPrinter::OnTestPartResult(
     const TestPartResult& result) {
-  // If the test part succeeded, we don't need to do anything.
-  if (result.type() == TestPartResult::kSuccess)
-    return;
-
-  // Print failure message from the assertion (e.g. expected this and got that).
-  PrintTestPartResult(result);
-  fflush(stdout);
+  switch (result.type()) {
+    // If the test part succeeded, or was skipped,
+    // we don't need to do anything.
+    case TestPartResult::kSkip:
+    case TestPartResult::kSuccess:
+      return;
+    default:
+      // Print failure message from the assertion
+      // (e.g. expected this and got that).
+      PrintTestPartResult(result);
+      fflush(stdout);
+  }
 }
 
 void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
   if (test_info.result()->Passed()) {
     ColoredPrintf(COLOR_GREEN, "[       OK ] ");
+  } else if (test_info.result()->Skipped()) {
+    ColoredPrintf(COLOR_GREEN, "[  SKIPPED ] ");
   } else {
     ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
   }
@@ -3248,7 +3285,7 @@ void PrettyUnitTestResultPrinter::PrintFailedTests(con
     }
     for (int j = 0; j < test_case.total_test_count(); ++j) {
       const TestInfo& test_info = *test_case.GetTestInfo(j);
-      if (!test_info.should_run() || test_info.result()->Passed()) {
+      if (!test_info.should_run() || !test_info.result()->Failed()) {
         continue;
       }
       ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
@@ -3259,6 +3296,30 @@ void PrettyUnitTestResultPrinter::PrintFailedTests(con
   }
 }
 
+// Internal helper for printing the list of skipped tests.
+void PrettyUnitTestResultPrinter::PrintSkippedTests(const UnitTest& unit_test) {
+  const int skipped_test_count = unit_test.skipped_test_count();
+  if (skipped_test_count == 0) {
+    return;
+  }
+
+  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
+    const TestCase& test_case = *unit_test.GetTestCase(i);
+    if (!test_case.should_run() || (test_case.skipped_test_count() == 0)) {
+      continue;
+    }
+    for (int j = 0; j < test_case.total_test_count(); ++j) {
+      const TestInfo& test_info = *test_case.GetTestInfo(j);
+      if (!test_info.should_run() || !test_info.result()->Skipped()) {
+        continue;
+      }
+      ColoredPrintf(COLOR_GREEN, "[  SKIPPED ] ");
+      printf("%s.%s", test_case.name(), test_info.name());
+      printf("\n");
+    }
+  }
+}
+
 void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
                                                      int /*iteration*/) {
   ColoredPrintf(COLOR_GREEN,  "[==========] ");
@@ -3273,6 +3334,13 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(c
   ColoredPrintf(COLOR_GREEN,  "[  PASSED  ] ");
   printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
 
+  const int skipped_test_count = unit_test.skipped_test_count();
+  if (skipped_test_count > 0) {
+    ColoredPrintf(COLOR_GREEN, "[  SKIPPED ] ");
+    printf("%s, listed below:\n", FormatTestCount(skipped_test_count).c_str());
+    PrintSkippedTests(unit_test);
+  }
+
   int num_failures = unit_test.failed_test_count();
   if (!unit_test.Passed()) {
     const int failed_test_count = unit_test.failed_test_count();
@@ -4540,6 +4608,11 @@ int UnitTest::successful_test_count() const {
   return impl()->successful_test_count();
 }
 
+// Gets the number of skipped tests.
+int UnitTest::skipped_test_count() const {
+  return impl()->skipped_test_count();
+}
+
 // Gets the number of failed tests.
 int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
 
@@ -4660,7 +4733,8 @@ void UnitTest::AddTestPartResult(
   impl_->GetTestPartResultReporterForCurrentThread()->
       ReportTestPartResult(result);
 
-  if (result_type != TestPartResult::kSuccess) {
+  if (result_type != TestPartResult::kSuccess &&
+      result_type != TestPartResult::kSkip) {
     // gtest_break_on_failure takes precedence over
     // gtest_throw_on_failure.  This allows a user to set the latter
     // in the code (perhaps in order to use Google Test assertions
@@ -5169,9 +5243,23 @@ bool UnitTestImpl::RunAllTests() {
       ForEach(environments_, SetUpEnvironment);
       repeater->OnEnvironmentsSetUpEnd(*parent_);
 
-      // Runs the tests only if there was no fatal failure during global
-      // set-up.
-      if (!Test::HasFatalFailure()) {
+      // Runs the tests only if there was no fatal failure or skip triggered
+      // during global set-up.
+      if (Test::IsSkipped()) {
+        // Emit diagnostics when global set-up calls skip, as it will not be
+        // emitted by default.
+        TestResult& test_result =
+          *internal::GetUnitTestImpl()->current_test_result();
+        for (int j = 0; j < test_result.total_part_count(); ++j) {
+          const TestPartResult& test_part_result =
+            test_result.GetTestPartResult(j);
+          if (test_part_result.type() == TestPartResult::kSkip) {
+            const std::string& result = test_part_result.message();
+            printf("%s\n", result.c_str());
+          }
+        }
+        fflush(stdout);
+      } else if (!Test::HasFatalFailure()) {
         for (int test_index = 0; test_index < total_test_case_count();
              test_index++) {
           GetMutableTestCase(test_index)->Run();

Modified: stable/12/contrib/googletest/googletest/test/BUILD.bazel
==============================================================================
--- head/contrib/googletest/googletest/test/BUILD.bazel	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/test/BUILD.bazel	Thu May 23 01:09:10 2019	(r348138)
@@ -311,6 +311,13 @@ cc_binary(
     deps = ["//:gtest"],
 )
 
+cc_test(
+    name = "gtest_skip_in_environment_setup_test",
+    size = "small",
+    srcs = ["gtest_skip_in_environment_setup_test.cc"],
+    deps = ["//:gtest_main"],
+)
+
 py_test(
     name = "googletest-list-tests-unittest",
     size = "small",

Modified: stable/12/contrib/googletest/googletest/test/googletest-test-part-test.cc
==============================================================================
--- head/contrib/googletest/googletest/test/googletest-test-part-test.cc	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/test/googletest-test-part-test.cc	Thu May 23 01:09:10 2019	(r348138)
@@ -46,9 +46,10 @@ class TestPartResultTest : public Test {
   TestPartResultTest()
       : r1_(TestPartResult::kSuccess, "foo/bar.cc", 10, "Success!"),
         r2_(TestPartResult::kNonFatalFailure, "foo/bar.cc", -1, "Failure!"),
-        r3_(TestPartResult::kFatalFailure, NULL, -1, "Failure!") {}
+        r3_(TestPartResult::kFatalFailure, nullptr, -1, "Failure!"),
+        r4_(TestPartResult::kSkip, "foo/bar.cc", 2, "Skipped!") {}
 
-  TestPartResult r1_, r2_, r3_;
+  TestPartResult r1_, r2_, r3_, r4_;
 };
 
 
@@ -79,6 +80,7 @@ TEST_F(TestPartResultTest, ResultAccessorsWork) {
   EXPECT_FALSE(success.failed());
   EXPECT_FALSE(success.nonfatally_failed());
   EXPECT_FALSE(success.fatally_failed());
+  EXPECT_FALSE(success.skipped());
 
   const TestPartResult nonfatal_failure(TestPartResult::kNonFatalFailure,
                                         "file.cc",
@@ -88,6 +90,7 @@ TEST_F(TestPartResultTest, ResultAccessorsWork) {
   EXPECT_TRUE(nonfatal_failure.failed());
   EXPECT_TRUE(nonfatal_failure.nonfatally_failed());
   EXPECT_FALSE(nonfatal_failure.fatally_failed());
+  EXPECT_FALSE(nonfatal_failure.skipped());
 
   const TestPartResult fatal_failure(TestPartResult::kFatalFailure,
                                      "file.cc",
@@ -97,6 +100,14 @@ TEST_F(TestPartResultTest, ResultAccessorsWork) {
   EXPECT_TRUE(fatal_failure.failed());
   EXPECT_FALSE(fatal_failure.nonfatally_failed());
   EXPECT_TRUE(fatal_failure.fatally_failed());
+  EXPECT_FALSE(fatal_failure.skipped());
+
+  const TestPartResult skip(TestPartResult::kSkip, "file.cc", 42, "message");
+  EXPECT_FALSE(skip.passed());
+  EXPECT_FALSE(skip.failed());
+  EXPECT_FALSE(skip.nonfatally_failed());
+  EXPECT_FALSE(skip.fatally_failed());
+  EXPECT_TRUE(skip.skipped());
 }
 
 // Tests TestPartResult::type().
@@ -104,23 +115,27 @@ TEST_F(TestPartResultTest, type) {
   EXPECT_EQ(TestPartResult::kSuccess, r1_.type());
   EXPECT_EQ(TestPartResult::kNonFatalFailure, r2_.type());
   EXPECT_EQ(TestPartResult::kFatalFailure, r3_.type());
+  EXPECT_EQ(TestPartResult::kSkip, r4_.type());
 }
 
 // Tests TestPartResult::file_name().
 TEST_F(TestPartResultTest, file_name) {
   EXPECT_STREQ("foo/bar.cc", r1_.file_name());
   EXPECT_STREQ(NULL, r3_.file_name());
+  EXPECT_STREQ("foo/bar.cc", r4_.file_name());
 }
 
 // Tests TestPartResult::line_number().
 TEST_F(TestPartResultTest, line_number) {
   EXPECT_EQ(10, r1_.line_number());
   EXPECT_EQ(-1, r2_.line_number());
+  EXPECT_EQ(2, r4_.line_number());
 }
 
 // Tests TestPartResult::message().
 TEST_F(TestPartResultTest, message) {
   EXPECT_STREQ("Success!", r1_.message());
+  EXPECT_STREQ("Skipped!", r4_.message());
 }
 
 // Tests TestPartResult::passed().
@@ -128,6 +143,7 @@ TEST_F(TestPartResultTest, Passed) {
   EXPECT_TRUE(r1_.passed());
   EXPECT_FALSE(r2_.passed());
   EXPECT_FALSE(r3_.passed());
+  EXPECT_FALSE(r4_.passed());
 }
 
 // Tests TestPartResult::failed().
@@ -135,13 +151,23 @@ TEST_F(TestPartResultTest, Failed) {
   EXPECT_FALSE(r1_.failed());
   EXPECT_TRUE(r2_.failed());
   EXPECT_TRUE(r3_.failed());
+  EXPECT_FALSE(r4_.failed());
 }
 
+// Tests TestPartResult::failed().
+TEST_F(TestPartResultTest, Skipped) {
+  EXPECT_FALSE(r1_.skipped());
+  EXPECT_FALSE(r2_.skipped());
+  EXPECT_FALSE(r3_.skipped());
+  EXPECT_TRUE(r4_.skipped());
+}
+
 // Tests TestPartResult::fatally_failed().
 TEST_F(TestPartResultTest, FatallyFailed) {
   EXPECT_FALSE(r1_.fatally_failed());
   EXPECT_FALSE(r2_.fatally_failed());
   EXPECT_TRUE(r3_.fatally_failed());
+  EXPECT_FALSE(r4_.fatally_failed());
 }
 
 // Tests TestPartResult::nonfatally_failed().
@@ -149,6 +175,7 @@ TEST_F(TestPartResultTest, NonfatallyFailed) {
   EXPECT_FALSE(r1_.nonfatally_failed());
   EXPECT_TRUE(r2_.nonfatally_failed());
   EXPECT_FALSE(r3_.nonfatally_failed());
+  EXPECT_FALSE(r4_.nonfatally_failed());
 }
 
 // Tests the TestPartResultArray class.

Modified: stable/12/contrib/googletest/googletest/test/gtest_all_test.cc
==============================================================================
--- head/contrib/googletest/googletest/test/gtest_all_test.cc	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/contrib/googletest/googletest/test/gtest_all_test.cc	Thu May 23 01:09:10 2019	(r348138)
@@ -37,10 +37,11 @@
 #include "test/googletest-message-test.cc"
 #include "test/googletest-options-test.cc"
 #include "test/googletest-port-test.cc"
-#include "test/gtest_pred_impl_unittest.cc"
-#include "test/gtest_prod_test.cc"
 #include "test/googletest-test-part-test.cc"
-#include "test/gtest-typed-test_test.cc"
 #include "test/gtest-typed-test2_test.cc"
+#include "test/gtest-typed-test_test.cc"
+#include "test/gtest_pred_impl_unittest.cc"
+#include "test/gtest_prod_test.cc"
+#include "test/gtest_skip_test.cc"
 #include "test/gtest_unittest.cc"
 #include "test/production.cc"

Copied: stable/12/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc	Thu May 23 01:09:10 2019	(r348138, copy of r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc)
@@ -0,0 +1,60 @@
+// Copyright 2019, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This test verifies that skipping in the environment results in the
+// testcases being skipped.
+//
+// This is a reproduction case for
+// https://github.com/google/googletest/issues/2189 .
+
+#include <iostream>
+#include <gtest/gtest.h>
+
+class SetupEnvironment : public testing::Environment {
+public:
+  void SetUp() override {
+    GTEST_SKIP() << "Skipping the entire environment";
+  }
+};
+
+TEST(Test, AlwaysPasses) {
+  EXPECT_EQ(true, true);
+}
+
+TEST(Test, AlwaysFails) {
+  EXPECT_EQ(true, false);
+}
+
+int main(int argc, char **argv) {
+  testing::InitGoogleTest(&argc, argv);
+
+  testing::AddGlobalTestEnvironment(new SetupEnvironment());
+
+  return (RUN_ALL_TESTS());
+}

Copied: stable/12/contrib/googletest/googletest/test/gtest_skip_test.cc (from r345353, head/contrib/googletest/googletest/test/gtest_skip_test.cc)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/contrib/googletest/googletest/test/gtest_skip_test.cc	Thu May 23 01:09:10 2019	(r348138, copy of r345353, head/contrib/googletest/googletest/test/gtest_skip_test.cc)
@@ -0,0 +1,55 @@
+// Copyright 2008 Google Inc.
+// All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: arseny.aprelev@gmail.com (Arseny Aprelev)
+//
+
+#include "gtest/gtest.h"
+
+using ::testing::Test;
+
+TEST(SkipTest, DoesSkip) {
+  GTEST_SKIP();
+  EXPECT_EQ(0, 1);
+}
+
+class Fixture : public Test {
+ protected:
+  void SetUp() override {
+    GTEST_SKIP() << "skipping all tests for this fixture";
+  }
+};
+
+TEST_F(Fixture, SkipsOneTest) {
+  EXPECT_EQ(5, 7);
+}
+
+TEST_F(Fixture, SkipsAnotherTest) {
+  EXPECT_EQ(99, 100);
+}

Modified: stable/12/contrib/mandoc/lib.in
==============================================================================
--- stable/12/contrib/mandoc/lib.in	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/contrib/mandoc/lib.in	Thu May 23 01:09:10 2019	(r348138)
@@ -62,7 +62,9 @@ LINE("libfsid",		"Filesystem Identification Library (l
 LINE("libftpio",	"FTP Connection Management Library (libftpio, \\-lftpio)")
 LINE("libform",		"Curses Form Library (libform, \\-lform)")
 LINE("libgeom",		"Userland API Library for Kernel GEOM subsystem (libgeom, \\-lgeom)")
+LINE("libgmock",	"GoogleMock library (libgmock, \\-lgmock)")
 LINE("libgpio",		"General-Purpose Input Output (GPIO) library (libgpio, \\-lgpio)")
+LINE("libgtest",	"GoogleTest library (libgtest, \\-lgtest)")
 LINE("libhammer",	"HAMMER Filesystem Userland Library (libhammer, \\-lhammer)")
 LINE("libi386",		"i386 Architecture Library (libi386, \\-li386)")
 LINE("libintl",		"Internationalized Message Handling Library (libintl, \\-lintl)")

Modified: stable/12/etc/mtree/BSD.tests.dist
==============================================================================
--- stable/12/etc/mtree/BSD.tests.dist	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/etc/mtree/BSD.tests.dist	Thu May 23 01:09:10 2019	(r348138)
@@ -270,6 +270,16 @@
             test-programs
             ..
         ..
+        googletest
+            gmock
+            ..
+            gmock_main
+            ..
+            gtest
+            ..
+            gtest_main
+            ..
+        ..
         libarchive
         ..
         libbe
@@ -423,6 +433,8 @@
         examples
             tests
                 atf
+                ..
+                googletest
                 ..
                 plain
                 ..

Modified: stable/12/etc/mtree/BSD.usr.dist
==============================================================================
--- stable/12/etc/mtree/BSD.usr.dist	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/etc/mtree/BSD.usr.dist	Thu May 23 01:09:10 2019	(r348138)
@@ -13,6 +13,18 @@
             ..
             event
             ..
+            gmock
+                internal
+                    custom
+                    ..
+                ..
+            ..
+            gtest
+                internal
+                    custom
+                    ..
+                ..
+            ..
             sqlite3
             ..
             ucl

Modified: stable/12/lib/Makefile
==============================================================================
--- stable/12/lib/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -170,6 +170,7 @@ _libcplusplus+=	libc++fs
 .endif
 
 SUBDIR.${MK_EFI}+=	libefivar
+SUBDIR.${MK_GOOGLETEST}+=	googletest
 SUBDIR.${MK_LIBTHR}+=	libthr
 SUBDIR.${MK_LLVM_LIBUNWIND}+=	libgcc_eh
 SUBDIR.${MK_LLVM_LIBUNWIND}+=	libgcc_s

Modified: stable/12/lib/clang/llvm.build.mk
==============================================================================
--- stable/12/lib/clang/llvm.build.mk	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/clang/llvm.build.mk	Thu May 23 01:09:10 2019	(r348138)
@@ -101,7 +101,7 @@ CFLAGS+=	-ffunction-sections
 CFLAGS+=	-fdata-sections
 LDFLAGS+=	-Wl,--gc-sections
 
-CXXFLAGS+=	-std=c++11
+CXXSTD?=	c++11
 CXXFLAGS+=	-fno-exceptions
 CXXFLAGS+=	-fno-rtti
 CXXFLAGS.clang+= -stdlib=libc++

Modified: stable/12/lib/googletest/gtest_main/tests/Makefile
==============================================================================
--- head/lib/googletest/gtest_main/tests/Makefile	Fri Mar 15 21:43:52 2019	(r345203)
+++ stable/12/lib/googletest/gtest_main/tests/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -18,6 +18,8 @@ GTESTS+=	gtest_prod_test
 GTESTS+=	gtest_sole_header_test
 GTESTS+=	googletest-test-part-test
 GTESTS+=	gtest-typed-test_test
+GTESTS+=	gtest_skip_test
+GTESTS+=	gtest_skip_in_environment_setup_test
 GTESTS+=	gtest_unittest
 
 CXXFLAGS+=	-I${GOOGLETEST_SRCROOT}/include

Modified: stable/12/lib/libc++/Makefile
==============================================================================
--- stable/12/lib/libc++/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libc++/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -76,9 +76,7 @@ CFLAGS+=	-nostdinc++
 CFLAGS+=	-nostdlib
 CFLAGS+=	-D_LIBCPP_BUILDING_LIBRARY
 CFLAGS+=	-DLIBCXXRT
-.if empty(CXXFLAGS:M-std=*)
-CXXFLAGS+=	-std=c++11
-.endif
+CXXSTD?=	c++11
 
 LIBADD+=	cxxrt
 INCSGROUPS=	STD EXP EXT

Modified: stable/12/lib/libc++experimental/Makefile
==============================================================================
--- stable/12/lib/libc++experimental/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libc++experimental/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -20,8 +20,6 @@ CXXFLAGS+=	-nostdinc++
 CXXFLAGS+=	-nostdlib
 CXXFLAGS+=	-D_LIBCPP_BUILDING_LIBRARY
 CXXFLAGS+=	-DLIBCXXRT
-.if empty(CXXFLAGS:M-std=*)
-CXXFLAGS+=	-std=c++14
-.endif
+CXXSTD?=	c++14
 
 .include <bsd.lib.mk>

Modified: stable/12/lib/libc++fs/Makefile
==============================================================================
--- stable/12/lib/libc++fs/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libc++fs/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -22,8 +22,6 @@ CXXFLAGS+=	-nostdinc++
 CXXFLAGS+=	-nostdlib
 CXXFLAGS+=	-D_LIBCPP_BUILDING_LIBRARY
 CXXFLAGS+=	-DLIBCXXRT
-.if empty(CXXFLAGS:M-std=*)
-CXXFLAGS+=	-std=c++14
-.endif
+CXXSTD?=	c++14
 
 .include <bsd.lib.mk>

Modified: stable/12/lib/libc/tests/stdlib/Makefile
==============================================================================
--- stable/12/lib/libc/tests/stdlib/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libc/tests/stdlib/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -49,8 +49,8 @@ PROGS+=		h_getopt h_getopt_long
 
 CFLAGS+=	-I${.CURDIR}
 
-CXXFLAGS.cxa_thread_atexit_test+=	-std=c++11
-CXXFLAGS.cxa_thread_atexit_nothr_test+=	-std=c++11
+CXXSTD.cxa_thread_atexit_test=	c++11
+CXXSTD.cxa_thread_atexit_nothr_test=	c++11
 LIBADD.cxa_thread_atexit_test+=		pthread
 
 .for t in h_getopt h_getopt_long

Modified: stable/12/lib/libclang_rt/Makefile.inc
==============================================================================
--- stable/12/lib/libclang_rt/Makefile.inc	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libclang_rt/Makefile.inc	Thu May 23 01:09:10 2019	(r348138)
@@ -41,4 +41,4 @@ CFLAGS+=	-funwind-tables
 CXXFLAGS+=	-fvisibility-inlines-hidden
 CXXFLAGS+=	-fvisibility=hidden
 CFLAGS+=	-I${CRTSRC}/lib
-CXXFLAGS+=	-std=c++11
+CXXSTD=		c++11

Modified: stable/12/lib/libcxxrt/Makefile
==============================================================================
--- stable/12/lib/libcxxrt/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libcxxrt/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -22,9 +22,7 @@ SRCS+=		libelftc_dem_gnu3.c\
 
 WARNS=		0
 CFLAGS+=	-isystem ${SRCDIR} -nostdinc++
-.if empty(CXXFLAGS:M-std=*)
-CXXFLAGS+=	-std=c++11
-.endif
+CXXSTD?=	c++11
 VERSION_MAP=	${.CURDIR}/Version.map
 
 .include <bsd.lib.mk>

Modified: stable/12/lib/libgcc_eh/Makefile.inc
==============================================================================
--- stable/12/lib/libgcc_eh/Makefile.inc	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libgcc_eh/Makefile.inc	Thu May 23 01:09:10 2019	(r348138)
@@ -27,10 +27,8 @@ CXXFLAGS.${file}+=	-fno-exceptions -funwind-tables
 .endfor
 
 CFLAGS+=	-I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY
-.if empty(CXXFLAGS:M-std=*)
-CXXFLAGS+=	-std=c++11
-.endif
 CXXFLAGS+=	-fno-rtti
+CXXSTD?=	c++11
 STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC
 # Probably need to just move this earlier or use CXXFLAGS
 .if ${MK_DIRDEPS_BUILD} == "yes"

Modified: stable/12/lib/libomp/Makefile
==============================================================================
--- stable/12/lib/libomp/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/libomp/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -53,9 +53,9 @@ CFLAGS+=	-I${ITTSRC}
 CFLAGS+=	-ffunction-sections
 CFLAGS+=	-fdata-sections
 CXXFLAGS+=	-fvisibility-inlines-hidden
-CXXFLAGS+=	-std=c++11
 CXXFLAGS+=	-fno-exceptions
 CXXFLAGS+=	-fno-rtti
+CXXSTD=		c++11
 
 LDFLAGS+=	-Wl,--warn-shared-textrel
 LDFLAGS+=	-Wl,--gc-sections

Modified: stable/12/lib/ofed/libibnetdisc/Makefile
==============================================================================
--- stable/12/lib/ofed/libibnetdisc/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/lib/ofed/libibnetdisc/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -32,7 +32,7 @@ CFLAGS+=	-DHAVE_CONFIG_H=1
 CFLAGS+=	-I${_spath}
 CFLAGS+=	-I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
 .if ${COMPILER_FEATURES:Mc++11}
-CXXFLAGS+=	-std=c++11
+CXXSTD=		c++11
 .endif
 VERSION_MAP=	${_spath}/libibnetdisc.map
 

Modified: stable/12/share/examples/tests/tests/Makefile
==============================================================================
--- stable/12/share/examples/tests/tests/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/share/examples/tests/tests/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -1,5 +1,7 @@
 # $FreeBSD$
 
+.include <src.opts.mk>
+
 # Directory into which the Kyuafile provided by this directory will be
 # installed.
 #
@@ -20,6 +22,10 @@
 TESTS_SUBDIRS+=	atf
 TESTS_SUBDIRS+=	plain
 TESTS_SUBDIRS+=	tap
+
+.if ${MK_GOOGLETEST} != no
+TESTS_SUBDIRS+= googletest
+.endif
 
 # We leave KYUAFILE unset so that bsd.test.mk auto-generates a Kyuafile
 # for us based on the contents of the TESTS_SUBDIRS line above.  The

Modified: stable/12/share/mk/Makefile
==============================================================================
--- stable/12/share/mk/Makefile	Thu May 23 00:59:05 2019	(r348137)
+++ stable/12/share/mk/Makefile	Thu May 23 01:09:10 2019	(r348138)
@@ -73,6 +73,8 @@ FILESDIR=	${BINDIR}/mk

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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