diff options
Diffstat (limited to 'share')
-rw-r--r-- | share/examples/tests/tests/Makefile | 6 | ||||
-rw-r--r-- | share/examples/tests/tests/googletest/Makefile | 59 | ||||
-rw-r--r-- | share/mk/Makefile | 2 | ||||
-rw-r--r-- | share/mk/bsd.README | 2 | ||||
-rw-r--r-- | share/mk/bsd.test.mk | 1 | ||||
-rw-r--r-- | share/mk/googletest.test.inc.mk | 15 | ||||
-rw-r--r-- | share/mk/googletest.test.mk | 41 | ||||
-rw-r--r-- | share/mk/src.libnames.mk | 30 | ||||
-rw-r--r-- | share/mk/src.opts.mk | 6 |
9 files changed, 162 insertions, 0 deletions
diff --git a/share/examples/tests/tests/Makefile b/share/examples/tests/tests/Makefile index 35106d686776..e5bbd7813352 100644 --- a/share/examples/tests/tests/Makefile +++ b/share/examples/tests/tests/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include <src.opts.mk> + # Directory into which the Kyuafile provided by this directory will be # installed. # @@ -21,6 +23,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 # generated file will tell the tests run-time engine to recurse into the diff --git a/share/examples/tests/tests/googletest/Makefile b/share/examples/tests/tests/googletest/Makefile new file mode 100644 index 000000000000..db1cbd322d4d --- /dev/null +++ b/share/examples/tests/tests/googletest/Makefile @@ -0,0 +1,59 @@ +# $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 + +GTEST_MAIN_REQ_TESTS+= sample1_unittest +GTEST_MAIN_REQ_TESTS+= sample2_unittest +GTEST_MAIN_REQ_TESTS+= sample3_unittest +GTEST_MAIN_REQ_TESTS+= sample4_unittest +GTEST_MAIN_REQ_TESTS+= sample5_unittest +GTEST_MAIN_REQ_TESTS+= sample6_unittest +GTEST_MAIN_REQ_TESTS+= sample7_unittest +GTEST_MAIN_REQ_TESTS+= sample8_unittest + +# sample9_unittest's `CustomOutputTest.Fails` fails intentionally to illustrate +# how output format can be adjusted with command-line parameters. +#GTEST_REQ_TESTS+= sample9_unittest +GTEST_REQ_TESTS+= sample10_unittest + +# 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 +.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 +SRCS.sample5_unittest+= sample1.cc + +.include <bsd.test.mk> diff --git a/share/mk/Makefile b/share/mk/Makefile index 714d86b74774..2fda6a04f266 100644 --- a/share/mk/Makefile +++ b/share/mk/Makefile @@ -73,6 +73,8 @@ FILESDIR= ${BINDIR}/mk .if ${MK_TESTS} != "no" FILES+= atf.test.mk +FILES+= googletest.test.inc.mk +FILES+= googletest.test.mk FILES+= plain.test.mk FILES+= suite.test.mk FILES+= tap.test.mk diff --git a/share/mk/bsd.README b/share/mk/bsd.README index 36a61e1d196e..c4db43ea5699 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -649,6 +649,8 @@ ATF_TESTS_CXX The names of the ATF C++ test programs to build. ATF_TESTS_SH The names of the ATF sh test programs to build. +GTESTS The names of the GoogleTest test programs to build. + KYUAFILE If 'auto' (the default), generate a Kyuafile out of the test programs defined in the Makefile. If 'yes', then a manually-crafted Kyuafile must be supplied with the diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk index c7e4f50d085f..072c5612ae29 100644 --- a/share/mk/bsd.test.mk +++ b/share/mk/bsd.test.mk @@ -63,6 +63,7 @@ _TESTS= # Pull in the definitions of all supported test interfaces. .include <atf.test.mk> +.include <googletest.test.mk> .include <plain.test.mk> .include <tap.test.mk> diff --git a/share/mk/googletest.test.inc.mk b/share/mk/googletest.test.inc.mk new file mode 100644 index 000000000000..c38be7adb353 --- /dev/null +++ b/share/mk/googletest.test.inc.mk @@ -0,0 +1,15 @@ +# $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=${CXXSTD} + +# XXX: src.libnames.mk should handle adding this directory. +GTESTS_CXXFLAGS+= -I${DESTDIR}${INCLUDEDIR}/private + +NO_WTHREAD_SAFETY= diff --git a/share/mk/googletest.test.mk b/share/mk/googletest.test.mk new file mode 100644 index 000000000000..b55f28d572f0 --- /dev/null +++ b/share/mk/googletest.test.mk @@ -0,0 +1,41 @@ +# $FreeBSD$ +# +# You must include bsd.test.mk instead of this file from your Makefile. +# +# Logic to build and install GoogleTest based test programs. +# +# GoogleTest is a C++ test framework, thus, it does not describe/articulate how +# to write tests in other languages, e.g., C or shell, unlike the ATF, plain, +# and TAP raw test interfaces. +# +# For now this is a thin wrapper around the `plain` test interface, but in the +# future this will rely on a newer version of kyua which will integrate in +# GoogleTest support. + +.if !target(__<bsd.test.mk>__) +.error googletest.test.mk cannot be included directly. +.endif + +# List of GoogleTest test programs to build. +# +# Programs listed here are built according to the semantics of bsd.progs.mk for +# PROGS_CXX. +# +# Test programs registered in this manner are set to be installed into TESTSDIR +# (which should be overridden by the Makefile) and are not required to provide a +# manpage. +GTESTS?= + +.if !empty(GTESTS) +.include <googletest.test.inc.mk> + +PROGS_CXX+= ${GTESTS} +_TESTS+= ${GTESTS} +.for _T in ${GTESTS} +BINDIR.${_T}= ${TESTSDIR} +CXXFLAGS.${_T}+= ${GTESTS_CXXFLAGS} +MAN.${_T}?= # empty +SRCS.${_T}?= ${_T}.cc +TEST_INTERFACE.${_T}= plain +.endfor +.endif diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index 13159718d962..d08a8653de3a 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -18,6 +18,10 @@ _PRIVATELIBS= \ bsdstat \ devdctl \ event \ + gmock \ + gtest \ + gmock_main \ + gtest_main \ heimipcc \ heimipcs \ ldns \ @@ -302,6 +306,10 @@ _DP_dpv= dialog figpar util ncursesw _DP_dialog= ncursesw m _DP_cuse= pthread _DP_atf_cxx= atf_c +_DP_gtest= pthread +_DP_gmock= gtest +_DP_gmock_main= gmock +_DP_gtest_main= gtest _DP_devstat= kvm _DP_pam= radius tacplus opie md util .if ${MK_KERBEROS} != "no" @@ -379,6 +387,15 @@ LIBATF_CXX= ${LIBDESTDIR}${LIBDIR_BASE}/libprivateatf-c++.a LDADD_atf_c= -lprivateatf-c LDADD_atf_cxx= -lprivateatf-c++ +LIBGMOCK= ${LIBDESTDIR}${LIBDIR_BASE}/libprivategmock.a +LIBGMOCK_MAIN= ${LIBDESTDIR}${LIBDIR_BASE}/libprivategmock_main.a +LIBGTEST= ${LIBDESTDIR}${LIBDIR_BASE}/libprivategtest.a +LIBGTEST_MAIN= ${LIBDESTDIR}${LIBDIR_BASE}/libprivategtest_main.a +LDADD_gmock= -lprivategmock +LDADD_gtest= -lprivategtest +LDADD_gmock_main= -lprivategmock_main +LDADD_gtest_main= -lprivategtest_main + .for _l in ${_PRIVATELIBS} LIB${_l:tu}?= ${LIBDESTDIR}${LIBDIR_BASE}/libprivate${_l}.a .endfor @@ -421,6 +438,15 @@ LDADD_${_l}+= ${LDADD_${_d}} DPADD_atf_cxx+= ${DPADD_atf_c} LDADD_atf_cxx+= ${LDADD_atf_c} +DPADD_gmock+= ${DPADD_gtest} +LDADD_gmock+= ${LDADD_gtest} + +DPADD_gmock_main+= ${DPADD_gmock} +LDADD_gmock_main+= ${LDADD_gmock} + +DPADD_gtest_main+= ${DPADD_gtest} +LDADD_gtest_main+= ${LDADD_gtest} + # Detect LDADD/DPADD that should be LIBADD, before modifying LDADD here. _BADLDADD= .for _l in ${LDADD:M-l*:N-l*/*:C,^-l,,} @@ -562,6 +588,10 @@ LIBROKENDIR= ${OBJTOP}/kerberos5/lib/libroken LIBWINDDIR= ${OBJTOP}/kerberos5/lib/libwind LIBATF_CDIR= ${OBJTOP}/lib/atf/libatf-c LIBATF_CXXDIR= ${OBJTOP}/lib/atf/libatf-c++ +LIBGMOCKDIR= ${OBJTOP}/lib/googletest/gmock +LIBGMOCK_MAINDIR= ${OBJTOP}/lib/googletest/gmock_main +LIBGTESTDIR= ${OBJTOP}/lib/googletest/gtest +LIBGTEST_MAINDIR= ${OBJTOP}/lib/googletest/gtest_main LIBALIASDIR= ${OBJTOP}/lib/libalias/libalias LIBBLACKLISTDIR= ${OBJTOP}/lib/libblacklist LIBBLOCKSRUNTIMEDIR= ${OBJTOP}/lib/libblocksruntime diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 9994496742cb..34e89f0190d5 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -108,6 +108,7 @@ __DEFAULT_YES_OPTIONS = \ GDB \ GNU_DIFF \ GNU_GREP \ + GOOGLETEST \ GPIO \ HAST \ HTML \ @@ -427,6 +428,7 @@ MK_${var}:= no # Order is somewhat important. # .if !${COMPILER_FEATURES:Mc++11} +MK_GOOGLETEST:= no MK_LLVM_LIBUNWIND:= no .endif @@ -507,6 +509,10 @@ MK_FREEBSD_UPDATE:= no MK_DTRACE_TESTS:= no .endif +.if ${MK_TESTS_SUPPORT} == "no" +MK_GOOGLETEST:= no +.endif + .if ${MK_ZONEINFO} == "no" MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no |