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
26 .if !empty(ATF_TESTS_C)
27 PROGS+= ${ATF_TESTS_C}
28 _TESTS+= ${ATF_TESTS_C}
29 .for _T in ${ATF_TESTS_C}
30 BINDIR.${_T}= ${TESTSDIR}
33 DPADD.${_T}+= ${LIBATF_C}
34 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
35 LDADD.${_T}+= ${LDADD_atf_c}
37 LDADD.${_T}+= ${LIBATF_C}
39 TEST_INTERFACE.${_T}= atf
43 .if !empty(ATF_TESTS_CXX)
44 PROGS_CXX+= ${ATF_TESTS_CXX}
45 _TESTS+= ${ATF_TESTS_CXX}
46 .for _T in ${ATF_TESTS_CXX}
47 BINDIR.${_T}= ${TESTSDIR}
49 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
50 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
51 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
52 LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c}
54 LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
56 TEST_INTERFACE.${_T}= atf
60 .if !empty(ATF_TESTS_SH)
61 SCRIPTS+= ${ATF_TESTS_SH}
62 _TESTS+= ${ATF_TESTS_SH}
63 .for _T in ${ATF_TESTS_SH}
64 SCRIPTSDIR_${_T}= ${TESTSDIR}
65 TEST_INTERFACE.${_T}= atf
66 CLEANFILES+= ${_T} ${_T}.tmp
67 # TODO(jmmv): It seems to me that this SED and SRC functionality should
68 # exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
69 # this proves to be useful within the tests.
70 ATF_TESTS_SH_SED_${_T}?= # empty
71 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
72 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
73 echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp
74 .if empty(ATF_TESTS_SH_SED_${_T})
75 cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
77 cat ${.ALLSRC:N*Makefile*} \
78 | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp
80 chmod +x ${.TARGET}.tmp
81 mv ${.TARGET}.tmp ${.TARGET}
85 .if !empty(ATF_TESTS_KSH93)
86 SCRIPTS+= ${ATF_TESTS_KSH93}
87 _TESTS+= ${ATF_TESTS_KSH93}
88 .for _T in ${ATF_TESTS_KSH93}
89 SCRIPTSDIR_${_T}= ${TESTSDIR}
90 TEST_INTERFACE.${_T}= atf
91 TEST_METADATA.${_T}+= required_programs="ksh93"
92 CLEANFILES+= ${_T} ${_T}.tmp
93 # TODO(jmmv): It seems to me that this SED and SRC functionality should
94 # exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
95 # this proves to be useful within the tests.
96 ATF_TESTS_KSH93_SED_${_T}?= # empty
97 ATF_TESTS_KSH93_SRC_${_T}?= ${_T}.sh
98 ${_T}: ${ATF_TESTS_KSH93_SRC_${_T}}
99 echo '#! /usr/libexec/atf-sh -s/usr/local/bin/ksh93' > ${.TARGET}.tmp
100 .if empty(ATF_TESTS_KSH93_SED_${_T})
101 cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
103 cat ${.ALLSRC:N*Makefile*} \
104 | sed ${ATF_TESTS_KSH93_SED_${_T}} >>${.TARGET}.tmp
106 chmod +x ${.TARGET}.tmp
107 mv ${.TARGET}.tmp ${.TARGET}