xref: /freebsd/share/mk/bsd.test.mk (revision 38f0b757fd84d17d0fc24739a7cda160c4516d81)
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# List of subdirectories containing tests into which to recurse.  This has the
14# same semantics as SUBDIR at build-time.  However, the directories listed here
15# get registered into the run-time test suite definitions so that the test
16# engines know to recurse into these directories.
17#
18# In other words: list here any directories that contain test programs but use
19# SUBDIR for directories that may contain helper binaries and/or data files.
20TESTS_SUBDIRS?=
21
22# If defined, indicates that the tests built by the Makefile are not part of
23# the FreeBSD Test Suite.  The implication of this is that the tests won't be
24# installed under /usr/tests/ and that Kyua won't be able to run them.
25#NOT_FOR_TEST_SUITE=
26
27# List of variables to pass to the tests at run-time via the environment.
28TESTS_ENV?=
29
30# Ordered list of directories to construct the PATH for the tests.
31TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
32             ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
33TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
34
35# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
36TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
37TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
38
39# List of all tests being built.  The various *.test.mk modules extend this
40# variable as needed.
41_TESTS=
42
43# Pull in the definitions of all supported test interfaces.
44.include <atf.test.mk>
45.include <plain.test.mk>
46.include <tap.test.mk>
47
48.if !empty(TESTS_SUBDIRS)
49SUBDIR+= ${TESTS_SUBDIRS}
50.endif
51
52# it is rare for test cases to have man pages
53.if !defined(MAN)
54NO_MAN=yes
55.export NO_MAN
56.endif
57
58# tell progs.mk we might want to install things
59PROG_VARS+= BINDIR
60PROGS_TARGETS+= install
61
62.if !defined(NOT_FOR_TEST_SUITE)
63.include <suite.test.mk>
64.endif
65
66.if !target(realtest)
67realtest: .PHONY
68	@echo "$@ not defined; skipping"
69.endif
70
71test: .PHONY
72.ORDER: beforetest realtest
73test: beforetest realtest
74
75.if target(aftertest)
76.ORDER: realtest aftertest
77test: aftertest
78.endif
79
80.if !empty(SUBDIR)
81.include <bsd.subdir.mk>
82.endif
83
84.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
85.include <bsd.progs.mk>
86.elif !empty(FILES)
87.include <bsd.files.mk>
88.endif
89
90.include <bsd.obj.mk>
91