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 # Name of the test suite these tests belong to. Should rarely be changed for
12 # Makefiles built into the FreeBSD src tree.
15 # Knob to control the handling of the Kyuafile for this Makefile.
17 # If 'yes', a Kyuafile exists in the source tree and is installed into
20 # If 'auto', a Kyuafile is automatically generated based on the list of test
21 # programs built by the Makefile and is installed into TESTSDIR. This is the
22 # default and is sufficient in the majority of the cases.
24 # If 'no', no Kyuafile is installed.
27 # Per-test program interface definition.
29 # The name provided here must match one of the interface names supported by
30 # Kyua as this is later encoded in the Kyuafile test program definitions.
31 #TEST_INTERFACE.<test-program>= interface-name
33 # Metadata properties applicable to all test programs.
35 # All the variables for a test program defined in the Makefile are appended
36 # to the test program's definition in the Kyuafile. This feature can be
37 # used to avoid having to explicitly supply a Kyuafile in the source
38 # directory, allowing the caller Makefile to rely on the KYUAFILE=auto
39 # behavior defined here.
40 #TEST_METADATA+= key="value"
42 # Per-test program metadata properties as a list of key/value pairs.
44 # These per-test program settings _extend_ the values provided in the
45 # unqualified TEST_METADATA variable.
46 #TEST_METADATA.<test-program>+= key="value"
48 # Path to the prefix of the installed Kyua CLI, if any.
50 # If kyua is installed from ports, we automatically define a realtest target
51 # below to run the tests using this tool. The tools are searched for in the
52 # hierarchy specified by this variable.
53 KYUA_PREFIX?= /usr/local
55 .if ${KYUAFILE:tl} != "no"
57 FILESDIR_Kyuafile= ${TESTSDIR}
60 .if ${KYUAFILE:tl} == "auto"
61 CLEANFILES+= Kyuafile Kyuafile.auto.tmp
65 _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}}
70 echo '-- Automatically generated by bsd.test.mk.'; \
74 echo 'test_suite("${TESTSUITE}")'; \
78 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
81 .for _T in ${TESTS_SUBDIRS:N.WAIT}
82 @echo "include(\"${_T}/Kyuafile\")" >>${.TARGET}.tmp
84 @mv ${.TARGET}.tmp ${.TARGET}
87 KYUA?= ${KYUA_PREFIX}/bin/kyua
89 # Definition of the "make test" target and supporting variables.
91 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
92 # host building a release for the same system). The target runs Kyua, which is
93 # not in the toolchain, and the tests execute code built for the target host.
95 # Due to the dependencies of the binaries built by the source tree and how they
96 # are used by tests, it is highly possible for a execution of "make test" to
97 # report bogus results unless the new binaries are put in place.
99 @echo "*** WARNING: make test is experimental"
101 @echo "*** Using this test does not preclude you from running the tests"
102 @echo "*** installed in ${TESTSBASE}. This test run may raise false"
103 @echo "*** positives and/or false negatives."
105 @${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \
108 echo "*** Once again, note that "make test" is unsupported."; \
109 test $${result} -eq 0
113 .if defined(TESTSDIR)
114 .if ${TESTSDIR} == ${TESTSBASE}
115 # Forbid running from ${TESTSBASE}. It can cause false positives/negatives and
116 # it does not cover all the tests (e.g. it misses testing software in external).
117 @echo "*** Sorry, you cannot use make test from src/tests. Install the"
118 @echo "*** tests into their final location and run them from ${TESTSBASE}"
121 @echo "*** Using this test does not preclude you from running the tests"
122 @echo "*** installed in ${TESTSBASE}. This test run may raise false"
123 @echo "*** positives and/or false negatives."
126 @echo "*** No TESTSDIR defined; nothing to do."