]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - share/mk/tap.test.mk
MFC r267176, r267181, r268445 (ATF-related commits):
[FreeBSD/stable/10.git] / share / mk / tap.test.mk
1 # $FreeBSD$
2 #
3 # You must include bsd.test.mk instead of this file from your Makefile.
4 #
5 # Logic to build and install TAP-compliant test programs.
6 #
7 # This is provided to support existing tests in the FreeBSD source tree
8 # (particularly those coming from tools/regression/) that comply with the
9 # Test Anything Protocol.  It should not be used for new tests.
10
11 .if !target(__<bsd.test.mk>__)
12 .error tap.test.mk cannot be included directly.
13 .endif
14
15 # List of C, C++ and shell test programs to build.
16 #
17 # Programs listed here are built according to the semantics of bsd.prog.mk for
18 # PROGS, PROGS_CXX and SCRIPTS, respectively.
19 #
20 # Test programs registered in this manner are set to be installed into TESTSDIR
21 # (which should be overriden by the Makefile) and are not required to provide a
22 # manpage.
23 TAP_TESTS_C?=
24 TAP_TESTS_CXX?=
25 TAP_TESTS_PERL?=
26 TAP_TESTS_SH?=
27
28 # Perl interpreter to use for test programs written in this language.
29 TAP_PERL_INTERPRETER?= /usr/local/bin/perl
30
31 .if !empty(TAP_TESTS_C)
32 PROGS+= ${TAP_TESTS_C}
33 _TESTS+= ${TAP_TESTS_C}
34 .for _T in ${TAP_TESTS_C}
35 BINDIR.${_T}= ${TESTSDIR}
36 MAN.${_T}?= # empty
37 SRCS.${_T}?= ${_T}.c
38 TEST_INTERFACE.${_T}= tap
39 .endfor
40 .endif
41
42 .if !empty(TAP_TESTS_CXX)
43 PROGS_CXX+= ${TAP_TESTS_CXX}
44 _TESTS+= ${TAP_TESTS_CXX}
45 .for _T in ${TAP_TESTS_CXX}
46 BINDIR.${_T}= ${TESTSDIR}
47 MAN.${_T}?= # empty
48 SRCS.${_T}?= ${_T}.cc
49 TEST_INTERFACE.${_T}= tap
50 .endfor
51 .endif
52
53 .if !empty(TAP_TESTS_PERL)
54 SCRIPTS+= ${TAP_TESTS_PERL}
55 _TESTS+= ${TAP_TESTS_PERL}
56 .for _T in ${TAP_TESTS_PERL}
57 SCRIPTSDIR_${_T}= ${TESTSDIR}
58 TEST_INTERFACE.${_T}= tap
59 TEST_METADATA.${_T}+= required_programs="${TAP_PERL_INTERPRETER}"
60 CLEANFILES+= ${_T} ${_T}.tmp
61 # TODO(jmmv): It seems to me that this SED and SRC functionality should
62 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
63 # this proves to be useful within the tests.
64 TAP_TESTS_PERL_SED_${_T}?= # empty
65 TAP_TESTS_PERL_SRC_${_T}?= ${_T}.pl
66 ${_T}: ${TAP_TESTS_PERL_SRC_${_T}}
67         { \
68             echo '#! ${TAP_PERL_INTERPRETER}'; \
69             cat ${.ALLSRC:N*Makefile*} | sed ${TAP_TESTS_PERL_SED_${_T}}; \
70         } >${.TARGET}.tmp
71         chmod +x ${.TARGET}.tmp
72         mv ${.TARGET}.tmp ${.TARGET}
73 .endfor
74 .endif
75
76 .if !empty(TAP_TESTS_SH)
77 SCRIPTS+= ${TAP_TESTS_SH}
78 _TESTS+= ${TAP_TESTS_SH}
79 .for _T in ${TAP_TESTS_SH}
80 SCRIPTSDIR_${_T}= ${TESTSDIR}
81 TEST_INTERFACE.${_T}= tap
82 CLEANFILES+= ${_T} ${_T}.tmp
83 # TODO(jmmv): It seems to me that this SED and SRC functionality should
84 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
85 # this proves to be useful within the tests.
86 TAP_TESTS_SH_SED_${_T}?= # empty
87 TAP_TESTS_SH_SRC_${_T}?= ${_T}.sh
88 ${_T}: ${TAP_TESTS_SH_SRC_${_T}}
89         cat ${.ALLSRC} | sed ${TAP_TESTS_SH_SED_${_T}} >${.TARGET}.tmp
90         chmod +x ${.TARGET}.tmp
91         mv ${.TARGET}.tmp ${.TARGET}
92 .endfor
93 .endif