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 # Directory in which to install tests defined by the current Makefile.
12 # Makefiles have to override this to point to a subdirectory of TESTSBASE.
15 # Name of the test suite these tests belong to. Should rarely be changed for
16 # Makefiles built into the FreeBSD src tree.
19 # Knob to control the handling of the Kyuafile for this Makefile.
21 # If 'yes', a Kyuafile exists in the source tree and is installed into
24 # If 'auto', a Kyuafile is automatically generated based on the list of test
25 # programs built by the Makefile and is installed into TESTSDIR. This is the
26 # default and is sufficient in the majority of the cases.
28 # If 'no', no Kyuafile is installed.
31 # Per-test program interface definition.
33 # The name provided here must match one of the interface names supported by
34 # Kyua as this is later encoded in the Kyuafile test program definitions.
35 #TEST_INTERFACE.<test-program>= interface-name
37 # Per-test program metadata properties as a list of key/value pairs.
39 # All the variables for a particular program are appended to the program's
40 # definition in the Kyuafile. This feature can be used to avoid having to
41 # explicitly supply a Kyuafile in the source directory, allowing the caller
42 # Makefile to rely on the KYUAFILE=auto behavior defined here.
43 #TEST_METADATA.<test-program>+= key="value"
45 # Path to the prefix of the installed Kyua CLI, if any.
47 # If kyua is installed from ports, we automatically define a realtest target
48 # below to run the tests using this tool. The tools are searched for in the
49 # hierarchy specified by this variable.
50 KYUA_PREFIX?= /usr/local
52 .if ${KYUAFILE:tl} == "yes"
54 FILESDIR_Kyuafile= ${TESTSDIR}
56 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
57 .elif ${KYUAFILE:tl} == "auto"
59 FILESDIR_Kyuafile.auto= ${TESTSDIR}
60 FILESNAME_Kyuafile.auto= Kyuafile
62 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
64 .NOPATH: Kyuafile.auto
65 Kyuafile.auto: Makefile
67 echo '-- Automatically generated by bsd.test.mk.'; \
71 echo 'test_suite("${TESTSUITE}")'; \
75 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
78 .for _T in ${TESTS_SUBDIRS:N.WAIT}
79 @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.auto.tmp
81 @mv Kyuafile.auto.tmp Kyuafile.auto
84 KYUA?= ${KYUA_PREFIX}/bin/kyua
86 # Definition of the "make test" target and supporting variables.
88 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
89 # host building a release for the same system). The target runs Kyua, which is
90 # not in the toolchain, and the tests execute code built for the target host.
92 # Due to the dependencies of the binaries built by the source tree and how they
93 # are used by tests, it is highly possible for a execution of "make test" to
94 # report bogus results unless the new binaries are put in place.
96 @echo "*** WARNING: make test is experimental"
98 @echo "*** Using this test does not preclude you from running the tests"
99 @echo "*** installed in ${TESTSBASE}. This test run may raise false"
100 @echo "*** positives and/or false negatives."
103 ${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \
106 echo "*** Once again, note that "make test" is unsupported."; \
107 test $${result} -eq 0
111 .if defined(TESTSDIR)
112 .if ${TESTSDIR} == ${TESTSBASE}
113 # Forbid running from ${TESTSBASE}. It can cause false positives/negatives and
114 # it does not cover all the tests (e.g. it misses testing software in external).
115 @echo "*** Sorry, you cannot use make test from src/tests. Install the"
116 @echo "*** tests into their final location and run them from ${TESTSBASE}"
119 @echo "*** Using this test does not preclude you from running the tests"
120 @echo "*** installed in ${TESTSBASE}. This test run may raise false"
121 @echo "*** positives and/or false negatives."
124 @echo "*** No TESTSDIR defined; nothing to do."