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 _kyuafile= ${DESTDIR}${TESTSDIR}/Kyuafile
90 # Definition of the "make test" target and supporting variables.
92 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
93 # host building a release for the same system). The target runs Kyua, which is
94 # not in the toolchain, and the tests execute code built for the target host.
96 # Due to the dependencies of the binaries built by the source tree and how they
97 # are used by tests, it is highly possible for a execution of "make test" to
98 # report bogus results unless the new binaries are put in place.
100 @${KYUA} test -k ${_kyuafile}
104 .if !defined(TESTSDIR)
105 @echo "*** No TESTSDIR defined; nothing to do."
108 .if ${KYUAFILE:tl} != "no"
109 @if [ ! -f ${_kyuafile} ]; then \
110 echo "*** Please run make install and make test for" \
111 "end-to-end testing"; \
114 @if [ "${KYUAFILE:tl}" = yes ]; then \
119 if [ ${_kyuafile} -ot Kyuafile$$ext ]; then \
120 echo "*** ${_kyuafile} is older than " \
121 "${.OBJDIR}/Kyuafile$$ext"; \
122 echo "*** Please run make install before running make test"; \