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