Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Oct 2013 06:51:35 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r256764 - head/share/mk
Message-ID:  <201310190651.r9J6pZ2j038490@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Sat Oct 19 06:51:34 2013
New Revision: 256764
URL: http://svnweb.freebsd.org/changeset/base/256764

Log:
  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

Modified:
  head/share/mk/atf.test.mk
  head/share/mk/bsd.test.mk

Modified: head/share/mk/atf.test.mk
==============================================================================
--- head/share/mk/atf.test.mk	Sat Oct 19 06:50:56 2013	(r256763)
+++ head/share/mk/atf.test.mk	Sat Oct 19 06:51:34 2013	(r256764)
@@ -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>

Modified: head/share/mk/bsd.test.mk
==============================================================================
--- head/share/mk/bsd.test.mk	Sat Oct 19 06:50:56 2013	(r256763)
+++ head/share/mk/bsd.test.mk	Sat Oct 19 06:51:34 2013	(r256764)
@@ -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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310190651.r9J6pZ2j038490>