]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - share/mk/atf.test.mk
MFC r286822:
[FreeBSD/stable/10.git] / share / mk / atf.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 ATF test programs; i.e. test programs linked
6 # against the ATF libraries.
7
8 .if !target(__<bsd.test.mk>__)
9 .error atf.test.mk cannot be included directly.
10 .endif
11
12 # List of C, C++ and shell test programs to build.
13 #
14 # Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS,
15 # respectively, from bsd.prog.mk.  However, the build rules are tweaked to
16 # require the ATF libraries.
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 ATF_TESTS_C?=
22 ATF_TESTS_CXX?=
23 ATF_TESTS_SH?=
24
25 # Path to the prefix of the installed ATF tools, if any.
26 #
27 # If atf-run and atf-report are installed from ports, we automatically define a
28 # realregress target below to run the tests using these tools.  The tools are
29 # searched for in the hierarchy specified by this variable.
30 ATF_PREFIX?= /usr/local
31
32 # C compiler passed to ATF tests that need to build code.
33 ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc
34 TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC}
35
36 # C preprocessor passed to ATF tests that need to build code.
37 ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp
38 TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP}
39
40 # C++ compiler passed to ATF tests that need to build code.
41 ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++
42 TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX}
43
44 # Shell interpreter used to run atf-sh(1) based tests.
45 ATF_SHELL?= ${DESTDIR}/bin/sh
46 TESTS_ENV+= ATF_SHELL=${ATF_SHELL}
47
48 .if !empty(ATF_TESTS_C)
49 PROGS+= ${ATF_TESTS_C}
50 _TESTS+= ${ATF_TESTS_C}
51 .for _T in ${ATF_TESTS_C}
52 BINDIR.${_T}= ${TESTSDIR}
53 MAN.${_T}?= # empty
54 SRCS.${_T}?= ${_T}.c
55 DPADD.${_T}+= ${LIBATF_C}
56 LDADD.${_T}+= -latf-c
57 USEPRIVATELIB+= atf-c
58 TEST_INTERFACE.${_T}= atf
59 .endfor
60 .endif
61
62 .if !empty(ATF_TESTS_CXX)
63 PROGS_CXX+= ${ATF_TESTS_CXX}
64 _TESTS+= ${ATF_TESTS_CXX}
65 .for _T in ${ATF_TESTS_CXX}
66 BINDIR.${_T}= ${TESTSDIR}
67 MAN.${_T}?= # empty
68 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
69 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
70 LDADD.${_T}+= -latf-c++ -latf-c
71 USEPRIVATELIB+= atf-c++
72 TEST_INTERFACE.${_T}= atf
73 .endfor
74 .endif
75
76 .if !empty(ATF_TESTS_SH)
77 SCRIPTS+= ${ATF_TESTS_SH}
78 _TESTS+= ${ATF_TESTS_SH}
79 .for _T in ${ATF_TESTS_SH}
80 SCRIPTSDIR_${_T}= ${TESTSDIR}
81 TEST_INTERFACE.${_T}= atf
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 ATF_TESTS_SH_SED_${_T}?= # empty
87 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
88 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
89         echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp
90 .if empty(ATF_TESTS_SH_SED_${_T})
91         cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
92 .else
93         cat ${.ALLSRC:N*Makefile*} \
94             | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp
95 .endif
96         chmod +x ${.TARGET}.tmp
97         mv ${.TARGET}.tmp ${.TARGET}
98 .endfor
99 .endif