3 # You must include bsd.test.mk instead of this file from your Makefile.
5 # Internal glue for the build of /usr/tests/.
7 .if !target(__<bsd.test.mk>__)
8 .error suite.test.mk cannot be included directly.
11 .include <bsd.opts.mk>
13 # Name of the test suite these tests belong to. Should rarely be changed for
14 # Makefiles built into the FreeBSD src tree.
17 # Knob to control the handling of the Kyuafile for this Makefile.
19 # If 'yes', a Kyuafile exists in the source tree and is installed into
22 # If 'auto', a Kyuafile is automatically generated based on the list of test
23 # programs built by the Makefile and is installed into TESTSDIR. This is the
24 # default and is sufficient in the majority of the cases.
26 # If 'no', no Kyuafile is installed.
29 # Per-test program interface definition.
31 # The name provided here must match one of the interface names supported by
32 # Kyua as this is later encoded in the Kyuafile test program definitions.
33 #TEST_INTERFACE.<test-program>= interface-name
35 # Metadata properties applicable to all test programs.
37 # All the variables for a test program defined in the Makefile are appended
38 # to the test program's definition in the Kyuafile. This feature can be
39 # used to avoid having to explicitly supply a Kyuafile in the source
40 # directory, allowing the caller Makefile to rely on the KYUAFILE=auto
41 # behavior defined here.
42 #TEST_METADATA+= key="value"
44 # Per-test program metadata properties as a list of key/value pairs.
46 # These per-test program settings _extend_ the values provided in the
47 # unqualified TEST_METADATA variable.
48 #TEST_METADATA.<test-program>+= key="value"
50 .if ${KYUAFILE:tl} != "no"
51 ${PACKAGE}FILES+= Kyuafile
52 ${PACKAGE}FILESDIR_Kyuafile= ${TESTSDIR}
56 _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}}
59 .if ${KYUAFILE:tl} == "auto"
60 CLEANFILES+= Kyuafile Kyuafile.tmp
63 echo '-- Automatically generated by bsd.test.mk.'; \
67 echo 'test_suite("${TESTSUITE}")'; \
71 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
74 .for _T in ${TESTS_SUBDIRS:N.WAIT}
75 @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp
77 @mv ${.TARGET}.tmp ${.TARGET}
80 KYUA= ${LOCALBASE}/bin/kyua
82 MAKE_CHECK_SANDBOX_DIR= ${.OBJDIR}/checkdir
83 CLEANDIRS+= ${MAKE_CHECK_SANDBOX_DIR}
85 .if ${MK_MAKE_CHECK_USE_SANDBOX} != "no" && make(check)
86 DESTDIR:= ${MAKE_CHECK_SANDBOX_DIR}
88 .if ${MK_MAKE_CHECK_TEST_WITH_COVERAGE} != "no"
92 TESTS_ENV+= GCOV=${GCOV} GCOV_PREFIX=${GCOV_PREFIX}
96 .for t in clean depend all
97 .for dir in ${SRCTOP}/tests/tools ${.CURDIR}
98 @cd ${dir} && ${MAKE} $t
101 @cd ${SRCTOP} && ${MAKE} hierarchy DESTDIR=${DESTDIR}
102 .for dir in ${SRCTOP}/tests/tools ${.CURDIR}
103 @cd ${dir} && ${MAKE} install DESTDIR=${DESTDIR}
106 # NOTE: this is intentional to ensure that "make check" can be run multiple
107 # times. "aftercheck" won't be run if "make check" fails, is interrupted,
110 find ${GCOV_PREFIX} -name \*.gcda
111 .if ${MK_MAKE_CHECK_TEST_WITH_COVERAGE} != "no"
112 @env ${TESTS_ENV:Q} ${TESTSBASE}/tools/gather_coverage
114 @cd ${.CURDIR} && ${MAKE} clean
117 # Definition of the "make check" target and supporting variables.
119 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
120 # host building a release for the same system). The target runs Kyua, which is
121 # not in the toolchain, and the tests execute code built for the target host.
123 # Due to the dependencies of the binaries built by the source tree and how they
124 # are used by tests, it is highly possible for a execution of "make test" to
125 # report bogus results unless the new binaries are put in place.
128 @if [ ! -x ${KYUA} ]; then \
130 echo "kyua binary not installed at expected location (${.TARGET})"; \
132 echo "Please install via pkg install, or specify the path to the kyua"; \
133 echo "package via the \$${LOCALBASE} variable, e.g. "; \
134 echo "LOCALBASE=\"${LOCALBASE}\""; \
137 @env ${TESTS_ENV:Q} ${KYUA} test ${KYUA_VARIABLES} \
138 -k ${DESTDIR}${TESTSDIR}/Kyuafile