abb02fa2f9
This mostly fixes an interaction with bsd.test.mk with PROGS and SCRIPTS. This was most notable with 'make clean' and 'make install', which r281055 and r272055 attempted to address but were inadequate. It also addresses similar issues in bsd.progs.mk when not using bsd.test.mk. This also fixes cases of NOT running commands in the parent when using bsd.progs.mk: - 'make clean' was not run for the main process for Makefiles which had both FILES and SUBDIR but no PROGS or SCRIPTS. This usually was just a leftover Kyuafile.auto. One such example is usr.bin/bmake/tests/sysmk/t1/2. - 'make obj' was not running in the current directory with bsd.test.mk due to early inclusion of bsd.subdir.mk. This was not really a problem due to the SUBDIRS using 'mkdir -p' for their objdirs. There were subtle bugs causing this wrong behavior: 1. bsd.progs.mk needs to set SCRIPTS to empty when recursing to avoid the sub-makes from installing, cleaning or building the SCRIPTS; only the parent make should be doing this. r281055 effectively did the same but wasn't enough. 2. CLEANFILES may contain (especially from *.test.mk) files which only the parent should clean, such as from FILES and SCRIPTS. To resolve sub-makes also cleaning these, reset CLEANFILES and CLEANDIRS in the children before including bsd.prog.mk. A tempting alternative would be to only handle CLEANFILES in the parent but then the child bsd.prog.mk CLEANFILES of per-PROGS wouldn't be setup. 3. bsd.subdir.mk was included too soon in bsd.test.mk. It needs to be included after bsd.prog.mk as the SCRIPTS logic is short-circuitted if 'install:' is already defined (which bsd.subdir.mk does). There is actually no need to include bsd.subdir.mk from bsd.test.mk as bsd.prog.mk and bsd.obj.mk will do so in the proper order. The description in r257095 covers this for FILES and was fixed differently, though changing the handling of target(install) in bsd.prog.mk may make sense after more research. 4. bsd.progs.mk had extra logic to handle recursing SCRIPTS if PROGS was empty, which isn't its business to be doing. SCRIPTS is handled fine by bsd.prog.mk. This mostly reverts and reworks the fix in r259209 and partially reverts r272055. 5. bsd.progs.mk has no need to depend 'all:' on SCRIPTS and FILES. These are handled by bsd.prog.mk/bsd.files.mk fine. This also partially reverts r272055. 6. bsd.progs.mk was not drop-in safe for bsd.prog.mk. Move the PROGS check from r273186 to allow it to be used safely. Specific tested cases: SCRIPTS:no PROGS:no FILES:yes SUBDIR:yes usr.bin/bmake/tests/sysmk/t1/2 SCRIPTS:yes PROGS:no FILES:yes SUBDIR:no usr.bin/bmake/tests/sysmk/t1/2/1 SCRIPTS:yes PROGS:yes FILES:yes SUBDIR:yes lib/libthr/tests SCRIPTS:yes PROGS:no FILES:yes SUBDIR:no usr.bin/yacc/tests libexec/atf/atf-sh/tests A full buildworld/installworld/clean comparison with mtree was also done. The only relevant difference was the new fixed behavior of removing Kyuafile.auto from the objdir in 'clean'. Converting SCRIPTS to be a special case FILES group will make this less fragile and is being explored. One known remaining issue is 'cleandepend' removing the tags files for every recursive call. Note that the 'make clean' command runs for the CURDIR last, which can make it appear to run multiple times when cleaning in tests/, but each command is for a SUBDIR returning up the chain. This is purely bsd.subdir.mk behavior. PR: 191055 PR: 191955 MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division
121 lines
3.2 KiB
Makefile
121 lines
3.2 KiB
Makefile
# $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 <bsd.init.mk>
|
|
|
|
__<bsd.test.mk>__:
|
|
|
|
.ifndef TESTSDIR
|
|
.error "Please define TESTSDIR when including bsd.test.mk"
|
|
.endif
|
|
|
|
# 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 <atf.test.mk>
|
|
.include <plain.test.mk>
|
|
.include <tap.test.mk>
|
|
|
|
.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 <suite.test.mk>
|
|
.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 <bsd.progs.mk>
|
|
.endif
|
|
.include <bsd.files.mk>
|
|
|
|
.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 <bsd.prog.mk>
|
|
.endif
|
|
|
|
.if !target(objwarn)
|
|
.include <bsd.obj.mk>
|
|
.endif
|