1242711Ssjg# $FreeBSD$
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
13259962Sjmmv# List of subdirectories containing tests into which to recurse.  This has the
14259962Sjmmv# same semantics as SUBDIR at build-time.  However, the directories listed here
15259962Sjmmv# get registered into the run-time test suite definitions so that the test
16259962Sjmmv# engines know to recurse into these directories.
17259962Sjmmv#
18259962Sjmmv# In other words: list here any directories that contain test programs but use
19259962Sjmmv# SUBDIR for directories that may contain helper binaries and/or data files.
20259962SjmmvTESTS_SUBDIRS?=
21259962Sjmmv
22264483Sjmmv# If defined, indicates that the tests built by the Makefile are not part of
23264483Sjmmv# the FreeBSD Test Suite.  The implication of this is that the tests won't be
24264483Sjmmv# installed under /usr/tests/ and that Kyua won't be able to run them.
25264483Sjmmv#NOT_FOR_TEST_SUITE=
26259962Sjmmv
27259962Sjmmv# List of variables to pass to the tests at run-time via the environment.
28259962SjmmvTESTS_ENV?=
29259962Sjmmv
30270187Sian# Force all tests in a separate distribution file.
31270187Sian#
32270187Sian# We want this to be the case even when the distribution name is already
33270187Sian# overriden.  For example: we want the tests for programs in the 'games'
34270187Sian# distribution to end up in the 'tests' distribution; the test programs
35270187Sian# themselves have all the necessary logic to detect that the games are not
36270187Sian# installed and thus won't cause false negatives.
37270187SianDISTRIBUTION:=	tests
38270187Sian
39259962Sjmmv# Ordered list of directories to construct the PATH for the tests.
40259962SjmmvTESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
41259962Sjmmv             ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
42259962SjmmvTESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
43259962Sjmmv
44259962Sjmmv# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
45259962SjmmvTESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
46259962SjmmvTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
47259962Sjmmv
48264483Sjmmv# List of all tests being built.  The various *.test.mk modules extend this
49264483Sjmmv# variable as needed.
50264483Sjmmv_TESTS=
51259962Sjmmv
52264483Sjmmv# Pull in the definitions of all supported test interfaces.
53264483Sjmmv.include <atf.test.mk>
54264483Sjmmv.include <plain.test.mk>
55264483Sjmmv.include <tap.test.mk>
56259962Sjmmv
57259962Sjmmv.if !empty(TESTS_SUBDIRS)
58259962SjmmvSUBDIR+= ${TESTS_SUBDIRS}
59242711Ssjg.endif
60242711Ssjg
61242711Ssjg# it is rare for test cases to have man pages
62242711Ssjg.if !defined(MAN)
63242711SsjgWITHOUT_MAN=yes
64242711Ssjg.export WITHOUT_MAN
65242711Ssjg.endif
66242711Ssjg
67242711Ssjg# tell progs.mk we might want to install things
68242711SsjgPROG_VARS+= BINDIR
69242711SsjgPROGS_TARGETS+= install
70242711Ssjg
71264483Sjmmv.if !defined(NOT_FOR_TEST_SUITE)
72264483Sjmmv.include <suite.test.mk>
73242711Ssjg.endif
74242711Ssjg
75242711Ssjg.if !target(realtest)
76242711Ssjgrealtest: .PHONY
77242711Ssjg	@echo "$@ not defined; skipping"
78242711Ssjg.endif
79242711Ssjg
80242711Ssjgtest: .PHONY
81242711Ssjg.ORDER: beforetest realtest
82242711Ssjgtest: beforetest realtest
83242711Ssjg
84242711Ssjg.if target(aftertest)
85242711Ssjg.ORDER: realtest aftertest
86242711Ssjgtest: aftertest
87242711Ssjg.endif
88242711Ssjg
89259962Sjmmv.if !empty(SUBDIR)
90259962Sjmmv.include <bsd.subdir.mk>
91259962Sjmmv.endif
92259962Sjmmv
93259962Sjmmv.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
94259962Sjmmv.include <bsd.progs.mk>
95259962Sjmmv.elif !empty(FILES)
96259962Sjmmv.include <bsd.files.mk>
97259962Sjmmv.endif
98259962Sjmmv
99242711Ssjg.include <bsd.obj.mk>
100