Plug atf-run into the 'test' target.

If atf-run exists in ATF_PREFIX and if ALLOW_DEPRECATED_ATF_TOOLS has
been set to yes, the test target is automatically defined to use it
for the execution of test programs.

Submitted by:	Julio Merino jmmv google.com
MFC after:	2 weeks
This commit is contained in:
Rui Paulo 2013-10-19 06:51:34 +00:00
parent 25b6a535fa
commit 30cc088dc0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=256764
2 changed files with 72 additions and 0 deletions

View File

@ -36,6 +36,29 @@ ALLOW_DEPRECATED_ATF_TOOLS?= no
# If 'no', no Atffile is installed.
ATFFILE?= auto
# Path to the prefix of the installed ATF tools, if any.
#
# If atf-run and atf-report are installed from ports, we automatically define a
# realtest target below to run the tests using these tools. The tools are
# searched for in the hierarchy specified by this variable.
ATF_PREFIX?= /usr/local
# C compiler passed to ATF tests that need to build code.
ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc
TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC}
# C preprocessor passed to ATF tests that need to build code.
ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp
TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP}
# C++ compiler passed to ATF tests that need to build code.
ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++
TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX}
# Shell interpreter used to run atf-sh(1) based tests.
ATF_SHELL?= ${DESTDIR}/bin/sh
TESTS_ENV+= ATF_SHELL=${ATF_SHELL}
.if !empty(ATF_TESTS_C)
PROGS+= ${ATF_TESTS_C}
_TESTS+= ${ATF_TESTS_C}
@ -104,6 +127,43 @@ Atffile: Makefile
.endif
.endif
ATF_REPORT?= ${ATF_PREFIX}/bin/atf-report
ATF_RUN?= ${ATF_PREFIX}/bin/atf-run
.if exists(${ATF_RUN}) && exists(${ATF_REPORT})
# Definition of the "make test" target and supporting variables.
#
# This target, by necessity, can only work for native builds (i.e. a freeBSD
# host building a release for the same system). The target runs ATF, which is
# not in the toolchain, 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.
_TESTS_FIFO= ${.OBJDIR}/atf-run.fifo
_TESTS_LOG= ${.OBJDIR}/atf-run.log
CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG}
realtest: .PHONY
@set -e; \
if [ -z "${TESTSDIR}" ]; then \
echo "*** No TESTSDIR defined; nothing to do."; \
exit 0; \
fi; \
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}"; \
echo "***"; \
echo "*** WARNING: atf-run is deprecated; please install kyua instead"; \
exit $${result}
.endif
.endif
.include <bsd.test.mk>

View File

@ -45,6 +45,18 @@ TESTS_SUBDIRS?=
# If 'no', no Kyuafile is installed.
KYUAFILE?= auto
# List of variables to pass to the tests at run-time via the environment.
TESTS_ENV?=
# Ordered list of directories to construct the PATH for the tests.
TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
# List of all tests being built. This variable is internal should not be
# defined by the Makefile. The various *.test.mk modules extend this variable
# as needed.