]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/suite.test.mk
Copy bin/ls/tests from ^/head
[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 # Metadata properties applicable to all test programs.
38 #
39 # All the variables for a test program defined in the Makefile are appended
40 # to the test program's definition in the Kyuafile.  This feature can be
41 # used to avoid having to explicitly supply a Kyuafile in the source
42 # directory, allowing the caller Makefile to rely on the KYUAFILE=auto
43 # behavior defined here.
44 #TEST_METADATA+= key="value"
45
46 # Per-test program metadata properties as a list of key/value pairs.
47 #
48 # These per-test program settings _extend_ the values provided in the
49 # unqualified TEST_METADATA variable.
50 #TEST_METADATA.<test-program>+= key="value"
51
52 # Path to the prefix of the installed Kyua CLI, if any.
53 #
54 # If kyua is installed from ports, we automatically define a realregress target
55 # below to run the tests using this tool.  The tools are searched for in the
56 # hierarchy specified by this variable.
57 KYUA_PREFIX?= /usr/local
58
59 .if ${KYUAFILE:tl} == "yes"
60 FILES+= Kyuafile
61 FILESDIR_Kyuafile= ${TESTSDIR}
62
63 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
64 .elif ${KYUAFILE:tl} == "auto"
65 FILES+= Kyuafile.auto
66 FILESDIR_Kyuafile.auto= ${TESTSDIR}
67 FILESNAME_Kyuafile.auto= Kyuafile
68
69 CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp
70
71 .for _T in ${_TESTS}
72 _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}}
73 .endfor
74
75 .NOPATH: Kyuafile.auto
76 Kyuafile.auto: Makefile
77         @{ \
78             echo '-- Automatically generated by bsd.test.mk.'; \
79             echo; \
80             echo 'syntax(2)'; \
81             echo; \
82             echo 'test_suite("${TESTSUITE}")'; \
83             echo; \
84         } >Kyuafile.auto.tmp
85 .for _T in ${_TESTS}
86         @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
87             >>Kyuafile.auto.tmp
88 .endfor
89 .for _T in ${TESTS_SUBDIRS:N.WAIT}
90         @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.auto.tmp
91 .endfor
92         @mv Kyuafile.auto.tmp Kyuafile.auto
93 .endif
94
95 KYUA?= ${KYUA_PREFIX}/bin/kyua
96
97 _kyuafile=      ${DESTDIR}${TESTSDIR}/Kyuafile
98
99 realregress: .PHONY
100 .if exists(${KYUA})
101 # Definition of the "make test" target and supporting variables.
102 #
103 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
104 # host building a release for the same system).  The target runs Kyua, which is
105 # not in the toolchain, and the tests execute code built for the target host.
106 #
107 # Due to the dependencies of the binaries built by the source tree and how they
108 # are used by tests, it is highly possible for a execution of "make test" to
109 # report bogus results unless the new binaries are put in place.
110 realregress:
111         @${KYUA} test -k ${_kyuafile}
112 .endif
113
114 beforeregress: .PHONY
115 .if !defined(TESTSDIR)
116         @echo "*** No TESTSDIR defined; nothing to do."
117         @false
118 .endif