]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - share/mk/bsd.test.mk
MFC r291892:
[FreeBSD/stable/10.git] / share / mk / bsd.test.mk
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 # Tests install directory
14 TESTSDIR?=      ${TESTSBASE}/${RELDIR:H}
15
16 # List of subdirectories containing tests into which to recurse.  This has the
17 # same semantics as SUBDIR at build-time.  However, the directories listed here
18 # get registered into the run-time test suite definitions so that the test
19 # engines know to recurse into these directories.
20 #
21 # In other words: list here any directories that contain test programs but use
22 # SUBDIR for directories that may contain helper binaries and/or data files.
23 TESTS_SUBDIRS?=
24
25 # If defined, indicates that the tests built by the Makefile are not part of
26 # the FreeBSD Test Suite.  The implication of this is that the tests won't be
27 # installed under /usr/tests/ and that Kyua won't be able to run them.
28 #NOT_FOR_TEST_SUITE=
29
30 # List of variables to pass to the tests at run-time via the environment.
31 TESTS_ENV?=
32
33 # Force all tests in a separate distribution file.
34 #
35 # We want this to be the case even when the distribution name is already
36 # overriden.  For example: we want the tests for programs in the 'games'
37 # distribution to end up in the 'tests' distribution; the test programs
38 # themselves have all the necessary logic to detect that the games are not
39 # installed and thus won't cause false negatives.
40 DISTRIBUTION:=  tests
41
42 # Ordered list of directories to construct the PATH for the tests.
43 TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
44              ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
45 .if defined(.PARSEDIR)
46 TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
47 .else
48 TESTS_ENV+= PATH=${TESTS_PATH:N :Q:S,\\ ,:,g}
49 .endif
50
51 # Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
52 TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
53 .if defined(.PARSEDIR)
54 TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
55 .else
56 TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:N :Q:S,\\ ,:,g}
57 .endif
58
59 # List of all tests being built.  The various *.test.mk modules extend this
60 # variable as needed.
61 _TESTS=
62
63 # Pull in the definitions of all supported test interfaces.
64 .include <atf.test.mk>
65 .include <plain.test.mk>
66 .include <tap.test.mk>
67
68 .for ts in ${TESTS_SUBDIRS}
69 .if empty(SUBDIR:M${ts})
70 SUBDIR+= ${ts}
71 .endif
72 .endfor
73
74 # it is rare for test cases to have man pages
75 .if !defined(MAN)
76 MAN=
77 .endif
78
79 # tell progs.mk we might want to install things
80 PROG_VARS+= BINDIR
81 PROGS_TARGETS+= install
82
83 .if !defined(NOT_FOR_TEST_SUITE)
84 .include <suite.test.mk>
85 .endif
86
87 .if !target(realtest)
88 realtest: .PHONY
89         @echo "$@ not defined; skipping"
90 .endif
91
92 test: .PHONY
93 .ORDER: beforetest realtest
94 test: beforetest realtest
95
96 .if target(aftertest)
97 .ORDER: realtest aftertest
98 test: aftertest
99 .endif
100
101 .if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
102 .include <bsd.progs.mk>
103 .endif
104 .include <bsd.files.mk>
105
106 .include <bsd.obj.mk>