xref: /freebsd/share/mk/bsd.test.mk (revision c115b8184e271efe4b570223da6156cb3b32dc23)
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>__:
12f5fd950eSJulio Merino
13d4a14c85SRui Paulo# List of subdirectories containing tests into which to recurse.  This has the
14d4a14c85SRui Paulo# same semantics as SUBDIR at build-time.  However, the directories listed here
15d4a14c85SRui Paulo# get registered into the run-time test suite definitions so that the test
16d4a14c85SRui Paulo# engines know to recurse into these directories.
17d4a14c85SRui Paulo#
18d4a14c85SRui Paulo# In other words: list here any directories that contain test programs but use
19d4a14c85SRui Paulo# SUBDIR for directories that may contain helper binaries and/or data files.
20d4a14c85SRui PauloTESTS_SUBDIRS?=
2150c5d27bSSimon J. Gerraty
22a784098cSJulio Merino# If defined, indicates that the tests built by the Makefile are not part of
23a784098cSJulio Merino# the FreeBSD Test Suite.  The implication of this is that the tests won't be
24a784098cSJulio Merino# installed under /usr/tests/ and that Kyua won't be able to run them.
25a784098cSJulio Merino#NOT_FOR_TEST_SUITE=
268c465f58SJulio Merino
2730cc088dSRui Paulo# List of variables to pass to the tests at run-time via the environment.
2830cc088dSRui PauloTESTS_ENV?=
2930cc088dSRui Paulo
3030cc088dSRui Paulo# Ordered list of directories to construct the PATH for the tests.
3130cc088dSRui PauloTESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
3230cc088dSRui Paulo             ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
3330cc088dSRui PauloTESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
3430cc088dSRui Paulo
3530cc088dSRui Paulo# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
3630cc088dSRui PauloTESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
3730cc088dSRui PauloTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
3830cc088dSRui Paulo
39f5fd950eSJulio Merino# List of all tests being built.  The various *.test.mk modules extend this
40f5fd950eSJulio Merino# variable as needed.
41f5fd950eSJulio Merino_TESTS=
42f5fd950eSJulio Merino
43f5fd950eSJulio Merino# Pull in the definitions of all supported test interfaces.
44f5fd950eSJulio Merino.include <atf.test.mk>
45f5fd950eSJulio Merino.include <plain.test.mk>
46f5fd950eSJulio Merino.include <tap.test.mk>
47f5fd950eSJulio Merino
48d4a14c85SRui Paulo.if !empty(TESTS_SUBDIRS)
49d4a14c85SRui PauloSUBDIR+= ${TESTS_SUBDIRS}
50d4a14c85SRui Paulo.endif
5150c5d27bSSimon J. Gerraty
5250c5d27bSSimon J. Gerraty# it is rare for test cases to have man pages
5350c5d27bSSimon J. Gerraty.if !defined(MAN)
54*c115b818SWarner LoshMAN=
5550c5d27bSSimon J. Gerraty.endif
5650c5d27bSSimon J. Gerraty
5750c5d27bSSimon J. Gerraty# tell progs.mk we might want to install things
5850c5d27bSSimon J. GerratyPROG_VARS+= BINDIR
5950c5d27bSSimon J. GerratyPROGS_TARGETS+= install
6050c5d27bSSimon J. Gerraty
61a784098cSJulio Merino.if !defined(NOT_FOR_TEST_SUITE)
62a784098cSJulio Merino.include <suite.test.mk>
6325b6a535SRui Paulo.endif
6425b6a535SRui Paulo
6550c5d27bSSimon J. Gerraty.if !target(realtest)
6650c5d27bSSimon J. Gerratyrealtest: .PHONY
6750c5d27bSSimon J. Gerraty	@echo "$@ not defined; skipping"
6850c5d27bSSimon J. Gerraty.endif
6950c5d27bSSimon J. Gerraty
7050c5d27bSSimon J. Gerratytest: .PHONY
7150c5d27bSSimon J. Gerraty.ORDER: beforetest realtest
7250c5d27bSSimon J. Gerratytest: beforetest realtest
7350c5d27bSSimon J. Gerraty
7450c5d27bSSimon J. Gerraty.if target(aftertest)
7550c5d27bSSimon J. Gerraty.ORDER: realtest aftertest
7650c5d27bSSimon J. Gerratytest: aftertest
7750c5d27bSSimon J. Gerraty.endif
7850c5d27bSSimon J. Gerraty
79d4a14c85SRui Paulo.if !empty(SUBDIR)
80d4a14c85SRui Paulo.include <bsd.subdir.mk>
81d4a14c85SRui Paulo.endif
82d4a14c85SRui Paulo
83d4a14c85SRui Paulo.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
84d4a14c85SRui Paulo.include <bsd.progs.mk>
8526ea29afSRui Paulo.elif !empty(FILES)
8626ea29afSRui Paulo.include <bsd.files.mk>
87d4a14c85SRui Paulo.endif
88d4a14c85SRui Paulo
8950c5d27bSSimon J. Gerraty.include <bsd.obj.mk>
90