3 # You must include bsd.test.mk instead of this file from your Makefile.
5 # Logic to build and install ATF test programs; i.e. test programs linked
6 # against the ATF libraries.
8 .if !target(__<bsd.test.mk>__)
9 .error atf.test.mk cannot be included directly.
12 # List of C, C++ and shell test programs to build.
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.
18 # Test programs registered in this manner are set to be installed into TESTSDIR
19 # (which should be overridden by the Makefile) and are not required to provide a
27 .if !empty(ATF_TESTS_C)
28 PROGS+= ${ATF_TESTS_C}
29 _TESTS+= ${ATF_TESTS_C}
30 .for _T in ${ATF_TESTS_C}
31 BINDIR.${_T}= ${TESTSDIR}
34 DPADD.${_T}+= ${LIBATF_C}
35 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
36 LDADD.${_T}+= ${LDADD_atf_c}
38 LDADD.${_T}+= ${LIBATF_C}
40 TEST_INTERFACE.${_T}= atf
44 .if !empty(ATF_TESTS_CXX)
45 PROGS_CXX+= ${ATF_TESTS_CXX}
46 _TESTS+= ${ATF_TESTS_CXX}
47 .for _T in ${ATF_TESTS_CXX}
48 BINDIR.${_T}= ${TESTSDIR}
50 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
51 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
52 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
53 LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c}
55 LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
57 TEST_INTERFACE.${_T}= atf
59 # Silence warnings about usage of deprecated std::auto_ptr
60 CXXWARNFLAGS+= -Wno-deprecated-declarations
63 .if !empty(ATF_TESTS_SH)
64 SCRIPTS+= ${ATF_TESTS_SH}
65 _TESTS+= ${ATF_TESTS_SH}
66 .for _T in ${ATF_TESTS_SH}
67 SCRIPTSDIR_${_T}= ${TESTSDIR}
68 TEST_INTERFACE.${_T}= atf
69 CLEANFILES+= ${_T} ${_T}.tmp
70 # TODO(jmmv): It seems to me that this SED and SRC functionality should
71 # exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
72 # this proves to be useful within the tests.
73 ATF_TESTS_SH_SED_${_T}?= # empty
74 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
75 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
76 echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp
77 .if empty(ATF_TESTS_SH_SED_${_T})
78 cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
80 cat ${.ALLSRC:N*Makefile*} \
81 | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp
83 chmod +x ${.TARGET}.tmp
84 mv ${.TARGET}.tmp ${.TARGET}
88 .if !empty(ATF_TESTS_KSH93)
89 SCRIPTS+= ${ATF_TESTS_KSH93}
90 _TESTS+= ${ATF_TESTS_KSH93}
91 .for _T in ${ATF_TESTS_KSH93}
92 SCRIPTSDIR_${_T}= ${TESTSDIR}
93 TEST_INTERFACE.${_T}= atf
94 TEST_METADATA.${_T}+= required_programs="ksh93"
95 CLEANFILES+= ${_T} ${_T}.tmp
96 # TODO(jmmv): It seems to me that this SED and SRC functionality should
97 # exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
98 # this proves to be useful within the tests.
99 ATF_TESTS_KSH93_SED_${_T}?= # empty
100 ATF_TESTS_KSH93_SRC_${_T}?= ${_T}.sh
101 ${_T}: ${ATF_TESTS_KSH93_SRC_${_T}}
102 echo '#! /usr/libexec/atf-sh -s/usr/local/bin/ksh93' > ${.TARGET}.tmp
103 .if empty(ATF_TESTS_KSH93_SED_${_T})
104 cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
106 cat ${.ALLSRC:N*Makefile*} \
107 | sed ${ATF_TESTS_KSH93_SED_${_T}} >>${.TARGET}.tmp
109 chmod +x ${.TARGET}.tmp
110 mv ${.TARGET}.tmp ${.TARGET}
114 .if !empty(ATF_TESTS_PYTEST)
115 # bsd.prog.mk SCRIPTS interface removes file extension unless
116 # SCRIPTSNAME is set, which is not possible to do here.
117 # Workaround this by appending another extension (.xtmp) to the
118 # file name. Use separate loop to avoid dealing with explicitly
119 # stating expansion for each and every variable.
121 # ATF_TESTS_PYTEST -> contains list of files as is (test_something.py ..)
122 # _ATF_TESTS_PYTEST -> (test_something.py.xtmp ..)
124 # Former array is iterated to construct Kyuafile, where original file
125 # names need to be written.
126 # Latter array is iterated to enable bsd.prog.mk scripts framework -
127 # namely, installing scripts without .xtmp prefix. Note: this allows to
128 # not bother about the fact that make target needs to be different from
130 _TESTS+= ${ATF_TESTS_PYTEST}
132 .for _T in ${ATF_TESTS_PYTEST}
133 _ATF_TESTS_PYTEST += ${_T}.xtmp
134 TEST_INTERFACE.${_T}= atf
135 TEST_METADATA.${_T}+= required_programs="pytest"
138 SCRIPTS+= ${_ATF_TESTS_PYTEST}
139 .for _T in ${_ATF_TESTS_PYTEST}
140 SCRIPTSDIR_${_T}= ${TESTSDIR}
141 CLEANFILES+= ${_T} ${_T}.tmp
142 # TODO(jmmv): It seems to me that this SED and SRC functionality should
143 # exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
144 # this proves to be useful within the tests.
145 ATF_TESTS_PYTEST_SED_${_T}?= # empty
146 ATF_TESTS_PYTEST_SRC_${_T}?= ${.CURDIR}/${_T:S,.xtmp$,,}
148 echo "#! /usr/libexec/atf_pytest_wrapper -P ${TESTSBASE}" > ${.TARGET}.tmp
149 .if empty(ATF_TESTS_PYTEST_SED_${_T})
150 cat ${ATF_TESTS_PYTEST_SRC_${_T}} >>${.TARGET}.tmp
152 cat ${ATF_TESTS_PYTEST_SRC_${_T}} \
153 | sed ${ATF_TESTS_PYTEST_SED_${_T}} >>${.TARGET}.tmp
155 chmod +x ${.TARGET}.tmp
156 mv ${.TARGET}.tmp ${.TARGET}