# $NetBSD$ # $FreeBSD$ # .include ATF_TESTS:= .if make(*test) TESTSDIR?= . .endif .if defined(ATF_TESTS_SUBDIRS) # Only visit subdirs when building, etc because ATF does this it on its own. .if !make(atf-test) SUBDIR+= ${ATF_TESTS_SUBDIRS} .endif ATF_TESTS+= ${ATF_TESTS_SUBDIRS} .include .endif .if defined(TESTS_C) ATF_TESTS+= ${TESTS_C} .for _T in ${TESTS_C} SRCS.${_T}?= ${_T}.c DPADD.${_T}+= ${LIBATF_C} LDADD.${_T}+= -latf-c .endfor .endif .if defined(TESTS_CXX) ATF_TESTS+= ${TESTS_CXX} .for _T in ${TESTS_CXX} SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc} DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} LDADD.${_T}+= -latf-c++ -latf-c .endfor .endif .if defined(TESTS_SH) ATF_TESTS+= ${TESTS_SH} .for _T in ${TESTS_SH} CLEANFILES+= ${_T} ${_T}.tmp TESTS_SH_SRC_${_T}?= ${_T}.sh ${_T}: ${TESTS_SH_SRC_${_T}} echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp cat ${.ALLSRC} >> ${.TARGET}.tmp chmod +x ${.TARGET}.tmp mv ${.TARGET}.tmp ${.TARGET} .endfor .endif ATFFILE?= auto .if ${ATFFILE:tl} != "no" FILES+= Atffile FILESDIR_Atffile= ${TESTSDIR} .if ${ATFFILE:tl} == "auto" CLEANFILES+= Atffile Atffile.tmp Atffile: Makefile @{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \ echo; \ echo '# Automatically generated by atf-test.mk.'; \ echo; \ echo 'prop: test-suite = "'`uname -o`'"'; \ echo; \ for tp in ${ATF_TESTS}; do \ echo "tp: $${tp}"; \ done; } >Atffile.tmp @mv Atffile.tmp Atffile .endif .endif # Generate support variables for atf-test. # # atf-test can only work for native builds, i.e. a build host of a particular # OS building a release for the same OS version and architecture. The target # runs ATF, which is on the build host, and the tests execute code built for # the target host. # # Due to the dependencies of the binaries built by the source tree and how they # are used by tests, it is highly possible for a execution of "make test" to # report bogus results unless the new binaries are put in place. # XXX (gcooper): Executing ATF from outside the source tree is improper; it # should be built as part of the OS toolchain build for the host OS and # executed from there. ATF_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin TESTS_ENV+= PATH=${ATF_PATH:ts:}:${PATH} ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++ ATF_CONFDIR?= ${DESTDIR}/etc ATF_INCLUDEDIR?= ${DESTDIR}/usr/include ATF_LIBDIR?= ${DESTDIR}/usr/lib ATF_LIBEXECDIR?= ${DESTDIR}/usr/libexec ATF_PKGDATADIR?= ${DESTDIR}/usr/share/atf ATF_SHELL?= ${DESTDIR}/bin/sh LD_LIBRARY_PATH?= ${TESTS_LD_LIBRARY_PATH:tW:S/ /:/g} ATF_ENV_VARS= \ ATF_BUILD_CC \ ATF_BUILD_CPP \ ATF_BUILD_CXX \ ATF_CONFDIR \ ATF_INCLUDEDIR \ ATF_LIBDIR \ ATF_LIBEXECDIR \ ATF_PKGDATADIR \ ATF_SHELL \ .for v in ${ATF_ENV_VARS} .if !empty($v) TESTS_ENV+= $v=${$v} .endif .endfor _TESTS_FIFO= ${.OBJDIR}/atf-run.fifo _TESTS_LOG= ${.OBJDIR}/atf-run.log CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG} ATF_BIN?= ${DESTDIR}/usr/bin ATF_REPORT?= ${ATF_BIN}/atf-report ATF_RUN?= ${ATF_BIN}/atf-run .PHONY: realtest realtest: .if defined(TESTSDIR) @set -e; \ cd ${DESTDIR}${TESTSDIR}; \ rm -f ${_TESTS_FIFO}; \ mkfifo ${_TESTS_FIFO}; \ tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \ set +e; \ ${TESTS_ENV} ${ATF_RUN} >> ${_TESTS_FIFO}; \ result=$${?}; \ wait; \ rm -f ${_TESTS_FIFO}; \ echo; \ echo "*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \ exit $${result} .endif .include