3 # Logic to build and install ATF test programs; i.e. test programs linked
4 # against the ATF libraries.
8 # List of C, C++ and shell test programs to build.
10 # Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS,
11 # respectively, from bsd.prog.mk. However, the build rules are tweaked to
12 # require the ATF libraries.
14 # Test programs registered in this manner are set to be installed into TESTSDIR
15 # (which should be overriden by the Makefile) and are not required to provide a
21 # Whether to allow using the deprecated ATF tools or not.
23 # If 'yes', this file will generate Atffiles when requested and will also
24 # support using the deprecated atf-run tool to execute the tests.
25 ALLOW_DEPRECATED_ATF_TOOLS?= no
27 # Knob to control the handling of the Atffile for this Makefile.
29 # If 'yes', an Atffile exists in the source tree and is installed into
32 # If 'auto', an Atffile is automatically generated based on the list of test
33 # programs built by the Makefile and is installed into TESTSDIR. This is the
34 # default and is sufficient in the majority of the cases.
36 # If 'no', no Atffile is installed.
39 # Path to the prefix of the installed ATF tools, if any.
41 # If atf-run and atf-report are installed from ports, we automatically define a
42 # realtest target below to run the tests using these tools. The tools are
43 # searched for in the hierarchy specified by this variable.
44 ATF_PREFIX?= /usr/local
46 # C compiler passed to ATF tests that need to build code.
47 ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc
48 TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC}
50 # C preprocessor passed to ATF tests that need to build code.
51 ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp
52 TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP}
54 # C++ compiler passed to ATF tests that need to build code.
55 ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++
56 TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX}
58 # Shell interpreter used to run atf-sh(1) based tests.
59 ATF_SHELL?= ${DESTDIR}/bin/sh
60 TESTS_ENV+= ATF_SHELL=${ATF_SHELL}
62 .if !empty(ATF_TESTS_C)
63 PROGS+= ${ATF_TESTS_C}
64 _TESTS+= ${ATF_TESTS_C}
65 .for _T in ${ATF_TESTS_C}
66 BINDIR.${_T}= ${TESTSDIR}
69 DPADD.${_T}+= ${LIBATF_C}
71 TEST_INTERFACE.${_T}= atf
75 .if !empty(ATF_TESTS_CXX)
76 PROGS_CXX+= ${ATF_TESTS_CXX}
77 _TESTS+= ${ATF_TESTS_CXX}
78 .for _T in ${ATF_TESTS_CXX}
79 BINDIR.${_T}= ${TESTSDIR}
81 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
82 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
83 LDADD.${_T}+= -latf-c++ -latf-c
84 TEST_INTERFACE.${_T}= atf
88 .if !empty(ATF_TESTS_SH)
89 SCRIPTS+= ${ATF_TESTS_SH}
90 _TESTS+= ${ATF_TESTS_SH}
91 .for _T in ${ATF_TESTS_SH}
92 SCRIPTSDIR_${_T}= ${TESTSDIR}
93 TEST_INTERFACE.${_T}= atf
94 CLEANFILES+= ${_T} ${_T}.tmp
95 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
96 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
97 echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp
98 cat ${.ALLSRC} >> ${.TARGET}.tmp
99 chmod +x ${.TARGET}.tmp
100 mv ${.TARGET}.tmp ${.TARGET}
104 .if ${ALLOW_DEPRECATED_ATF_TOOLS} != "no"
106 .if ${ATFFILE:tl} != "no"
108 FILESDIR_Atffile= ${TESTSDIR}
110 .if ${ATFFILE:tl} == "auto"
111 CLEANFILES+= Atffile Atffile.tmp
114 @{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \
116 echo '# Automatically generated by atf-test.mk.'; \
118 echo 'prop: test-suite = "'${TESTSUITE}'"'; \
120 for tp in ${ATF_TESTS_C} ${ATF_TESTS_CXX} ${ATF_TESTS_SH} \
125 @mv Atffile.tmp Atffile
129 ATF_REPORT?= ${ATF_PREFIX}/bin/atf-report
130 ATF_RUN?= ${ATF_PREFIX}/bin/atf-run
131 .if exists(${ATF_RUN}) && exists(${ATF_REPORT})
132 # Definition of the "make test" target and supporting variables.
134 # This target, by necessity, can only work for native builds (i.e. a freeBSD
135 # host building a release for the same system). The target runs ATF, which is
136 # not in the toolchain, and the tests execute code built for the target host.
138 # Due to the dependencies of the binaries built by the source tree and how they
139 # are used by tests, it is highly possible for a execution of "make test" to
140 # report bogus results unless the new binaries are put in place.
141 _TESTS_FIFO= ${.OBJDIR}/atf-run.fifo
142 _TESTS_LOG= ${.OBJDIR}/atf-run.log
143 CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG}
146 if [ -z "${TESTSDIR}" ]; then \
147 echo "*** No TESTSDIR defined; nothing to do."; \
150 cd ${DESTDIR}${TESTSDIR}; \
151 rm -f ${_TESTS_FIFO}; \
152 mkfifo ${_TESTS_FIFO}; \
153 tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \
155 ${TESTS_ENV} ${ATF_RUN} >> ${_TESTS_FIFO}; \
158 rm -f ${_TESTS_FIFO}; \
160 echo "*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \
162 echo "*** WARNING: atf-run is deprecated; please install kyua instead"; \
168 .include <bsd.test.mk>