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 .include <bsd.opts.mk>
13 # Name of the test suite these tests belong to. Should rarely be changed for
14 # Makefiles built into the FreeBSD src tree.
17 # Knob to control the handling of the Kyuafile for this Makefile.
19 # If 'yes', a Kyuafile exists in the source tree and is installed into
22 # If 'auto', a Kyuafile is automatically generated based on the list of test
23 # programs built by the Makefile and is installed into TESTSDIR. This is the
24 # default and is sufficient in the majority of the cases.
26 # If 'no', no Kyuafile is installed.
29 # Per-test program interface definition.
31 # The name provided here must match one of the interface names supported by
32 # Kyua as this is later encoded in the Kyuafile test program definitions.
33 #TEST_INTERFACE.<test-program>= interface-name
35 # Metadata properties applicable to all test programs.
37 # All the variables for a test program defined in the Makefile are appended
38 # to the test program's definition in the Kyuafile. This feature can be
39 # used to avoid having to explicitly supply a Kyuafile in the source
40 # directory, allowing the caller Makefile to rely on the KYUAFILE=auto
41 # behavior defined here.
42 #TEST_METADATA+= key="value"
44 # Per-test program metadata properties as a list of key/value pairs.
46 # These per-test program settings _extend_ the values provided in the
47 # unqualified TEST_METADATA variable.
48 #TEST_METADATA.<test-program>+= key="value"
50 .if ${KYUAFILE:tl} != "no"
51 ${PACKAGE}FILES+= Kyuafile
52 ${PACKAGE}FILESDIR_Kyuafile= ${TESTSDIR}
56 _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}}
59 .if ${KYUAFILE:tl} == "auto"
60 CLEANFILES+= Kyuafile Kyuafile.tmp
63 echo '-- Automatically generated by bsd.test.mk.'; \
67 echo 'test_suite("${TESTSUITE}")'; \
71 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
74 .for _T in ${TESTS_SUBDIRS:N.WAIT}
75 @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp
77 @mv ${.TARGET}.tmp ${.TARGET}
80 KYUA= ${LOCALBASE}/bin/kyua
82 # Definition of the "make check" target and supporting variables.
84 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
85 # host building a release for the same system). The target runs Kyua, which is
86 # not in the toolchain, and the tests execute code built for the target host.
88 # Due to the dependencies of the binaries built by the source tree and how they
89 # are used by tests, it is highly possible for a execution of "make test" to
90 # report bogus results unless the new binaries are put in place.
93 @if [ ! -x ${KYUA} ]; then \
95 echo "kyua binary not installed at expected location (${.TARGET})"; \
97 echo "Please install via pkg install, or specify the path to the kyua"; \
98 echo "package via the \$${LOCALBASE} variable, e.g. "; \
99 echo "LOCALBASE=\"${LOCALBASE}\""; \
102 @env ${TESTS_ENV:Q} ${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile
104 MAKE_CHECK_SANDBOX_DIR= checkdir
105 CLEANDIRS+= ${MAKE_CHECK_SANDBOX_DIR}
107 .if ${MK_MAKE_CHECK_USE_SANDBOX} != "no" && make(check)
108 DESTDIR:= ${.OBJDIR}/${MAKE_CHECK_SANDBOX_DIR}
111 .for t in clean depend all
112 @cd ${.CURDIR} && ${MAKE} $t
114 @cd ${SRCTOP} && ${MAKE} hierarchy DESTDIR=${DESTDIR}
115 @cd ${.CURDIR} && ${MAKE} install \
118 # NOTE: this is intentional to ensure that "make check" can be run multiple
119 # times. "aftercheck" won't be run if "make check" fails, is interrupted,
122 @cd ${.CURDIR} && ${MAKE} clean
123 @test ! -e ${DESTDIR} || chflags -R 0 "${DESTDIR}"