1242711Ssjg# $FreeBSD: releng/10.2/share/mk/bsd.test.mk 276486 2014-12-31 23:25:37Z 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
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
57276050Sngie.for ts in ${TESTS_SUBDIRS}
58276050Sngie.if empty(SUBDIR:M${ts})
59276050SngieSUBDIR+= ${ts}
60242711Ssjg.endif
61276050Sngie.endfor
62242711Ssjg
63242711Ssjg# it is rare for test cases to have man pages
64242711Ssjg.if !defined(MAN)
65276486SngieMAN=
66242711Ssjg.endif
67242711Ssjg
68242711Ssjg# tell progs.mk we might want to install things
69242711SsjgPROG_VARS+= BINDIR
70242711SsjgPROGS_TARGETS+= install
71242711Ssjg
72264483Sjmmv.if !defined(NOT_FOR_TEST_SUITE)
73264483Sjmmv.include <suite.test.mk>
74242711Ssjg.endif
75242711Ssjg
76242711Ssjg.if !target(realtest)
77242711Ssjgrealtest: .PHONY
78242711Ssjg	@echo "$@ not defined; skipping"
79242711Ssjg.endif
80242711Ssjg
81242711Ssjgtest: .PHONY
82242711Ssjg.ORDER: beforetest realtest
83242711Ssjgtest: beforetest realtest
84242711Ssjg
85242711Ssjg.if target(aftertest)
86242711Ssjg.ORDER: realtest aftertest
87242711Ssjgtest: aftertest
88242711Ssjg.endif
89242711Ssjg
90259962Sjmmv.if !empty(SUBDIR)
91259962Sjmmv.include <bsd.subdir.mk>
92259962Sjmmv.endif
93259962Sjmmv
94259962Sjmmv.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
95259962Sjmmv.include <bsd.progs.mk>
96276422Sngie.endif
97259962Sjmmv.include <bsd.files.mk>
98259962Sjmmv
99242711Ssjg.include <bsd.obj.mk>
100