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 # Metadata properties applicable to all test programs.
39 # All the variables for a test program defined in the Makefile are appended
40 # to the test program's definition in the Kyuafile. This feature can be
41 # used to avoid having to explicitly supply a Kyuafile in the source
42 # directory, allowing the caller Makefile to rely on the KYUAFILE=auto
43 # behavior defined here.
44 #TEST_METADATA+= key="value"
46 # Per-test program metadata properties as a list of key/value pairs.
48 # These per-test program settings _extend_ the values provided in the
49 # unqualified TEST_METADATA variable.
50 #TEST_METADATA.<test-program>+= key="value"
52 # Path to the prefix of the installed Kyua CLI, if any.
54 # If kyua is installed from ports, we automatically define a realregress target
55 # below to run the tests using this tool. The tools are searched for in the
56 # hierarchy specified by this variable.
57 KYUA_PREFIX?= /usr/local
59 .if ${KYUAFILE:tl} == "yes"
61 FILESDIR_Kyuafile= ${TESTSDIR}
63 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
64 .elif ${KYUAFILE:tl} == "auto"
66 FILESDIR_Kyuafile.auto= ${TESTSDIR}
67 FILESNAME_Kyuafile.auto= Kyuafile
69 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
72 _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}}
75 .NOPATH: Kyuafile.auto
76 Kyuafile.auto: Makefile
78 echo '-- Automatically generated by bsd.test.mk.'; \
82 echo 'test_suite("${TESTSUITE}")'; \
86 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
89 .for _T in ${TESTS_SUBDIRS:N.WAIT}
90 @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.auto.tmp
92 @mv Kyuafile.auto.tmp Kyuafile.auto
95 KYUA?= ${KYUA_PREFIX}/bin/kyua
97 _kyuafile= ${DESTDIR}${TESTSDIR}/Kyuafile
101 # Definition of the "make test" target and supporting variables.
103 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
104 # host building a release for the same system). The target runs Kyua, which is
105 # not in the toolchain, and the tests execute code built for the target host.
107 # Due to the dependencies of the binaries built by the source tree and how they
108 # are used by tests, it is highly possible for a execution of "make test" to
109 # report bogus results unless the new binaries are put in place.
111 @${KYUA} test -k ${_kyuafile}
114 beforeregress: .PHONY
115 .if !defined(TESTSDIR)
116 @echo "*** No TESTSDIR defined; nothing to do."