diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2019-03-15 21:43:52 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2019-03-15 21:43:52 +0000 |
commit | 5193fcde8d29e5fe3056c8cf7b0d7a004c20a632 (patch) | |
tree | 99394130905a7e71453fabc72babc000d1488f9e /share/examples/tests | |
parent | 398467c1e4ead3eb2c66e1a8d42b2cc70bbbf9e7 (diff) | |
parent | eb1761b0043a48aec97571975fe304979a7310d0 (diff) |
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)
Reviewed by: asomers
Approved by: emaste (mentor)
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D19551
Notes
Notes:
svn path=/head/; revision=345203
Diffstat (limited to 'share/examples/tests')
-rw-r--r-- | share/examples/tests/tests/Makefile | 6 | ||||
-rw-r--r-- | share/examples/tests/tests/googletest/Makefile | 59 |
2 files changed, 65 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> |