Index: head/share/mk/atf.test.mk =================================================================== --- head/share/mk/atf.test.mk (revision 274076) +++ head/share/mk/atf.test.mk (revision 274077) @@ -1,185 +1,189 @@ # $FreeBSD$ # # You must include bsd.test.mk instead of this file from your Makefile. # # Logic to build and install ATF test programs; i.e. test programs linked # against the ATF libraries. .if !target(____) .error atf.test.mk cannot be included directly. .endif # List of C, C++ and shell test programs to build. # # Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS, # respectively, from bsd.prog.mk. However, the build rules are tweaked to # require the ATF libraries. # # Test programs registered in this manner are set to be installed into TESTSDIR # (which should be overriden by the Makefile) and are not required to provide a # manpage. ATF_TESTS_C?= ATF_TESTS_CXX?= ATF_TESTS_SH?= # Whether to allow using the deprecated ATF tools or not. # # If 'yes', this file will generate Atffiles when requested and will also # support using the deprecated atf-run tool to execute the tests. ALLOW_DEPRECATED_ATF_TOOLS?= no # Knob to control the handling of the Atffile for this Makefile. # # If 'yes', an Atffile exists in the source tree and is installed into # TESTSDIR. # # If 'auto', an Atffile is automatically generated based on the list of test # programs built by the Makefile and is installed into TESTSDIR. This is the # default and is sufficient in the majority of the cases. # # If 'no', no Atffile is installed. ATFFILE?= auto # Path to the prefix of the installed ATF tools, if any. # # If atf-run and atf-report are installed from ports, we automatically define a # realtest target below to run the tests using these tools. The tools are # searched for in the hierarchy specified by this variable. ATF_PREFIX?= /usr/local # C compiler passed to ATF tests that need to build code. ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC} # C preprocessor passed to ATF tests that need to build code. ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP} # C++ compiler passed to ATF tests that need to build code. ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++ TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX} # Shell interpreter used to run atf-sh(1) based tests. ATF_SHELL?= ${DESTDIR}/bin/sh TESTS_ENV+= ATF_SHELL=${ATF_SHELL} .if !empty(ATF_TESTS_C) PROGS+= ${ATF_TESTS_C} _TESTS+= ${ATF_TESTS_C} .for _T in ${ATF_TESTS_C} BINDIR.${_T}= ${TESTSDIR} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.c DPADD.${_T}+= ${LIBATF_C} .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static) LDADD.${_T}+= ${LDATF_C} .else LDADD.${_T}+= ${LIBATF_C} .endif USEPRIVATELIB+= atf-c TEST_INTERFACE.${_T}= atf .endfor .endif .if !empty(ATF_TESTS_CXX) PROGS_CXX+= ${ATF_TESTS_CXX} _TESTS+= ${ATF_TESTS_CXX} .for _T in ${ATF_TESTS_CXX} BINDIR.${_T}= ${TESTSDIR} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc} DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static) LDADD.${_T}+= ${LDATF_CXX} ${LDATF_C} .else LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} .endif USEPRIVATELIB+= atf-c++ TEST_INTERFACE.${_T}= atf .endfor .endif .if !empty(ATF_TESTS_SH) SCRIPTS+= ${ATF_TESTS_SH} _TESTS+= ${ATF_TESTS_SH} .for _T in ${ATF_TESTS_SH} SCRIPTSDIR_${_T}= ${TESTSDIR} TEST_INTERFACE.${_T}= atf 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. ATF_TESTS_SH_SED_${_T}?= # empty ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh ${_T}: ${ATF_TESTS_SH_SRC_${_T}} echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp +.if empty(ATF_TESTS_SH_SED_${_T}) + cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp +.else cat ${.ALLSRC:N*Makefile*} \ | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp +.endif chmod +x ${.TARGET}.tmp mv ${.TARGET}.tmp ${.TARGET} .endfor .endif .if ${ALLOW_DEPRECATED_ATF_TOOLS} != "no" .if ${ATFFILE:tl} != "no" FILES+= Atffile FILESDIR_Atffile= ${TESTSDIR} .if ${ATFFILE:tl} == "auto" CLEANFILES+= Atffile Atffile.tmp Atffile: Makefile @{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \ echo; \ echo '# Automatically generated by atf-test.mk.'; \ echo; \ echo 'prop: test-suite = "'${TESTSUITE}'"'; \ echo; \ for tp in ${ATF_TESTS_C} ${ATF_TESTS_CXX} ${ATF_TESTS_SH} \ ${TESTS_SUBDIRS}; \ do \ echo "tp: $${tp}"; \ done; } >Atffile.tmp @mv Atffile.tmp Atffile .endif .endif ATF_REPORT?= ${ATF_PREFIX}/bin/atf-report ATF_RUN?= ${ATF_PREFIX}/bin/atf-run .if exists(${ATF_RUN}) && exists(${ATF_REPORT}) # Definition of the "make test" target and supporting variables. # # 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 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_FIFO= ${.OBJDIR}/atf-run.fifo _TESTS_LOG= ${.OBJDIR}/atf-run.log CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG} realtest: .PHONY @set -e; \ if [ -z "${TESTSDIR}" ]; then \ echo "*** No TESTSDIR defined; nothing to do."; \ exit 0; \ fi; \ cd ${DESTDIR}${TESTSDIR}; \ rm -f ${_TESTS_FIFO}; \ mkfifo ${_TESTS_FIFO}; \ tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \ set +e; \ ${TESTS_ENV} ${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 "***"; \ echo "*** WARNING: atf-run is deprecated; please install kyua instead"; \ exit $${result} .endif .endif Index: head/share/mk/plain.test.mk =================================================================== --- head/share/mk/plain.test.mk (revision 274076) +++ head/share/mk/plain.test.mk (revision 274077) @@ -1,65 +1,69 @@ # $FreeBSD$ # # You must include bsd.test.mk instead of this file from your Makefile. # # Logic to build and install plain test programs. A plain test programs it not # supposed to use any specific testing framework: all it does is run some code # and report the test's pass or fail status via a 0 or 1 exit code. .if !target(____) .error plain.test.mk cannot be included directly. .endif # List of C, C++ and shell test programs to build. # # Programs listed here are built according to the semantics of bsd.prog.mk for # PROGS, PROGS_CXX and SCRIPTS, respectively. # # Test programs registered in this manner are set to be installed into TESTSDIR # (which should be overriden by the Makefile) and are not required to provide a # manpage. PLAIN_TESTS_C?= PLAIN_TESTS_CXX?= PLAIN_TESTS_SH?= .if !empty(PLAIN_TESTS_C) PROGS+= ${PLAIN_TESTS_C} _TESTS+= ${PLAIN_TESTS_C} .for _T in ${PLAIN_TESTS_C} BINDIR.${_T}= ${TESTSDIR} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.c TEST_INTERFACE.${_T}= plain .endfor .endif .if !empty(PLAIN_TESTS_CXX) PROGS_CXX+= ${PLAIN_TESTS_CXX} _TESTS+= ${PLAIN_TESTS_CXX} .for _T in ${PLAIN_TESTS_CXX} BINDIR.${_T}= ${TESTSDIR} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.cc TEST_INTERFACE.${_T}= plain .endfor .endif .if !empty(PLAIN_TESTS_SH) SCRIPTS+= ${PLAIN_TESTS_SH} _TESTS+= ${PLAIN_TESTS_SH} .for _T in ${PLAIN_TESTS_SH} SCRIPTSDIR_${_T}= ${TESTSDIR} TEST_INTERFACE.${_T}= plain 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. PLAIN_TESTS_SH_SED_${_T}?= # empty PLAIN_TESTS_SH_SRC_${_T}?= ${_T}.sh ${_T}: ${PLAIN_TESTS_SH_SRC_${_T}} +.if empty(PLAIN_TESTS_SH_SED_${_T}) + cat ${.ALLSRC:N*Makefile*} >${.TARGET}.tmp +.else cat ${.ALLSRC:N*Makefile*} \ | sed ${PLAIN_TESTS_SH_SED_${_T}} >${.TARGET}.tmp +.endif chmod +x ${.TARGET}.tmp mv ${.TARGET}.tmp ${.TARGET} .endfor .endif Index: head/share/mk/tap.test.mk =================================================================== --- head/share/mk/tap.test.mk (revision 274076) +++ head/share/mk/tap.test.mk (revision 274077) @@ -1,93 +1,97 @@ # $FreeBSD$ # # You must include bsd.test.mk instead of this file from your Makefile. # # Logic to build and install TAP-compliant test programs. # # This is provided to support existing tests in the FreeBSD source tree # (particularly those coming from tools/regression/) that comply with the # Test Anything Protocol. It should not be used for new tests. .if !target(____) .error tap.test.mk cannot be included directly. .endif # List of C, C++ and shell test programs to build. # # Programs listed here are built according to the semantics of bsd.prog.mk for # PROGS, PROGS_CXX and SCRIPTS, respectively. # # Test programs registered in this manner are set to be installed into TESTSDIR # (which should be overriden by the Makefile) and are not required to provide a # 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} .for _T in ${TAP_TESTS_C} BINDIR.${_T}= ${TESTSDIR} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.c TEST_INTERFACE.${_T}= tap .endfor .endif .if !empty(TAP_TESTS_CXX) PROGS_CXX+= ${TAP_TESTS_CXX} _TESTS+= ${TAP_TESTS_CXX} .for _T in ${TAP_TESTS_CXX} BINDIR.${_T}= ${TESTSDIR} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.cc 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:N*Makefile*} | 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} .for _T in ${TAP_TESTS_SH} SCRIPTSDIR_${_T}= ${TESTSDIR} TEST_INTERFACE.${_T}= tap 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_SH_SED_${_T}?= # empty TAP_TESTS_SH_SRC_${_T}?= ${_T}.sh ${_T}: ${TAP_TESTS_SH_SRC_${_T}} +.if empty(TAP_TESTS_SH_SED_${_T}) + cat ${.ALLSRC} >${.TARGET}.tmp +.else cat ${.ALLSRC} | sed ${TAP_TESTS_SH_SED_${_T}} >${.TARGET}.tmp +.endif chmod +x ${.TARGET}.tmp mv ${.TARGET}.tmp ${.TARGET} .endfor .endif