From 24c93e4a936e94bdbfabdf825e88a3bb5ad68250 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 11 Mar 2019 22:39:06 +0000 Subject: [PATCH 1/5] Remove optional files when MK_GOOGLETEST == yes --- tools/build/mk/OptionalObsoleteFiles.inc | 129 +++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 72a938cb8765..53d234c73569 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -2776,6 +2776,135 @@ OLD_FILES+=usr/libexec/gdb OLD_FILES+=usr/libexec/kgdb .endif +.if ${MK_GOOGLETEST} == no +OLD_FILES+=usr/include/gmock/gmock-actions.h +OLD_FILES+=usr/include/gmock/gmock-cardinalities.h +OLD_FILES+=usr/include/gmock/gmock-generated-actions.h +OLD_FILES+=usr/include/gmock/gmock-generated-function-mockers.h +OLD_FILES+=usr/include/gmock/gmock-generated-matchers.h +OLD_FILES+=usr/include/gmock/gmock-generated-nice-strict.h +OLD_FILES+=usr/include/gmock/gmock-matchers.h +OLD_FILES+=usr/include/gmock/gmock-more-actions.h +OLD_FILES+=usr/include/gmock/gmock-more-matchers.h +OLD_FILES+=usr/include/gmock/gmock-spec-builders.h +OLD_FILES+=usr/include/gmock/gmock.h +OLD_FILES+=usr/include/gmock/internal/custom/gmock-generated-actions.h +OLD_FILES+=usr/include/gmock/internal/custom/gmock-matchers.h +OLD_FILES+=usr/include/gmock/internal/custom/gmock-port.h +OLD_FILES+=usr/include/gmock/internal/gmock-generated-internal-utils.h +OLD_FILES+=usr/include/gmock/internal/gmock-internal-utils.h +OLD_FILES+=usr/include/gmock/internal/gmock-port.h +OLD_DIRS+=usr/include/gmock +OLD_FILES+=usr/include/gtest/gtest_pred_impl.h +OLD_FILES+=usr/include/gtest/gtest_prod.h +OLD_FILES+=usr/include/gtest/gtest-death-test.h +OLD_FILES+=usr/include/gtest/gtest-message.h +OLD_FILES+=usr/include/gtest/gtest-param-test.h +OLD_FILES+=usr/include/gtest/gtest-printers.h +OLD_FILES+=usr/include/gtest/gtest-spi.h +OLD_FILES+=usr/include/gtest/gtest-test-part.h +OLD_FILES+=usr/include/gtest/gtest-typed-test.h +OLD_FILES+=usr/include/gtest/gtest.h +OLD_FILES+=usr/include/gtest/internal/custom/gtest-port.h +OLD_FILES+=usr/include/gtest/internal/custom/gtest-printers.h +OLD_FILES+=usr/include/gtest/internal/custom/gtest.h +OLD_FILES+=usr/include/gtest/internal/gtest-death-test-internal.h +OLD_FILES+=usr/include/gtest/internal/gtest-filepath.h +OLD_FILES+=usr/include/gtest/internal/gtest-internal.h +OLD_FILES+=usr/include/gtest/internal/gtest-linked_ptr.h +OLD_FILES+=usr/include/gtest/internal/gtest-param-util-generated.h +OLD_FILES+=usr/include/gtest/internal/gtest-param-util.h +OLD_FILES+=usr/include/gtest/internal/gtest-port-arch.h +OLD_FILES+=usr/include/gtest/internal/gtest-port.h +OLD_FILES+=usr/include/gtest/internal/gtest-string.h +OLD_FILES+=usr/include/gtest/internal/gtest-tuple.h +OLD_FILES+=usr/include/gtest/internal/gtest-type-util.h +OLD_DIRS+=usr/include/gtest +OLD_FILES+=usr/lib/libprivategmock_main.a +OLD_FILES+=usr/lib/libprivategmock_main.so +OLD_LIBS+=usr/lib/libprivategmock_main.so.0 +OLD_FILES+=usr/lib/libprivategmock_main_p.a +OLD_FILES+=usr/lib/libprivategmock.a +OLD_FILES+=usr/lib/libprivategmock.so +OLD_LIBS+=usr/lib/libprivategmock.so.0 +OLD_FILES+=usr/lib/libprivategmock_p.a +OLD_FILES+=usr/lib/libprivategtest_main.a +OLD_FILES+=usr/lib/libprivategtest_main.so +OLD_LIBS+=usr/lib/libprivategtest_main.so.0 +OLD_FILES+=usr/lib/libprivategtest_main_p.a +OLD_FILES+=usr/lib/libprivategtest.a +OLD_FILES+=usr/lib/libprivategtest.so +OLD_LIBS+=usr/lib/libprivategtest.so.0 +OLD_FILES+=usr/lib/libprivategtest_p.a +OLD_FILES+=usr/tests/lib/googletest/gmock/gmock_stress_test +OLD_FILES+=usr/tests/lib/googletest/gmock/Kyuafile +OLD_DIRS+=usr/tests/lib/googletest/gmock +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock_ex_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock_link_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-actions_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-cardinalities_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-ex_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-actions_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-function-mockers_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-internal-utils_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-matchers_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-internal-utils_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-matchers_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-more-actions_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-nice-strict_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-port_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-spec-builders_test +OLD_FILES+=usr/tests/lib/googletest/gmock_main/Kyuafile +OLD_DIRS+=usr/tests/lib/googletest/gmock_main +OLD_FILES+=usr/tests/lib/googletest/gtest/googletest-param-test-test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_all_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_environment_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_no_test_unittest +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_premature_exit_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_repeat_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_stress_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest_throw_on_failure_ex_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest-death-test_ex_catch_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest-death-test_ex_nocatch_test +OLD_FILES+=usr/tests/lib/googletest/gtest/gtest-unittest-api_test +OLD_FILES+=usr/tests/lib/googletest/gtest/Kyuafile +OLD_DIRS+=usr/tests/lib/googletest/gtest +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-death-test-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-filepath-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-linked-ptr-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-listener-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-message-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-options-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-port-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-printers-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-test-part-test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_help_test_ +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_main_unittest +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_pred_impl_unittest +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_prod_test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_sole_header_test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_unittest +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_xml_outfile1_test_ +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest_xml_outfile2_test_ +OLD_FILES+=usr/tests/lib/googletest/gtest_main/gtest-typed-test_test +OLD_FILES+=usr/tests/lib/googletest/gtest_main/Kyuafile +OLD_DIRS+=usr/tests/lib/googletest/gtest_main +OLD_FILES+=usr/tests/lib/googletest/Kyuafile +OLD_DIRS+=usr/tests/lib/googletest/ +OLD_FILES+=usr/tests/share/examples/tests/googletest/Kyuafile +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample1_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample10_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample2_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample3_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample4_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample5_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample6_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample7_unittest +OLD_FILES+=usr/tests/share/examples/tests/googletest/sample8_unittest +OLD_DIRS+=usr/tests/share/examples/tests/googletest +.endif + .if ${MK_GPIO} == no OLD_FILES+=usr/include/libgpio.h OLD_FILES+=usr/lib/libgpio.a From 9e670beb61ec5967fea4b5eb23e0d7f245c7ba7b Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 11 Mar 2019 22:43:24 +0000 Subject: [PATCH 2/5] Tweak the examples integration * Install the samples to the correct directory. * Annotate with comments, like the other directories. * Simplify the for loops; they were only needed for matching which tests require `libgtest` instead of `libgtest_main`. --- .../examples/tests/tests/googletest/Makefile | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/share/examples/tests/tests/googletest/Makefile b/share/examples/tests/tests/googletest/Makefile index 1709b478a904..db1cbd322d4d 100644 --- a/share/examples/tests/tests/googletest/Makefile +++ b/share/examples/tests/tests/googletest/Makefile @@ -1,4 +1,24 @@ # $FreeBSD$ +# +# This Makefile differs from the other examples, in the sense that its purpose +# is to install the upstream provided googletest sample unit tests. + +# The release package to use for the tests contained within the directory +# +# This applies to components which rely on ^/projects/release-pkg support +# (see UPDATING XXXXXXXXX / svn revision r298107). +PACKAGE= tests + +# Directory into which the Kyuafile provided by this directory will be +# installed. +# +# This is always a subdirectory of ${TESTSBASE}/. The remainder of the +# path has to match the relative path within the source tree in which +# these files are found modulo the tests/ component at the end. +# +# For example: if this Makefile were in src/bin/cp/tests/, its TESTSDIR +# would point at ${TESTSBASE}/bin/cp/. +TESTSDIR= ${TESTSBASE}/share/examples/tests/googletest .PATH: ${SRCTOP}/contrib/googletest/googletest/samples @@ -16,18 +36,21 @@ GTEST_MAIN_REQ_TESTS+= sample8_unittest #GTEST_REQ_TESTS+= sample9_unittest GTEST_REQ_TESTS+= sample10_unittest -.for t in ${GTEST_MAIN_REQ_TESTS} -GTESTS+= $t +# List of test programs to build. Note that we can build more than one +# test from a single directory, and this is expected. +GTESTS+= ${GTEST_MAIN_REQ_TESTS} ${GTEST_REQ_TESTS} + +# +.for t in ${GTESTS} +.if ${GTEST_MAIN_REQ_TESTS:M$t} LIBADD.$t+= gtest_main -SRCS.$t+= $t.cc -.endfor - -.for t in ${GTEST_REQ_TESTS} -GTESTS+= $t +.else LIBADD.$t+= gtest +.endif SRCS.$t+= $t.cc .endfor +# Additional sources for sample testcase 1, 2, 4, and 5. SRCS.sample1_unittest+= sample1.cc SRCS.sample2_unittest+= sample2.cc SRCS.sample4_unittest+= sample4.cc From d0eac77abf397af6878cdc49ae1b090a92b04540 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 11 Mar 2019 23:27:50 +0000 Subject: [PATCH 3/5] Fix integration with zfsd_unittest The previous code didn't nul out SRCS after setting the pre-bsd.progs.mk value, however, when recursing down into bsd.prog.mk, it was appending the per-prog value to the value of SRCS. The other catch is that code did not install the zfsd headers, so some of the headers, e.g., callout.h could not be found. So, add `-I${SRCTOP}/cddl/usr.sbin` to CXXFLAGS. While here, fix a typo: `LIBDADD.zfsd_unittest` should have been `LIBADD.zfsd_unittest`, and remove the superfluous `DPADD` part which was never required post-LIBADD integration. --- cddl/usr.sbin/zfsd/Makefile.common | 5 ++--- cddl/usr.sbin/zfsd/tests/Makefile | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common index 061a26a28343..2f1b7b9f5a32 100644 --- a/cddl/usr.sbin/zfsd/Makefile.common +++ b/cddl/usr.sbin/zfsd/Makefile.common @@ -28,12 +28,11 @@ INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair 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} -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" \) \ diff --git a/cddl/usr.sbin/zfsd/tests/Makefile b/cddl/usr.sbin/zfsd/tests/Makefile index ca585d509234..1b776b217776 100644 --- a/cddl/usr.sbin/zfsd/tests/Makefile +++ b/cddl/usr.sbin/zfsd/tests/Makefile @@ -7,7 +7,8 @@ GTESTS= zfsd_unittest SRCS.zfsd_unittest:= ${SRCS:Nzfsd_main.cc} SRCS.zfsd_unittest+= libmocks.c zfsd_unittest.cc +.undef SRCS -LIBDADD.zfsd_unittest+= gmock_main +LIBADD.zfsd_unittest+= gmock_main .include From dde07f1c14f9a5f100d7dc51308bbbf3490d594e Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 12 Mar 2019 01:12:34 +0000 Subject: [PATCH 4/5] Adjust code based on comments from @asomers in D19551 --- share/mk/googletest.test.inc.mk | 5 ++++- tools/build/options/WITHOUT_GOOGLETEST | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/share/mk/googletest.test.inc.mk b/share/mk/googletest.test.inc.mk index 8f9b8400c8b8..c38be7adb353 100644 --- a/share/mk/googletest.test.inc.mk +++ b/share/mk/googletest.test.inc.mk @@ -1,10 +1,13 @@ # $FreeBSD$ +# XXX: this should be defined in bsd.sys.mk +CXXSTD?= c++11 + GTESTS_CXXFLAGS+= -DGTEST_HAS_POSIX_RE=1 GTESTS_CXXFLAGS+= -DGTEST_HAS_PTHREAD=1 GTESTS_CXXFLAGS+= -DGTEST_HAS_STREAM_REDIRECTION=1 GTESTS_CXXFLAGS+= -frtti -GTESTS_CXXFLAGS+= -std=c++11 +GTESTS_CXXFLAGS+= -std=${CXXSTD} # XXX: src.libnames.mk should handle adding this directory. GTESTS_CXXFLAGS+= -I${DESTDIR}${INCLUDEDIR}/private diff --git a/tools/build/options/WITHOUT_GOOGLETEST b/tools/build/options/WITHOUT_GOOGLETEST index 1ac48fbf9372..a76112e07fa4 100644 --- a/tools/build/options/WITHOUT_GOOGLETEST +++ b/tools/build/options/WITHOUT_GOOGLETEST @@ -1,5 +1,5 @@ .\" $FreeBSD$ -Set to not build nor install +Set to neither build nor install .Lb libgmock , .Lb libgtest , and dependent tests. From 40d840826287bffc69f383642901872a9d8a5332 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 12 Mar 2019 02:43:07 +0000 Subject: [PATCH 5/5] The zfsd tests need to depend on MK_GOOGLETEST instead of MK_TESTS This will unbreak the build with mips*/powerpc*. --- cddl/usr.sbin/zfsd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cddl/usr.sbin/zfsd/Makefile b/cddl/usr.sbin/zfsd/Makefile index 205d4b84c200..88eb9220a8cc 100644 --- a/cddl/usr.sbin/zfsd/Makefile +++ b/cddl/usr.sbin/zfsd/Makefile @@ -8,6 +8,6 @@ PROG_CXX= zfsd MAN= zfsd.8 HAS_TESTS= -SUBDIR.${MK_TESTS}+= tests +SUBDIR.${MK_GOOGLETEST}+= tests .include