suite.test.mk (313789) | suite.test.mk (313790) |
---|---|
1# $FreeBSD: stable/10/share/mk/suite.test.mk 313789 2017-02-16 04:23:45Z ngie $ | 1# $FreeBSD: stable/10/share/mk/suite.test.mk 313790 2017-02-16 05:14:07Z ngie $ |
2# 3# You must include bsd.test.mk instead of this file from your Makefile. 4# 5# Internal glue for the build of /usr/tests/. 6 7.if !target(__<bsd.test.mk>__) 8.error suite.test.mk cannot be included directly. 9.endif --- 15 unchanged lines hidden (view full) --- 25KYUAFILE?= auto 26 27# Per-test program interface definition. 28# 29# The name provided here must match one of the interface names supported by 30# Kyua as this is later encoded in the Kyuafile test program definitions. 31#TEST_INTERFACE.<test-program>= interface-name 32 | 2# 3# You must include bsd.test.mk instead of this file from your Makefile. 4# 5# Internal glue for the build of /usr/tests/. 6 7.if !target(__<bsd.test.mk>__) 8.error suite.test.mk cannot be included directly. 9.endif --- 15 unchanged lines hidden (view full) --- 25KYUAFILE?= auto 26 27# Per-test program interface definition. 28# 29# The name provided here must match one of the interface names supported by 30# Kyua as this is later encoded in the Kyuafile test program definitions. 31#TEST_INTERFACE.<test-program>= interface-name 32 |
33# Metadata properties applicable to all test programs. 34# 35# All the variables for a test program defined in the Makefile are appended 36# to the test program's definition in the Kyuafile. This feature can be 37# used to avoid having to explicitly supply a Kyuafile in the source 38# directory, allowing the caller Makefile to rely on the KYUAFILE=auto 39# behavior defined here. 40#TEST_METADATA+= key="value" 41 |
|
33# Per-test program metadata properties as a list of key/value pairs. 34# | 42# Per-test program metadata properties as a list of key/value pairs. 43# |
35# All the variables for a particular program are appended to the program's 36# definition in the Kyuafile. This feature can be used to avoid having to 37# explicitly supply a Kyuafile in the source directory, allowing the caller 38# Makefile to rely on the KYUAFILE=auto behavior defined here. | 44# These per-test program settings _extend_ the values provided in the 45# unqualified TEST_METADATA variable. |
39#TEST_METADATA.<test-program>+= key="value" 40 41.if ${KYUAFILE:tl} != "no" 42FILES+= Kyuafile 43FILESDIR_Kyuafile= ${TESTSDIR} 44.endif 45 | 46#TEST_METADATA.<test-program>+= key="value" 47 48.if ${KYUAFILE:tl} != "no" 49FILES+= Kyuafile 50FILESDIR_Kyuafile= ${TESTSDIR} 51.endif 52 |
46.if ${KYUAFILE:tl} == "auto" 47CLEANFILES+= Kyuafile Kyuafile.tmp 48.endif | 53.for _T in ${_TESTS} 54_TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}} 55.endfor |
49 50.if ${KYUAFILE:tl} == "auto" | 56 57.if ${KYUAFILE:tl} == "auto" |
58CLEANFILES+= Kyuafile Kyuafile.tmp |
|
51Kyuafile: Makefile 52 @{ \ 53 echo '-- Automatically generated by bsd.test.mk.'; \ 54 echo; \ 55 echo 'syntax(2)'; \ 56 echo; \ 57 echo 'test_suite("${TESTSUITE}")'; \ 58 echo; \ 59 } > ${.TARGET}.tmp 60.for _T in ${_TESTS} 61.if defined(.PARSEDIR) | 59Kyuafile: Makefile 60 @{ \ 61 echo '-- Automatically generated by bsd.test.mk.'; \ 62 echo; \ 63 echo 'syntax(2)'; \ 64 echo; \ 65 echo 'test_suite("${TESTSUITE}")'; \ 66 echo; \ 67 } > ${.TARGET}.tmp 68.for _T in ${_TESTS} 69.if defined(.PARSEDIR) |
62 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ | 70 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ |
63 >>${.TARGET}.tmp 64.else | 71 >>${.TARGET}.tmp 72.else |
65 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/^/, /:Q:S/\\ ,/,/g:S,\\,,g}}' \ | 73 @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/^/, /:Q:S/\\ ,/,/g:S,\\,,g}}' \ |
66 >>Kyuafile.auto.tmp 67.endif 68.endfor 69.for _T in ${TESTS_SUBDIRS:N.WAIT} 70 @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp 71.endfor 72 @mv ${.TARGET}.tmp ${.TARGET} 73.endif 74 | 74 >>Kyuafile.auto.tmp 75.endif 76.endfor 77.for _T in ${TESTS_SUBDIRS:N.WAIT} 78 @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp 79.endfor 80 @mv ${.TARGET}.tmp ${.TARGET} 81.endif 82 |
83CHECKDIR?= ${DESTDIR}${TESTSDIR} 84 |
|
75KYUA= ${LOCALBASE}/bin/kyua | 85KYUA= ${LOCALBASE}/bin/kyua |
76.if exists(${KYUA}) 77# Definition of the "make test" target and supporting variables. | 86 87# Definition of the "make check" target and supporting variables. |
78# 79# This target, by necessity, can only work for native builds (i.e. a FreeBSD 80# host building a release for the same system). The target runs Kyua, which is 81# not in the toolchain, and the tests execute code built for the target host. 82# 83# Due to the dependencies of the binaries built by the source tree and how they 84# are used by tests, it is highly possible for a execution of "make test" to 85# report bogus results unless the new binaries are put in place. | 88# 89# This target, by necessity, can only work for native builds (i.e. a FreeBSD 90# host building a release for the same system). The target runs Kyua, which is 91# not in the toolchain, and the tests execute code built for the target host. 92# 93# Due to the dependencies of the binaries built by the source tree and how they 94# are used by tests, it is highly possible for a execution of "make test" to 95# report bogus results unless the new binaries are put in place. |
86realtest: .PHONY 87 @echo "*** WARNING: make test is experimental" 88 @echo "***" 89 @echo "*** Using this test does not preclude you from running the tests" 90 @echo "*** installed in ${TESTSBASE}. This test run may raise false" 91 @echo "*** positives and/or false negatives." 92 @echo 93 @${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ 94 result=0; \ 95 echo; \ 96 echo "*** Once again, note that "make test" is unsupported."; \ 97 test $${result} -eq 0 98.endif | |
99 | 96 |
100beforetest: .PHONY 101.if defined(TESTSDIR) 102.if ${TESTSDIR} == ${TESTSBASE} 103# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and 104# it does not cover all the tests (e.g. it misses testing software in external). 105 @echo "*** Sorry, you cannot use make test from src/tests. Install the" 106 @echo "*** tests into their final location and run them from ${TESTSBASE}" 107 @false 108.else 109 @echo "*** Using this test does not preclude you from running the tests" 110 @echo "*** installed in ${TESTSBASE}. This test run may raise false" 111 @echo "*** positives and/or false negatives." 112.endif 113.else 114 @echo "*** No TESTSDIR defined; nothing to do." 115 @false 116.endif 117 @echo | 97realcheck: .PHONY 98 @if [ ! -x ${KYUA} ]; then \ 99 echo; \ 100 echo "kyua binary not installed at expected location (${.TARGET})"; \ 101 echo; \ 102 echo "Please install via pkg install, or specify the path to the kyua"; \ 103 echo "package via the \$${LOCALBASE} variable, e.g. "; \ 104 echo "LOCALBASE=\"${LOCALBASE}\""; \ 105 false; \ 106 fi 107 @${KYUA} test -k ${CHECKDIR}/Kyuafile |