Changeset View
Changeset View
Standalone View
Standalone View
share/mk/suite.test.mk
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# You must include bsd.test.mk instead of this file from your Makefile. | # You must include bsd.test.mk instead of this file from your Makefile. | ||||
# | # | ||||
# Internal glue for the build of /usr/tests/. | # Internal glue for the build of /usr/tests/. | ||||
.if !target(__<bsd.test.mk>__) | .if !target(__<bsd.test.mk>__) | ||||
.error suite.test.mk cannot be included directly. | .error suite.test.mk cannot be included directly. | ||||
.endif | .endif | ||||
# Directory in which to install tests defined by the current Makefile. | |||||
# Makefiles have to override this to point to a subdirectory of TESTSBASE. | |||||
TESTSDIR?= . | |||||
# Name of the test suite these tests belong to. Should rarely be changed for | # Name of the test suite these tests belong to. Should rarely be changed for | ||||
# Makefiles built into the FreeBSD src tree. | # Makefiles built into the FreeBSD src tree. | ||||
TESTSUITE?= FreeBSD | TESTSUITE?= FreeBSD | ||||
# Knob to control the handling of the Kyuafile for this Makefile. | # Knob to control the handling of the Kyuafile for this Makefile. | ||||
# | # | ||||
# If 'yes', a Kyuafile exists in the source tree and is installed into | # If 'yes', a Kyuafile exists in the source tree and is installed into | ||||
# TESTSDIR. | # TESTSDIR. | ||||
Show All 23 Lines | |||||
# Per-test program metadata properties as a list of key/value pairs. | # Per-test program metadata properties as a list of key/value pairs. | ||||
# | # | ||||
# These per-test program settings _extend_ the values provided in the | # These per-test program settings _extend_ the values provided in the | ||||
# unqualified TEST_METADATA variable. | # unqualified TEST_METADATA variable. | ||||
#TEST_METADATA.<test-program>+= key="value" | #TEST_METADATA.<test-program>+= key="value" | ||||
# Path to the prefix of the installed Kyua CLI, if any. | # Path to the prefix of the installed Kyua CLI, if any. | ||||
# | # | ||||
# If kyua is installed from ports, we automatically define a realtest target | # If kyua is installed from ports, we automatically define a realcheck target | ||||
# below to run the tests using this tool. The tools are searched for in the | # below to run the tests using this tool. The tools are searched for in the | ||||
# hierarchy specified by this variable. | # hierarchy specified by this variable. | ||||
KYUA_PREFIX?= /usr/local | LOCALBASE?= /usr/local | ||||
.if ${KYUAFILE:tl} == "yes" | .if ${KYUAFILE:tl} != "no" | ||||
FILES+= Kyuafile | FILES+= Kyuafile | ||||
FILESDIR_Kyuafile= ${TESTSDIR} | FILESDIR_Kyuafile= ${TESTSDIR} | ||||
CLEANFILES+= Kyuafile Kyuafile.tmp | |||||
.endif | |||||
CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp | .if ${KYUAFILE:tl} == "auto" | ||||
.elif ${KYUAFILE:tl} == "auto" | |||||
FILES+= Kyuafile.auto | |||||
FILESDIR_Kyuafile.auto= ${TESTSDIR} | |||||
FILESNAME_Kyuafile.auto= Kyuafile | |||||
CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp | |||||
.for _T in ${_TESTS} | .for _T in ${_TESTS} | ||||
_TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}} | _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}} | ||||
.endfor | .endfor | ||||
.NOPATH: Kyuafile.auto | .NOPATH: Kyuafile | ||||
Kyuafile.auto: Makefile | Kyuafile: Makefile | ||||
ngie: I think .NOPATH breaks tinderbox. Need to remove and retest. | |||||
@{ \ | @{ \ | ||||
echo '-- Automatically generated by bsd.test.mk.'; \ | echo '-- Automatically generated by bsd.test.mk.'; \ | ||||
echo; \ | echo; \ | ||||
echo 'syntax(2)'; \ | echo 'syntax(2)'; \ | ||||
echo; \ | echo; \ | ||||
echo 'test_suite("${TESTSUITE}")'; \ | echo 'test_suite("${TESTSUITE}")'; \ | ||||
echo; \ | echo; \ | ||||
} >Kyuafile.auto.tmp | } > ${.TARGET}.tmp | ||||
.for _T in ${_TESTS} | .for _T in ${_TESTS} | ||||
@echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ | @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ | ||||
>>Kyuafile.auto.tmp | >>${.TARGET}.tmp | ||||
.endfor | .endfor | ||||
.for _T in ${TESTS_SUBDIRS:N.WAIT} | .for _T in ${TESTS_SUBDIRS:N.WAIT} | ||||
@echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.auto.tmp | @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp | ||||
.endfor | .endfor | ||||
@mv Kyuafile.auto.tmp Kyuafile.auto | @mv ${.TARGET}.tmp ${.TARGET} | ||||
Done Inline ActionsI'd be fine with these cleanups going in first emaste: I'd be fine with these cleanups going in first | |||||
.endif | .endif | ||||
KYUA?= ${KYUA_PREFIX}/bin/kyua | CHECKDIR?= ${DESTDIR}${TESTSDIR} | ||||
.if exists(${KYUA}) | |||||
# Definition of the "make test" target and supporting variables. | KYUA= ${LOCALBASE}/bin/kyua | ||||
${KYUA}: | |||||
@echo | |||||
@echo "kyua binary not installed at expected location (${.TARGET})" | |||||
@echo | |||||
@echo "Please install via pkg install, or specify the path to the kyua" | |||||
@echo "package via the \$${LOCALBASE} variable, e.g. " | |||||
@echo "LOCALBASE=\"${LOCALBASE}\"" | |||||
@false | |||||
Done Inline Actionsthis seems strange to me, I'd expect a if [ ! -x ${LOCALBASE}/bin/kyua ] type test in the intended target instead emaste: this seems strange to me, I'd expect a `if [ ! -x ${LOCALBASE}/bin/kyua ]` type test in the… | |||||
Done Inline ActionsYeah, you're right. There might be some unintended side effects of doing it this way, so I'll do an inline if statement instead. ngie: Yeah, you're right. There might be some unintended side effects of doing it this way, so I'll… | |||||
# Definition of the "make check" target and supporting variables. | |||||
# | # | ||||
# This target, by necessity, can only work for native builds (i.e. a FreeBSD | # 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 Kyua, which is | # host building a release for the same system). The target runs Kyua, which is | ||||
# not in the toolchain, and the tests execute code built for the target host. | # 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 | # 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 | # 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. | # report bogus results unless the new binaries are put in place. | ||||
realtest: .PHONY | |||||
@echo "*** WARNING: make test is experimental" | |||||
@echo "***" | |||||
@echo "*** Using this test does not preclude you from running the tests" | |||||
@echo "*** installed in ${TESTSBASE}. This test run may raise false" | |||||
@echo "*** positives and/or false negatives." | |||||
@echo | |||||
@${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ | |||||
result=0; \ | |||||
echo; \ | |||||
echo "*** Once again, note that "make test" is unsupported."; \ | |||||
test $${result} -eq 0 | |||||
.endif | |||||
beforetest: .PHONY | realcheck: .PHONY | ||||
.if defined(TESTSDIR) | realcheck: ${KYUA} | ||||
.if ${TESTSDIR} == ${TESTSBASE} | @${KYUA} test -k ${CHECKDIR}/Kyuafile | ||||
# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and | |||||
# it does not cover all the tests (e.g. it misses testing software in external). | |||||
@echo "*** Sorry, you cannot use make test from src/tests. Install the" | |||||
@echo "*** tests into their final location and run them from ${TESTSBASE}" | |||||
@false | |||||
.else | |||||
@echo "*** Using this test does not preclude you from running the tests" | |||||
@echo "*** installed in ${TESTSBASE}. This test run may raise false" | |||||
@echo "*** positives and/or false negatives." | |||||
.endif | |||||
.else | |||||
@echo "*** No TESTSDIR defined; nothing to do." | |||||
@false | |||||
.endif | |||||
@echo |
I think .NOPATH breaks tinderbox. Need to remove and retest.