]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/suite.test.mk
MF head @ r284358
[FreeBSD/FreeBSD.git] / share / mk / suite.test.mk
1 # $FreeBSD$
2 #
3 # You must include bsd.test.mk instead of this file from your Makefile.
4 #
5 # Internal glue for the build of /usr/tests/.
6
7 .if !target(__<bsd.test.mk>__)
8 .error suite.test.mk cannot be included directly.
9 .endif
10
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.
13 TESTSDIR?= .
14
15 # Name of the test suite these tests belong to.  Should rarely be changed for
16 # Makefiles built into the FreeBSD src tree.
17 TESTSUITE?= FreeBSD
18
19 # Knob to control the handling of the Kyuafile for this Makefile.
20 #
21 # If 'yes', a Kyuafile exists in the source tree and is installed into
22 # TESTSDIR.
23 #
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.
27 #
28 # If 'no', no Kyuafile is installed.
29 KYUAFILE?= auto
30
31 # Per-test program interface definition.
32 #
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
36
37 # Per-test program metadata properties as a list of key/value pairs.
38 #
39 # All the variables for a particular program are appended to the program's
40 # definition in the Kyuafile.  This feature can be used to avoid having to
41 # explicitly supply a Kyuafile in the source directory, allowing the caller
42 # Makefile to rely on the KYUAFILE=auto behavior defined here.
43 #TEST_METADATA.<test-program>+= key="value"
44
45 # Path to the prefix of the installed Kyua CLI, if any.
46 #
47 # If kyua is installed from ports, we automatically define a realregress target
48 # below to run the tests using this tool.  The tools are searched for in the
49 # hierarchy specified by this variable.
50 KYUA_PREFIX?= /usr/local
51
52 .if ${KYUAFILE:tl} == "yes"
53 FILES+= Kyuafile
54 FILESDIR_Kyuafile= ${TESTSDIR}
55
56 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
57 .elif ${KYUAFILE:tl} == "auto"
58 FILES+= Kyuafile.auto
59 FILESDIR_Kyuafile.auto= ${TESTSDIR}
60 FILESNAME_Kyuafile.auto= Kyuafile
61
62 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
63
64 .NOPATH: Kyuafile.auto
65 Kyuafile.auto: Makefile
66         @{ \
67             echo '-- Automatically generated by bsd.test.mk.'; \
68             echo; \
69             echo 'syntax(2)'; \
70             echo; \
71             echo 'test_suite("${TESTSUITE}")'; \
72             echo; \
73         } >Kyuafile.auto.tmp
74 .for _T in ${_TESTS}
75         @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
76             >>Kyuafile.auto.tmp
77 .endfor
78 .for _T in ${TESTS_SUBDIRS:N.WAIT}
79         @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.auto.tmp
80 .endfor
81         @mv Kyuafile.auto.tmp Kyuafile.auto
82 .endif
83
84 KYUA?= ${KYUA_PREFIX}/bin/kyua
85
86 _kyuafile=      ${DESTDIR}${TESTSDIR}/Kyuafile
87
88 realregress: .PHONY
89 .if exists(${KYUA})
90 # Definition of the "make test" target and supporting variables.
91 #
92 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
93 # host building a release for the same system).  The target runs Kyua, which is
94 # not in the toolchain, and the tests execute code built for the target host.
95 #
96 # Due to the dependencies of the binaries built by the source tree and how they
97 # are used by tests, it is highly possible for a execution of "make test" to
98 # report bogus results unless the new binaries are put in place.
99 realregress:
100         @${KYUA} test -k ${_kyuafile}
101 .endif
102
103 beforeregress: .PHONY
104 .if !defined(TESTSDIR)
105         @echo "*** No TESTSDIR defined; nothing to do."
106         @false
107 .endif