3 # Generic build infrastructure for test programs.
5 # The code in this file is independent of the implementation of the test
6 # programs being built; this file just provides generic infrastructure for the
7 # build and the definition of various helper variables and targets.
9 # Makefiles should never include this file directly. Instead, they should
10 # include one of the various *.test.mk depending on the specific test programs
13 .include <bsd.init.mk>
15 # Pointer to the top directory into which tests are installed. Should not be
16 # overriden by Makefiles, but the user may choose to set this in src.conf(5).
17 TESTSBASE?= /usr/tests
19 # Directory in which to install tests defined by the current Makefile.
20 # Makefiles have to override this to point to a subdirectory of TESTSBASE.
23 # Name of the test suite these tests belong to. Should rarely be changed for
24 # Makefiles built into the FreeBSD src tree.
27 # List of subdirectories containing tests into which to recurse. This has the
28 # same semantics as SUBDIR at build-time. However, the directories listed here
29 # get registered into the run-time test suite definitions so that the test
30 # engines know to recurse into these directories.
32 # In other words: list here any directories that contain test programs but use
33 # SUBDIR for directories that may contain helper binaries and/or data files.
36 # Knob to control the handling of the Kyuafile for this Makefile.
38 # If 'yes', a Kyuafile exists in the source tree and is installed into
41 # If 'auto', a Kyuafile is automatically generated based on the list of test
42 # programs built by the Makefile and is installed into TESTSDIR. This is the
43 # default and is sufficient in the majority of the cases.
45 # If 'no', no Kyuafile is installed.
48 # List of all tests being built. This variable is internal should not be
49 # defined by the Makefile. The various *.test.mk modules extend this variable
53 .if !empty(TESTS_SUBDIRS)
54 SUBDIR+= ${TESTS_SUBDIRS}
57 # it is rare for test cases to have man pages
63 # tell progs.mk we might want to install things
65 PROGS_TARGETS+= install
67 .if ${KYUAFILE:tl} != "no"
69 FILESDIR_Kyuafile= ${TESTSDIR}
71 .if ${KYUAFILE:tl} == "auto"
72 CLEANFILES+= Kyuafile Kyuafile.tmp
76 echo '-- Automatically generated by bsd.test.mk.'; \
80 echo 'test_suite("${TESTSUITE}")'; \
84 @echo "${TEST_INTERFACE.${_T}}_test_program{name=\"${_T}\"}" \
87 .for _T in ${TESTS_SUBDIRS:N.WAIT}
88 @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.tmp
90 @mv Kyuafile.tmp Kyuafile
96 .if ${TESTSDIR} == ${TESTSBASE}
97 # Forbid running from ${TESTSBASE}. It can cause false positives/negatives and
98 # it does not cover all the tests (e.g. it misses testing software in external).
99 @echo "*** Sorry, you cannot use make test from src/tests. Install the"
100 @echo "*** tests into their final location and run them from ${TESTSBASE}"
103 @echo "*** Using this test does not preclude you from running the tests"
104 @echo "*** installed in ${TESTSBASE}. This test run may raise false"
105 @echo "*** positives and/or false negatives."
108 @echo "*** No TESTSDIR defined; nothing to do."
113 .if !target(realtest)
115 @echo "$@ not defined; skipping"
119 .ORDER: beforetest realtest
120 test: beforetest realtest
122 .if target(aftertest)
123 .ORDER: realtest aftertest
128 .include <bsd.subdir.mk>
131 .if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
132 .include <bsd.progs.mk>
134 .include <bsd.files.mk>
137 .include <bsd.obj.mk>