xref: /freebsd/share/mk/bsd.test.mk (revision f324fafcc57abc425653675bf6eac53fb061339e)
150c5d27bSSimon J. Gerraty# $FreeBSD$
2d4a14c85SRui Paulo#
3d4a14c85SRui Paulo# Generic build infrastructure for test programs.
4d4a14c85SRui Paulo#
5f5fd950eSJulio Merino# This is the only public file that should be included by Makefiles when
6f5fd950eSJulio Merino# tests are to be built.  All other *.test.mk files are internal and not
7f5fd950eSJulio Merino# to be included directly.
850c5d27bSSimon J. Gerraty
950c5d27bSSimon J. Gerraty.include <bsd.init.mk>
1050c5d27bSSimon J. Gerraty
11f5fd950eSJulio Merino__<bsd.test.mk>__:
1250c5d27bSSimon J. Gerraty
1326dfa135SEnji Cooper# Third-party software (kyua, etc) prefix.
1426dfa135SEnji CooperLOCALBASE?=	/usr/local
1526dfa135SEnji Cooper
16da3110edSEnji Cooper# Tests install directory
17da3110edSEnji CooperTESTSDIR?=	${TESTSBASE}/${RELDIR:H}
18430f7286SEnji Cooper
19430f7286SEnji CooperPACKAGE?=	tests
20430f7286SEnji Cooper
21430f7286SEnji CooperFILESGROUPS+=	${PACKAGE}FILES
22430f7286SEnji Cooper${PACKAGE}FILESPACKAGE=	${PACKAGE}
23430f7286SEnji Cooper${PACKAGE}FILESDIR=	${TESTSDIR}
24c4af37bbSEnji Cooper
25d4a14c85SRui Paulo# List of subdirectories containing tests into which to recurse.  This has the
26d4a14c85SRui Paulo# same semantics as SUBDIR at build-time.  However, the directories listed here
27d4a14c85SRui Paulo# get registered into the run-time test suite definitions so that the test
28d4a14c85SRui Paulo# engines know to recurse into these directories.
29d4a14c85SRui Paulo#
30d4a14c85SRui Paulo# In other words: list here any directories that contain test programs but use
31d4a14c85SRui Paulo# SUBDIR for directories that may contain helper binaries and/or data files.
32d4a14c85SRui PauloTESTS_SUBDIRS?=
3350c5d27bSSimon J. Gerraty
34a784098cSJulio Merino# If defined, indicates that the tests built by the Makefile are not part of
35a784098cSJulio Merino# the FreeBSD Test Suite.  The implication of this is that the tests won't be
36a784098cSJulio Merino# installed under /usr/tests/ and that Kyua won't be able to run them.
37a784098cSJulio Merino#NOT_FOR_TEST_SUITE=
3850c5d27bSSimon J. Gerraty
3930cc088dSRui Paulo# List of variables to pass to the tests at run-time via the environment.
4030cc088dSRui PauloTESTS_ENV?=
4130cc088dSRui Paulo
42e8a34402SJulio Merino# Force all tests in a separate distribution file.
43e8a34402SJulio Merino#
44e8a34402SJulio Merino# We want this to be the case even when the distribution name is already
45*f324fafcSEitan Adler# overridden.  For example: we want the tests for programs in the 'games'
46e8a34402SJulio Merino# distribution to end up in the 'tests' distribution; the test programs
47e8a34402SJulio Merino# themselves have all the necessary logic to detect that the games are not
48e8a34402SJulio Merino# installed and thus won't cause false negatives.
49e8a34402SJulio MerinoDISTRIBUTION:=	tests
50e8a34402SJulio Merino
5130cc088dSRui Paulo# Ordered list of directories to construct the PATH for the tests.
5230cc088dSRui PauloTESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
5330cc088dSRui Paulo             ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
5430cc088dSRui PauloTESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
5530cc088dSRui Paulo
5630cc088dSRui Paulo# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
5730cc088dSRui PauloTESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
5830cc088dSRui PauloTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
5930cc088dSRui Paulo
60f5fd950eSJulio Merino# List of all tests being built.  The various *.test.mk modules extend this
61f5fd950eSJulio Merino# variable as needed.
62f5fd950eSJulio Merino_TESTS=
63f5fd950eSJulio Merino
64f5fd950eSJulio Merino# Pull in the definitions of all supported test interfaces.
65f5fd950eSJulio Merino.include <atf.test.mk>
66f5fd950eSJulio Merino.include <plain.test.mk>
67f5fd950eSJulio Merino.include <tap.test.mk>
68f5fd950eSJulio Merino
692474da32SEnji Cooper# Sort the tests alphabetically, so the results are deterministically formed
702474da32SEnji Cooper# across runs.
712474da32SEnji Cooper_TESTS:=	${_TESTS:O}
722474da32SEnji Cooper
7371b7fa12SEnji Cooper# kyua automatically descends directories; only run make check on the
7471b7fa12SEnji Cooper# top-level directory
7571b7fa12SEnji Cooper.if !make(check)
769aa97389SEnji Cooper.for ts in ${TESTS_SUBDIRS}
7705f0ff5aSEnji Cooper.if empty(SUBDIR:M${ts})
789aa97389SEnji CooperSUBDIR+= ${ts}
79d4a14c85SRui Paulo.endif
809aa97389SEnji Cooper.endfor
81d3157f09SBryan DrewerySUBDIR_PARALLEL= t
8271b7fa12SEnji Cooper.endif
8350c5d27bSSimon J. Gerraty
8450c5d27bSSimon J. Gerraty# it is rare for test cases to have man pages
8550c5d27bSSimon J. Gerraty.if !defined(MAN)
86c115b818SWarner LoshMAN=
8750c5d27bSSimon J. Gerraty.endif
8850c5d27bSSimon J. Gerraty
89a784098cSJulio Merino.if !defined(NOT_FOR_TEST_SUITE)
90a784098cSJulio Merino.include <suite.test.mk>
916f5639e3SSimon J. Gerraty.endif
926f5639e3SSimon J. Gerraty
9371b7fa12SEnji Cooper.if !target(realcheck)
9471b7fa12SEnji Cooperrealcheck: .PHONY
9550c5d27bSSimon J. Gerraty	@echo "$@ not defined; skipping"
9650c5d27bSSimon J. Gerraty.endif
9750c5d27bSSimon J. Gerraty
9871b7fa12SEnji Cooperbeforecheck realcheck aftercheck check: .PHONY
9971b7fa12SEnji Cooper.ORDER: beforecheck realcheck aftercheck
10071b7fa12SEnji Coopercheck: beforecheck realcheck aftercheck
10150c5d27bSSimon J. Gerraty
102d4a14c85SRui Paulo.include <bsd.progs.mk>
103