Index: head/share/mk/bsd.test.mk =================================================================== --- head/share/mk/bsd.test.mk (revision 292506) +++ head/share/mk/bsd.test.mk (revision 292507) @@ -1,119 +1,122 @@ # $FreeBSD$ # # Generic build infrastructure for test programs. # # This is the only public file that should be included by Makefiles when # tests are to be built. All other *.test.mk files are internal and not # to be included directly. .include ____: +# Third-party software (kyua, etc) prefix. +LOCALBASE?= /usr/local + # Tests install directory TESTSDIR?= ${TESTSBASE}/${RELDIR:H} # List of subdirectories containing tests into which to recurse. This has the # same semantics as SUBDIR at build-time. However, the directories listed here # get registered into the run-time test suite definitions so that the test # engines know to recurse into these directories. # # In other words: list here any directories that contain test programs but use # SUBDIR for directories that may contain helper binaries and/or data files. TESTS_SUBDIRS?= # If defined, indicates that the tests built by the Makefile are not part of # the FreeBSD Test Suite. The implication of this is that the tests won't be # installed under /usr/tests/ and that Kyua won't be able to run them. #NOT_FOR_TEST_SUITE= # List of variables to pass to the tests at run-time via the environment. TESTS_ENV?= # Force all tests in a separate distribution file. # # We want this to be the case even when the distribution name is already # overriden. For example: we want the tests for programs in the 'games' # distribution to end up in the 'tests' distribution; the test programs # themselves have all the necessary logic to detect that the games are not # installed and thus won't cause false negatives. DISTRIBUTION:= tests # Ordered list of directories to construct the PATH for the tests. TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \ ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g} # Ordered list of directories to construct the LD_LIBRARY_PATH for the tests. TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g} # List of all tests being built. The various *.test.mk modules extend this # variable as needed. _TESTS= # Pull in the definitions of all supported test interfaces. .include .include .include .for ts in ${TESTS_SUBDIRS} .if empty(SUBDIR:M${ts}) SUBDIR+= ${ts} .endif .endfor # it is rare for test cases to have man pages .if !defined(MAN) MAN= .endif # tell progs.mk we might want to install things PROG_VARS+= BINDIR PROGS_TARGETS+= install .if !defined(NOT_FOR_TEST_SUITE) .include .endif .if !target(realtest) realtest: .PHONY @echo "$@ not defined; skipping" .endif test: .PHONY .ORDER: beforetest realtest test: beforetest realtest .if target(aftertest) .ORDER: realtest aftertest test: aftertest .endif .ifdef PROG # we came here via bsd.progs.mk below # parent will do staging. MK_STAGING= no .endif .if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) .include .endif .include .if !defined(PROG) && ${MK_STAGING} != "no" .if !defined(_SKIP_BUILD) # this will handle staging if needed _SKIP_STAGING= no # but we don't want it to build anything _SKIP_BUILD= .endif .if !empty(PROGS) stage_files.prog: ${PROGS} .endif .include .endif .if !target(objwarn) .include .endif Index: head/share/mk/suite.test.mk =================================================================== --- head/share/mk/suite.test.mk (revision 292506) +++ head/share/mk/suite.test.mk (revision 292507) @@ -1,130 +1,123 @@ # $FreeBSD$ # # You must include bsd.test.mk instead of this file from your Makefile. # # Internal glue for the build of /usr/tests/. .if !target(____) .error suite.test.mk cannot be included directly. .endif # Name of the test suite these tests belong to. Should rarely be changed for # Makefiles built into the FreeBSD src tree. TESTSUITE?= FreeBSD # Knob to control the handling of the Kyuafile for this Makefile. # # If 'yes', a Kyuafile exists in the source tree and is installed into # TESTSDIR. # # If 'auto', a Kyuafile 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 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.= interface-name # Metadata properties applicable to all test programs. # # All the variables for a test program defined in the Makefile are appended # to the test 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+= key="value" # Per-test program metadata properties as a list of key/value pairs. # # These per-test program settings _extend_ the values provided in the # unqualified TEST_METADATA variable. #TEST_METADATA.+= key="value" -# Path to the prefix of the installed Kyua CLI, if any. -# -# If kyua is installed from ports, we automatically define a realtest target -# below to run the tests using this tool. The tools are searched for in the -# hierarchy specified by this variable. -KYUA_PREFIX?= /usr/local - .if ${KYUAFILE:tl} != "no" FILES+= Kyuafile FILESDIR_Kyuafile= ${TESTSDIR} .endif .if ${KYUAFILE:tl} == "auto" CLEANFILES+= Kyuafile Kyuafile.auto.tmp .endif .for _T in ${_TESTS} _TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}} .endfor .if ${KYUAFILE:tl} == "auto" Kyuafile: Makefile @{ \ echo '-- Automatically generated by bsd.test.mk.'; \ echo; \ echo 'syntax(2)'; \ echo; \ echo 'test_suite("${TESTSUITE}")'; \ echo; \ } > ${.TARGET}.tmp .for _T in ${_TESTS} @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ >>${.TARGET}.tmp .endfor .for _T in ${TESTS_SUBDIRS:N.WAIT} @echo "include(\"${_T}/${.TARGET}\")" >>${.TARGET}.tmp .endfor @mv ${.TARGET}.tmp ${.TARGET} .endif -KYUA?= ${KYUA_PREFIX}/bin/kyua +KYUA= ${LOCALBASE}/bin/kyua .if exists(${KYUA}) # 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 Kyua, 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. 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 .if defined(TESTSDIR) .if ${TESTSDIR} == ${TESTSBASE} # 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 Index: head/share/mk/tap.test.mk =================================================================== --- head/share/mk/tap.test.mk (revision 292506) +++ head/share/mk/tap.test.mk (revision 292507) @@ -1,97 +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 +TAP_PERL_INTERPRETER?= ${LOCALBASE}/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