1242711Ssjg# $FreeBSD: stable/10/share/mk/bsd.test.mk 313791 2017-02-16 05:17:40Z ngie $ 2259962Sjmmv# 3259962Sjmmv# Generic build infrastructure for test programs. 4259962Sjmmv# 5264483Sjmmv# This is the only public file that should be included by Makefiles when 6264483Sjmmv# tests are to be built. All other *.test.mk files are internal and not 7264483Sjmmv# to be included directly. 8242711Ssjg 9242711Ssjg.include <bsd.init.mk> 10242711Ssjg 11264483Sjmmv__<bsd.test.mk>__: 12242711Ssjg 13292812Sngie# Third-party software (kyua, etc) prefix. 14292812SngieLOCALBASE?= /usr/local 15292812Sngie 16292278Sngie# Tests install directory 17292278SngieTESTSDIR?= ${TESTSBASE}/${RELDIR:H} 18292278Sngie 19259962Sjmmv# List of subdirectories containing tests into which to recurse. This has the 20259962Sjmmv# same semantics as SUBDIR at build-time. However, the directories listed here 21259962Sjmmv# get registered into the run-time test suite definitions so that the test 22259962Sjmmv# engines know to recurse into these directories. 23259962Sjmmv# 24259962Sjmmv# In other words: list here any directories that contain test programs but use 25259962Sjmmv# SUBDIR for directories that may contain helper binaries and/or data files. 26259962SjmmvTESTS_SUBDIRS?= 27259962Sjmmv 28264483Sjmmv# If defined, indicates that the tests built by the Makefile are not part of 29264483Sjmmv# the FreeBSD Test Suite. The implication of this is that the tests won't be 30264483Sjmmv# installed under /usr/tests/ and that Kyua won't be able to run them. 31264483Sjmmv#NOT_FOR_TEST_SUITE= 32259962Sjmmv 33259962Sjmmv# List of variables to pass to the tests at run-time via the environment. 34259962SjmmvTESTS_ENV?= 35259962Sjmmv 36270187Sian# Force all tests in a separate distribution file. 37270187Sian# 38270187Sian# We want this to be the case even when the distribution name is already 39270187Sian# overriden. For example: we want the tests for programs in the 'games' 40270187Sian# distribution to end up in the 'tests' distribution; the test programs 41270187Sian# themselves have all the necessary logic to detect that the games are not 42270187Sian# installed and thus won't cause false negatives. 43270187SianDISTRIBUTION:= tests 44270187Sian 45259962Sjmmv# Ordered list of directories to construct the PATH for the tests. 46259962SjmmvTESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \ 47259962Sjmmv ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin 48289050Sbdrewery.if defined(.PARSEDIR) 49259962SjmmvTESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g} 50289050Sbdrewery.else 51289050SbdreweryTESTS_ENV+= PATH=${TESTS_PATH:N :Q:S,\\ ,:,g} 52289050Sbdrewery.endif 53259962Sjmmv 54259962Sjmmv# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests. 55259962SjmmvTESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib 56289050Sbdrewery.if defined(.PARSEDIR) 57259962SjmmvTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g} 58289050Sbdrewery.else 59289050SbdreweryTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:N :Q:S,\\ ,:,g} 60289050Sbdrewery.endif 61259962Sjmmv 62264483Sjmmv# List of all tests being built. The various *.test.mk modules extend this 63264483Sjmmv# variable as needed. 64264483Sjmmv_TESTS= 65259962Sjmmv 66264483Sjmmv# Pull in the definitions of all supported test interfaces. 67264483Sjmmv.include <atf.test.mk> 68264483Sjmmv.include <plain.test.mk> 69264483Sjmmv.include <tap.test.mk> 70259962Sjmmv 71313790Sngie# kyua automatically descends directories; only run make check on the 72313790Sngie# top-level directory 73313790Sngie.if !make(check) 74276050Sngie.for ts in ${TESTS_SUBDIRS} 75276050Sngie.if empty(SUBDIR:M${ts}) 76276050SngieSUBDIR+= ${ts} 77242711Ssjg.endif 78276050Sngie.endfor 79313791SngieSUBDIR_PARALLEL= t 80313790Sngie.endif 81242711Ssjg 82242711Ssjg# it is rare for test cases to have man pages 83242711Ssjg.if !defined(MAN) 84276486SngieMAN= 85242711Ssjg.endif 86242711Ssjg 87264483Sjmmv.if !defined(NOT_FOR_TEST_SUITE) 88264483Sjmmv.include <suite.test.mk> 89242711Ssjg.endif 90242711Ssjg 91313790Sngie.if !target(realcheck) 92313790Sngierealcheck: .PHONY 93242711Ssjg @echo "$@ not defined; skipping" 94242711Ssjg.endif 95242711Ssjg 96313790Sngiebeforecheck realcheck aftercheck check: .PHONY 97313790Sngie.ORDER: beforecheck realcheck aftercheck 98313790Sngiecheck: beforecheck realcheck aftercheck 99242711Ssjg 100259962Sjmmv.include <bsd.progs.mk> 101