1# $FreeBSD$ 2# 3# Generic build infrastructure for test programs. 4# 5# This is the only public file that should be included by Makefiles when 6# tests are to be built. All other *.test.mk files are internal and not 7# to be included directly. 8 9.include <bsd.init.mk> 10 11__<bsd.test.mk>__: 12 13.ifndef TESTSDIR 14.error "Please define TESTSDIR when including bsd.test.mk" 15.endif 16 17# List of subdirectories containing tests into which to recurse. This has the 18# same semantics as SUBDIR at build-time. However, the directories listed here 19# get registered into the run-time test suite definitions so that the test 20# engines know to recurse into these directories. 21# 22# In other words: list here any directories that contain test programs but use 23# SUBDIR for directories that may contain helper binaries and/or data files. 24TESTS_SUBDIRS?= 25 26# If defined, indicates that the tests built by the Makefile are not part of 27# the FreeBSD Test Suite. The implication of this is that the tests won't be 28# installed under /usr/tests/ and that Kyua won't be able to run them. 29#NOT_FOR_TEST_SUITE= 30 31# List of variables to pass to the tests at run-time via the environment. 32TESTS_ENV?= 33 34# Force all tests in a separate distribution file. 35# 36# We want this to be the case even when the distribution name is already 37# overriden. For example: we want the tests for programs in the 'games' 38# distribution to end up in the 'tests' distribution; the test programs 39# themselves have all the necessary logic to detect that the games are not 40# installed and thus won't cause false negatives. 41DISTRIBUTION:= tests 42 43# Ordered list of directories to construct the PATH for the tests. 44TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \ 45 ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin 46TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g} 47 48# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests. 49TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib 50TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g} 51 52# List of all tests being built. The various *.test.mk modules extend this 53# variable as needed. 54_TESTS= 55 56# Pull in the definitions of all supported test interfaces. 57.include <atf.test.mk> 58.include <plain.test.mk> 59.include <tap.test.mk> 60 61.for ts in ${TESTS_SUBDIRS} 62.if empty(SUBDIR:M${ts}) 63SUBDIR+= ${ts} 64.endif 65.endfor 66 67# it is rare for test cases to have man pages 68.if !defined(MAN) 69MAN= 70.endif 71 72# tell progs.mk we might want to install things 73PROG_VARS+= BINDIR 74PROGS_TARGETS+= install 75 76.if !defined(NOT_FOR_TEST_SUITE) 77.include <suite.test.mk> 78.endif 79 80.if !target(realtest) 81realtest: .PHONY 82 @echo "$@ not defined; skipping" 83.endif 84 85test: .PHONY 86.ORDER: beforetest realtest 87test: beforetest realtest 88 89.if target(aftertest) 90.ORDER: realtest aftertest 91test: aftertest 92.endif 93 94.ifdef PROG 95# we came here via bsd.progs.mk below 96# parent will do staging. 97MK_STAGING= no 98.endif 99 100.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) 101.include <bsd.progs.mk> 102.endif 103.include <bsd.files.mk> 104 105.if !defined(PROG) && ${MK_STAGING} != "no" 106.if !defined(_SKIP_BUILD) 107# this will handle staging if needed 108_SKIP_STAGING= no 109# but we don't want it to build anything 110_SKIP_BUILD= 111.endif 112.if !empty(PROGS) 113stage_files.prog: ${PROGS} 114.endif 115.include <bsd.prog.mk> 116.endif 117 118.if !target(objwarn) 119.include <bsd.obj.mk> 120.endif 121