1# 2# Generic build infrastructure for test programs. 3# 4# This is the only public file that should be included by Makefiles when 5# tests are to be built. All other *.test.mk files are internal and not 6# to be included directly. 7 8.include <bsd.init.mk> 9 10__<bsd.test.mk>__: .NOTMAIN 11 12# Third-party software (kyua, etc) prefix. 13LOCALBASE?= /usr/local 14 15# Tests install directory 16TESTSDIR?= ${TESTSBASE}/${RELDIR:H} 17 18PACKAGE?= tests 19# Prevent creating a -dev package for tests. Sometimes tests include static 20# libraries or other artifacts which are not actually "development" files. 21NO_DEV_PACKAGE= 22 23FILESGROUPS+= ${PACKAGE}FILES 24${PACKAGE}FILESPACKAGE= ${PACKAGE} 25${PACKAGE}FILESDIR= ${TESTSDIR} 26 27# List of subdirectories containing tests into which to recurse. This has the 28# same semantics as SUBDIR at build-time. However, the directories listed here 29# get registered into the run-time test suite definitions so that the test 30# engines know to recurse into these directories. 31# 32# In other words: list here any directories that contain test programs but use 33# SUBDIR for directories that may contain helper binaries and/or data files. 34TESTS_SUBDIRS?= 35 36# If defined, indicates that the tests built by the Makefile are not part of 37# the FreeBSD Test Suite. The implication of this is that the tests won't be 38# installed under /usr/tests/ and that Kyua won't be able to run them. 39#NOT_FOR_TEST_SUITE= 40 41# List of variables to pass to the tests at run-time via the environment. 42TESTS_ENV?= 43 44# Force all tests in a separate distribution file. 45# 46# We want this to be the case even when the distribution name is already 47# overridden. For example: we want the tests for programs in the 'games' 48# distribution to end up in the 'tests' distribution; the test programs 49# themselves have all the necessary logic to detect that the games are not 50# installed and thus won't cause false negatives. 51DISTRIBUTION:= tests 52 53# Ordered list of directories to construct the PATH for the tests. 54TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \ 55 ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin 56TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g} 57 58# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests. 59TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib 60TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g} 61 62# List of all tests being built. The various *.test.mk modules extend this 63# variable as needed. 64_TESTS= 65 66# Pull in the definitions of all supported test interfaces. 67.include <googletest.test.mk> 68.include <plain.test.mk> 69.include <tap.test.mk> 70# Include atf last to let other test framework use it 71.include <atf.test.mk> 72 73# Sort the tests alphabetically, so the results are deterministically formed 74# across runs. 75_TESTS:= ${_TESTS:O} 76 77# kyua automatically descends directories; only run make check on the 78# top-level directory 79.if !make(check) 80.for ts in ${TESTS_SUBDIRS} 81.if empty(SUBDIR:M${ts}) 82SUBDIR+= ${ts} 83.endif 84.endfor 85SUBDIR_PARALLEL= t 86.endif 87 88# it is rare for test cases to have man pages 89.if !defined(MAN) 90MAN= 91.endif 92 93.if !defined(NOT_FOR_TEST_SUITE) 94.include <suite.test.mk> 95.endif 96 97.if ${MK_RUN_TESTS} == "yes" 98# Run tests as part of the build 99.include <host.test.mk> 100.endif 101 102.if !target(realcheck) 103realcheck: .PHONY 104 @echo "$@ not defined; skipping" 105.endif 106 107beforecheck realcheck aftercheck check: .PHONY 108.ORDER: beforecheck realcheck aftercheck 109check: beforecheck realcheck aftercheck 110 111.include <bsd.progs.mk> 112