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