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