1263172Sjmmv# $FreeBSD: releng/10.3/share/mk/suite.test.mk 292812 2015-12-28 00:05:31Z ngie $ 2263172Sjmmv# 3263172Sjmmv# You must include bsd.test.mk instead of this file from your Makefile. 4263172Sjmmv# 5263172Sjmmv# Internal glue for the build of /usr/tests/. 6263172Sjmmv 7263172Sjmmv.if !target(__<bsd.test.mk>__) 8263172Sjmmv.error suite.test.mk cannot be included directly. 9263172Sjmmv.endif 10263172Sjmmv 11263172Sjmmv# Name of the test suite these tests belong to. Should rarely be changed for 12263172Sjmmv# Makefiles built into the FreeBSD src tree. 13263172SjmmvTESTSUITE?= FreeBSD 14263172Sjmmv 15263172Sjmmv# Knob to control the handling of the Kyuafile for this Makefile. 16263172Sjmmv# 17263172Sjmmv# If 'yes', a Kyuafile exists in the source tree and is installed into 18263172Sjmmv# TESTSDIR. 19263172Sjmmv# 20263172Sjmmv# If 'auto', a Kyuafile is automatically generated based on the list of test 21263172Sjmmv# programs built by the Makefile and is installed into TESTSDIR. This is the 22263172Sjmmv# default and is sufficient in the majority of the cases. 23263172Sjmmv# 24263172Sjmmv# If 'no', no Kyuafile is installed. 25263172SjmmvKYUAFILE?= auto 26263172Sjmmv 27263172Sjmmv# Per-test program interface definition. 28263172Sjmmv# 29263172Sjmmv# The name provided here must match one of the interface names supported by 30263172Sjmmv# Kyua as this is later encoded in the Kyuafile test program definitions. 31263172Sjmmv#TEST_INTERFACE.<test-program>= interface-name 32263172Sjmmv 33263172Sjmmv# Per-test program metadata properties as a list of key/value pairs. 34263172Sjmmv# 35263172Sjmmv# All the variables for a particular program are appended to the program's 36263172Sjmmv# definition in the Kyuafile. This feature can be used to avoid having to 37263172Sjmmv# explicitly supply a Kyuafile in the source directory, allowing the caller 38263172Sjmmv# Makefile to rely on the KYUAFILE=auto behavior defined here. 39263172Sjmmv#TEST_METADATA.<test-program>+= key="value" 40263172Sjmmv 41292768Sngie.if ${KYUAFILE:tl} != "no" 42263172SjmmvFILES+= Kyuafile 43263172SjmmvFILESDIR_Kyuafile= ${TESTSDIR} 44292768Sngie.endif 45263172Sjmmv 46292768Sngie.if ${KYUAFILE:tl} == "auto" 47292768SngieCLEANFILES+= Kyuafile Kyuafile.tmp 48292768Sngie.endif 49263172Sjmmv 50292768Sngie.if ${KYUAFILE:tl} == "auto" 51292768SngieKyuafile: Makefile 52263172Sjmmv @{ \ 53263172Sjmmv echo '-- Automatically generated by bsd.test.mk.'; \ 54263172Sjmmv echo; \ 55263172Sjmmv echo 'syntax(2)'; \ 56263172Sjmmv echo; \ 57263172Sjmmv echo 'test_suite("${TESTSUITE}")'; \ 58263172Sjmmv echo; \ 59292768Sngie } > ${.TARGET}.tmp 60263172Sjmmv.for _T in ${_TESTS} 61289050Sbdrewery.if defined(.PARSEDIR) 62263172Sjmmv @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ 63292768Sngie >>${.TARGET}.tmp 64289050Sbdrewery.else 65289050Sbdrewery @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/^/, /:Q:S/\\ ,/,/g:S,\\,,g}}' \ 66289050Sbdrewery >>Kyuafile.auto.tmp 67289050Sbdrewery.endif 68263172Sjmmv.endfor 69263172Sjmmv.for _T in ${TESTS_SUBDIRS:N.WAIT} 70292768Sngie @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp 71263172Sjmmv.endfor 72292768Sngie @mv ${.TARGET}.tmp ${.TARGET} 73263172Sjmmv.endif 74263172Sjmmv 75292812SngieKYUA= ${LOCALBASE}/bin/kyua 76263172Sjmmv.if exists(${KYUA}) 77263172Sjmmv# Definition of the "make test" target and supporting variables. 78263172Sjmmv# 79263172Sjmmv# This target, by necessity, can only work for native builds (i.e. a FreeBSD 80263172Sjmmv# host building a release for the same system). The target runs Kyua, which is 81263172Sjmmv# not in the toolchain, and the tests execute code built for the target host. 82263172Sjmmv# 83263172Sjmmv# Due to the dependencies of the binaries built by the source tree and how they 84263172Sjmmv# are used by tests, it is highly possible for a execution of "make test" to 85263172Sjmmv# report bogus results unless the new binaries are put in place. 86263172Sjmmvrealtest: .PHONY 87263172Sjmmv @echo "*** WARNING: make test is experimental" 88263172Sjmmv @echo "***" 89263172Sjmmv @echo "*** Using this test does not preclude you from running the tests" 90263172Sjmmv @echo "*** installed in ${TESTSBASE}. This test run may raise false" 91263172Sjmmv @echo "*** positives and/or false negatives." 92263172Sjmmv @echo 93263172Sjmmv @set -e; \ 94263172Sjmmv ${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ 95263172Sjmmv result=0; \ 96263172Sjmmv echo; \ 97263172Sjmmv echo "*** Once again, note that "make test" is unsupported."; \ 98263172Sjmmv test $${result} -eq 0 99263172Sjmmv.endif 100263172Sjmmv 101263172Sjmmvbeforetest: .PHONY 102263172Sjmmv.if defined(TESTSDIR) 103263172Sjmmv.if ${TESTSDIR} == ${TESTSBASE} 104263172Sjmmv# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and 105263172Sjmmv# it does not cover all the tests (e.g. it misses testing software in external). 106263172Sjmmv @echo "*** Sorry, you cannot use make test from src/tests. Install the" 107263172Sjmmv @echo "*** tests into their final location and run them from ${TESTSBASE}" 108263172Sjmmv @false 109263172Sjmmv.else 110263172Sjmmv @echo "*** Using this test does not preclude you from running the tests" 111263172Sjmmv @echo "*** installed in ${TESTSBASE}. This test run may raise false" 112263172Sjmmv @echo "*** positives and/or false negatives." 113263172Sjmmv.endif 114263172Sjmmv.else 115263172Sjmmv @echo "*** No TESTSDIR defined; nothing to do." 116263172Sjmmv @false 117263172Sjmmv.endif 118263172Sjmmv @echo 119