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 variables to pass to the tests at run-time via the environment.
51 # Ordered list of directories to construct the PATH for the tests.
52 TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
53 ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
54 TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
56 # Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
57 TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
58 TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
60 # List of all tests being built. This variable is internal should not be
61 # defined by the Makefile. The various *.test.mk modules extend this variable
65 .if !empty(TESTS_SUBDIRS)
66 SUBDIR+= ${TESTS_SUBDIRS}
69 # it is rare for test cases to have man pages
75 # tell progs.mk we might want to install things
77 PROGS_TARGETS+= install
79 .if ${KYUAFILE:tl} != "no"
81 FILESDIR_Kyuafile= ${TESTSDIR}
83 .if ${KYUAFILE:tl} == "auto"
84 CLEANFILES+= Kyuafile Kyuafile.tmp
88 echo '-- Automatically generated by bsd.test.mk.'; \
92 echo 'test_suite("${TESTSUITE}")'; \
96 @echo "${TEST_INTERFACE.${_T}}_test_program{name=\"${_T}\"}" \
99 .for _T in ${TESTS_SUBDIRS:N.WAIT}
100 @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.tmp
102 @mv Kyuafile.tmp Kyuafile
107 .if defined(TESTSDIR)
108 .if ${TESTSDIR} == ${TESTSBASE}
109 # Forbid running from ${TESTSBASE}. It can cause false positives/negatives and
110 # it does not cover all the tests (e.g. it misses testing software in external).
111 @echo "*** Sorry, you cannot use make test from src/tests. Install the"
112 @echo "*** tests into their final location and run them from ${TESTSBASE}"
115 @echo "*** Using this test does not preclude you from running the tests"
116 @echo "*** installed in ${TESTSBASE}. This test run may raise false"
117 @echo "*** positives and/or false negatives."
120 @echo "*** No TESTSDIR defined; nothing to do."
125 .if !target(realtest)
127 @echo "$@ not defined; skipping"
131 .ORDER: beforetest realtest
132 test: beforetest realtest
134 .if target(aftertest)
135 .ORDER: realtest aftertest
140 .include <bsd.subdir.mk>
143 .if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
144 .include <bsd.progs.mk>
146 .include <bsd.files.mk>
149 .include <bsd.obj.mk>