summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorjmmv <jmmv@FreeBSD.org>2014-03-06 13:30:36 +0000
committerjmmv <jmmv@FreeBSD.org>2014-03-06 13:30:36 +0000
commit74e392eb6c6b063a59702d6c9e0c4aeda35bf2d0 (patch)
tree95551b1c20ac8b5e39b67098f5da7f6eb5e9ce34 /share
parentccebcfd33be062df09a39f66bdcedd42460c15f4 (diff)
downloadFreeBSD-src-74e392eb6c6b063a59702d6c9e0c4aeda35bf2d0.zip
FreeBSD-src-74e392eb6c6b063a59702d6c9e0c4aeda35bf2d0.tar.gz
MFC a couple of improvements to the test suite mk files.
- r260632 Support defining test program metadata from the Makefiles. - r260633 Support perl-based TAP-compliant test programs.
Diffstat (limited to 'share')
-rw-r--r--share/mk/bsd.test.mk16
-rw-r--r--share/mk/tap.test.mk27
2 files changed, 42 insertions, 1 deletions
diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk
index 01d74b5..ee96f77 100644
--- a/share/mk/bsd.test.mk
+++ b/share/mk/bsd.test.mk
@@ -41,6 +41,20 @@ TESTS_SUBDIRS?=
# If 'no', no Kyuafile is installed.
KYUAFILE?= auto
+# Per-test program interface definition.
+#
+# The name provided here must match one of the interface names supported by
+# Kyua as this is later encoded in the Kyuafile test program definitions.
+#TEST_INTERFACE.<test-program>= interface-name
+
+# Per-test program metadata properties as a list of key/value pairs.
+#
+# All the variables for a particular program are appended to the program's
+# definition in the Kyuafile. This feature can be used to avoid having to
+# explicitly supply a Kyuafile in the source directory, allowing the caller
+# Makefile to rely on the KYUAFILE=auto behavior defined here.
+#TEST_METADATA.<test-program>+= key="value"
+
# List of variables to pass to the tests at run-time via the environment.
TESTS_ENV?=
@@ -102,7 +116,7 @@ Kyuafile.auto: Makefile
echo; \
} >Kyuafile.auto.tmp
.for _T in ${_TESTS}
- @echo "${TEST_INTERFACE.${_T}}_test_program{name=\"${_T}\"}" \
+ @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \
>>Kyuafile.auto.tmp
.endfor
.for _T in ${TESTS_SUBDIRS:N.WAIT}
diff --git a/share/mk/tap.test.mk b/share/mk/tap.test.mk
index 394f685..9c1ef54 100644
--- a/share/mk/tap.test.mk
+++ b/share/mk/tap.test.mk
@@ -18,8 +18,12 @@
# manpage.
TAP_TESTS_C?=
TAP_TESTS_CXX?=
+TAP_TESTS_PERL?=
TAP_TESTS_SH?=
+# Perl interpreter to use for test programs written in this language.
+TAP_PERL_INTERPRETER?= /usr/local/bin/perl
+
.if !empty(TAP_TESTS_C)
PROGS+= ${TAP_TESTS_C}
_TESTS+= ${TAP_TESTS_C}
@@ -42,6 +46,29 @@ TEST_INTERFACE.${_T}= tap
.endfor
.endif
+.if !empty(TAP_TESTS_PERL)
+SCRIPTS+= ${TAP_TESTS_PERL}
+_TESTS+= ${TAP_TESTS_PERL}
+.for _T in ${TAP_TESTS_PERL}
+SCRIPTSDIR_${_T}= ${TESTSDIR}
+TEST_INTERFACE.${_T}= tap
+TEST_METADATA.${_T}+= required_programs="${TAP_PERL_INTERPRETER}"
+CLEANFILES+= ${_T} ${_T}.tmp
+# TODO(jmmv): It seems to me that this SED and SRC functionality should
+# exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
+# this proves to be useful within the tests.
+TAP_TESTS_PERL_SED_${_T}?= # empty
+TAP_TESTS_PERL_SRC_${_T}?= ${_T}.pl
+${_T}: ${TAP_TESTS_PERL_SRC_${_T}}
+ { \
+ echo '#! ${TAP_PERL_INTERPRETER}'; \
+ cat ${.ALLSRC} | sed ${TAP_TESTS_PERL_SED_${_T}}; \
+ } >${.TARGET}.tmp
+ chmod +x ${.TARGET}.tmp
+ mv ${.TARGET}.tmp ${.TARGET}
+.endfor
+.endif
+
.if !empty(TAP_TESTS_SH)
SCRIPTS+= ${TAP_TESTS_SH}
_TESTS+= ${TAP_TESTS_SH}
OpenPOWER on IntegriCloud