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