]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - share/mk/plain.test.mk
MFC r267176, r267181, r268445 (ATF-related commits):
[FreeBSD/stable/10.git] / share / mk / plain.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 plain test programs.  A plain test programs it not
6 # supposed to use any specific testing framework: all it does is run some code
7 # and report the test's pass or fail status via a 0 or 1 exit code.
8
9 .if !target(__<bsd.test.mk>__)
10 .error plain.test.mk cannot be included directly.
11 .endif
12
13 # List of C, C++ and shell test programs to build.
14 #
15 # Programs listed here are built according to the semantics of bsd.prog.mk for
16 # PROGS, PROGS_CXX and SCRIPTS, respectively.
17 #
18 # Test programs registered in this manner are set to be installed into TESTSDIR
19 # (which should be overriden by the Makefile) and are not required to provide a
20 # manpage.
21 PLAIN_TESTS_C?=
22 PLAIN_TESTS_CXX?=
23 PLAIN_TESTS_SH?=
24
25 .if !empty(PLAIN_TESTS_C)
26 PROGS+= ${PLAIN_TESTS_C}
27 _TESTS+= ${PLAIN_TESTS_C}
28 .for _T in ${PLAIN_TESTS_C}
29 BINDIR.${_T}= ${TESTSDIR}
30 MAN.${_T}?= # empty
31 SRCS.${_T}?= ${_T}.c
32 TEST_INTERFACE.${_T}= plain
33 .endfor
34 .endif
35
36 .if !empty(PLAIN_TESTS_CXX)
37 PROGS_CXX+= ${PLAIN_TESTS_CXX}
38 _TESTS+= ${PLAIN_TESTS_CXX}
39 .for _T in ${PLAIN_TESTS_CXX}
40 BINDIR.${_T}= ${TESTSDIR}
41 MAN.${_T}?= # empty
42 SRCS.${_T}?= ${_T}.cc
43 TEST_INTERFACE.${_T}= plain
44 .endfor
45 .endif
46
47 .if !empty(PLAIN_TESTS_SH)
48 SCRIPTS+= ${PLAIN_TESTS_SH}
49 _TESTS+= ${PLAIN_TESTS_SH}
50 .for _T in ${PLAIN_TESTS_SH}
51 SCRIPTSDIR_${_T}= ${TESTSDIR}
52 TEST_INTERFACE.${_T}= plain
53 CLEANFILES+= ${_T} ${_T}.tmp
54 # TODO(jmmv): It seems to me that this SED and SRC functionality should
55 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
56 # this proves to be useful within the tests.
57 PLAIN_TESTS_SH_SED_${_T}?= # empty
58 PLAIN_TESTS_SH_SRC_${_T}?= ${_T}.sh
59 ${_T}: ${PLAIN_TESTS_SH_SRC_${_T}}
60         cat ${.ALLSRC:N*Makefile*} \
61             | sed ${PLAIN_TESTS_SH_SED_${_T}} >${.TARGET}.tmp
62         chmod +x ${.TARGET}.tmp
63         mv ${.TARGET}.tmp ${.TARGET}
64 .endfor
65 .endif