Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/mk Add a experimental "make test" target



details:   https://anonhg.NetBSD.org/src/rev/ca4605e2189f
branches:  trunk
changeset: 755741:ca4605e2189f
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Fri Jun 18 10:10:57 2010 +0000

description:
Add a experimental "make test" target

make test may yield misleading results but should work in many cases.  This
target is supposed to simplify the execution of tests but does not preclude
developers from running the installed versions.

Addresses PR misc/38326.

diffstat:

 share/mk/bsd.test.mk |  54 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diffs (65 lines):

diff -r 9873969c11f0 -r ca4605e2189f share/mk/bsd.test.mk
--- a/share/mk/bsd.test.mk      Fri Jun 18 09:18:16 2010 +0000
+++ b/share/mk/bsd.test.mk      Fri Jun 18 10:10:57 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.test.mk,v 1.8 2010/06/04 08:35:09 jmmv Exp $
+# $NetBSD: bsd.test.mk,v 1.9 2010/06/18 10:10:57 jmmv Exp $
 #
 
 .include <bsd.init.mk>
@@ -55,3 +55,55 @@
 .if !empty(SCRIPTS) || !empty(PROGS) || !empty(PROGS_CXX)
 .  include <bsd.prog.mk>
 .endif
+
+#
+# Definition of the "make test" target and supporting variables.
+#
+# This target, by necessity, can only work for native builds (i.e. a NetBSD
+# 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_PATH += ${DESTDIR}/bin ${DESTDIR}/sbin ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
+TESTS_LD_LIBRARY_PATH += ${DESTDIR}/lib ${DESTDIR}/usr/lib
+
+TESTS_ENV += LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:S/ /:/g}
+TESTS_ENV += PATH=${TESTS_PATH:tW:S/ /:/g}
+
+_TESTS_FIFO = ${.OBJDIR}/atf-run.fifo
+_TESTS_LOG = ${.OBJDIR}/atf-run.log
+CLEANFILES += ${_TESTS_FIFO} ${_TESTS_LOG}
+
+.PHONY: test
+.if ${TESTSDIR} == ${TESTSBASE}
+# Forbid this case.  It is likely to cause false positives/negatives and it
+# does not cover all the tests (e.g. it misses testing software in external).
+test:
+       @echo "*** Sorry, you cannot use make test from src/tests.  Install the"
+       @echo "*** tests into their final location and run them from /usr/tests"
+       @false
+.else
+test:
+       @echo "*** WARNING: make test is experimental"
+       @echo "***"
+       @echo "*** Using this test does not preclude you from running the tests"
+       @echo "*** installed in /usr/tests.  This test run may raise false"
+       @echo "*** positives and/or false negatives."
+       @echo
+       @cd ${DESTDIR}${TESTSDIR}; \
+       mkfifo ${_TESTS_FIFO}; \
+       cat ${_TESTS_FIFO} | tee ${_TESTS_LOG} | \
+           ${TESTS_ENV} ${DESTDIR}/usr/bin/atf-report & \
+       ${TESTS_ENV} ${DESTDIR}/usr/bin/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 "*** Once again, note that "make test" is unsupported."; \
+       test $${result} -eq 0
+.endif



Home | Main Index | Thread Index | Old Index