]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/suite.test.mk
Update clang to trunk r256633.
[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 # Name of the test suite these tests belong to.  Should rarely be changed for
12 # Makefiles built into the FreeBSD src tree.
13 TESTSUITE?= FreeBSD
14
15 # Knob to control the handling of the Kyuafile for this Makefile.
16 #
17 # If 'yes', a Kyuafile exists in the source tree and is installed into
18 # TESTSDIR.
19 #
20 # If 'auto', a Kyuafile is automatically generated based on the list of test
21 # programs built by the Makefile and is installed into TESTSDIR.  This is the
22 # default and is sufficient in the majority of the cases.
23 #
24 # If 'no', no Kyuafile is installed.
25 KYUAFILE?= auto
26
27 # Per-test program interface definition.
28 #
29 # The name provided here must match one of the interface names supported by
30 # Kyua as this is later encoded in the Kyuafile test program definitions.
31 #TEST_INTERFACE.<test-program>= interface-name
32
33 # Metadata properties applicable to all test programs.
34 #
35 # All the variables for a test program defined in the Makefile are appended
36 # to the test program's definition in the Kyuafile.  This feature can be
37 # used to avoid having to explicitly supply a Kyuafile in the source
38 # directory, allowing the caller Makefile to rely on the KYUAFILE=auto
39 # behavior defined here.
40 #TEST_METADATA+= key="value"
41
42 # Per-test program metadata properties as a list of key/value pairs.
43 #
44 # These per-test program settings _extend_ the values provided in the
45 # unqualified TEST_METADATA variable.
46 #TEST_METADATA.<test-program>+= key="value"
47
48 .if ${KYUAFILE:tl} != "no"
49 FILES+= Kyuafile
50 FILESDIR_Kyuafile= ${TESTSDIR}
51 .endif
52
53 .if ${KYUAFILE:tl} == "auto"
54 CLEANFILES+= Kyuafile Kyuafile.tmp
55 .endif
56
57 .for _T in ${_TESTS}
58 _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}}
59 .endfor
60
61 .if ${KYUAFILE:tl} == "auto"
62 Kyuafile: Makefile
63         @{ \
64             echo '-- Automatically generated by bsd.test.mk.'; \
65             echo; \
66             echo 'syntax(2)'; \
67             echo; \
68             echo 'test_suite("${TESTSUITE}")'; \
69             echo; \
70         } > ${.TARGET}.tmp
71 .for _T in ${_TESTS}
72         @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
73             >>${.TARGET}.tmp
74 .endfor
75 .for _T in ${TESTS_SUBDIRS:N.WAIT}
76         @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp
77 .endfor
78         @mv ${.TARGET}.tmp ${.TARGET}
79 .endif
80
81 KYUA= ${LOCALBASE}/bin/kyua
82 .if exists(${KYUA})
83 # Definition of the "make test" target and supporting variables.
84 #
85 # This target, by necessity, can only work for native builds (i.e. a FreeBSD
86 # host building a release for the same system).  The target runs Kyua, which is
87 # not in the toolchain, and the tests execute code built for the target host.
88 #
89 # Due to the dependencies of the binaries built by the source tree and how they
90 # are used by tests, it is highly possible for a execution of "make test" to
91 # report bogus results unless the new binaries are put in place.
92 realtest: .PHONY
93         @echo "*** WARNING: make test is experimental"
94         @echo "***"
95         @echo "*** Using this test does not preclude you from running the tests"
96         @echo "*** installed in ${TESTSBASE}.  This test run may raise false"
97         @echo "*** positives and/or false negatives."
98         @echo
99         @${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \
100         result=0; \
101         echo; \
102         echo "*** Once again, note that "make test" is unsupported."; \
103         test $${result} -eq 0
104 .endif
105
106 beforetest: .PHONY
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}"
113         @false
114 .else
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."
118 .endif
119 .else
120         @echo "*** No TESTSDIR defined; nothing to do."
121         @false
122 .endif
123         @echo