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} 18c4af37bbSEnji Cooper 19d4a14c85SRui Paulo# List of subdirectories containing tests into which to recurse. This has the 20d4a14c85SRui Paulo# same semantics as SUBDIR at build-time. However, the directories listed here 21d4a14c85SRui Paulo# get registered into the run-time test suite definitions so that the test 22d4a14c85SRui Paulo# engines know to recurse into these directories. 23d4a14c85SRui Paulo# 24d4a14c85SRui Paulo# In other words: list here any directories that contain test programs but use 25d4a14c85SRui Paulo# SUBDIR for directories that may contain helper binaries and/or data files. 26d4a14c85SRui PauloTESTS_SUBDIRS?= 2750c5d27bSSimon J. Gerraty 28a784098cSJulio Merino# If defined, indicates that the tests built by the Makefile are not part of 29a784098cSJulio Merino# the FreeBSD Test Suite. The implication of this is that the tests won't be 30a784098cSJulio Merino# installed under /usr/tests/ and that Kyua won't be able to run them. 31a784098cSJulio Merino#NOT_FOR_TEST_SUITE= 3250c5d27bSSimon J. Gerraty 3330cc088dSRui Paulo# List of variables to pass to the tests at run-time via the environment. 3430cc088dSRui PauloTESTS_ENV?= 3530cc088dSRui Paulo 36e8a34402SJulio Merino# Force all tests in a separate distribution file. 37e8a34402SJulio Merino# 38e8a34402SJulio Merino# We want this to be the case even when the distribution name is already 39e8a34402SJulio Merino# overriden. For example: we want the tests for programs in the 'games' 40e8a34402SJulio Merino# distribution to end up in the 'tests' distribution; the test programs 41e8a34402SJulio Merino# themselves have all the necessary logic to detect that the games are not 42e8a34402SJulio Merino# installed and thus won't cause false negatives. 43e8a34402SJulio MerinoDISTRIBUTION:= tests 44e8a34402SJulio Merino 4530cc088dSRui Paulo# Ordered list of directories to construct the PATH for the tests. 4630cc088dSRui PauloTESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \ 4730cc088dSRui Paulo ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin 4830cc088dSRui PauloTESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g} 4930cc088dSRui Paulo 5030cc088dSRui Paulo# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests. 5130cc088dSRui PauloTESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib 5230cc088dSRui PauloTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g} 5330cc088dSRui Paulo 54f5fd950eSJulio Merino# List of all tests being built. The various *.test.mk modules extend this 55f5fd950eSJulio Merino# variable as needed. 56f5fd950eSJulio Merino_TESTS= 57f5fd950eSJulio Merino 58f5fd950eSJulio Merino# Pull in the definitions of all supported test interfaces. 59f5fd950eSJulio Merino.include <atf.test.mk> 60f5fd950eSJulio Merino.include <plain.test.mk> 61f5fd950eSJulio Merino.include <tap.test.mk> 62f5fd950eSJulio Merino 63*71b7fa12SEnji Cooper# kyua automatically descends directories; only run make check on the 64*71b7fa12SEnji Cooper# top-level directory 65*71b7fa12SEnji Cooper.if !make(check) 669aa97389SEnji Cooper.for ts in ${TESTS_SUBDIRS} 6705f0ff5aSEnji Cooper.if empty(SUBDIR:M${ts}) 689aa97389SEnji CooperSUBDIR+= ${ts} 69d4a14c85SRui Paulo.endif 709aa97389SEnji Cooper.endfor 71*71b7fa12SEnji Cooper.endif 7250c5d27bSSimon J. Gerraty 7350c5d27bSSimon J. Gerraty# it is rare for test cases to have man pages 7450c5d27bSSimon J. Gerraty.if !defined(MAN) 75c115b818SWarner LoshMAN= 7650c5d27bSSimon J. Gerraty.endif 7750c5d27bSSimon J. Gerraty 7850c5d27bSSimon J. Gerraty# tell progs.mk we might want to install things 7950c5d27bSSimon J. GerratyPROG_VARS+= BINDIR 8050c5d27bSSimon J. GerratyPROGS_TARGETS+= install 8150c5d27bSSimon J. Gerraty 82a784098cSJulio Merino.if !defined(NOT_FOR_TEST_SUITE) 83a784098cSJulio Merino.include <suite.test.mk> 846f5639e3SSimon J. Gerraty.endif 856f5639e3SSimon J. Gerraty 86*71b7fa12SEnji Cooper.if !target(realcheck) 87*71b7fa12SEnji Cooperrealcheck: .PHONY 8850c5d27bSSimon J. Gerraty @echo "$@ not defined; skipping" 8950c5d27bSSimon J. Gerraty.endif 9050c5d27bSSimon J. Gerraty 91*71b7fa12SEnji Cooperbeforecheck realcheck aftercheck check: .PHONY 92*71b7fa12SEnji Cooper.ORDER: beforecheck realcheck aftercheck 93*71b7fa12SEnji Coopercheck: beforecheck realcheck aftercheck 9450c5d27bSSimon J. Gerraty 953b8f0845SSimon J. Gerraty.ifdef PROG 963b8f0845SSimon J. Gerraty# we came here via bsd.progs.mk below 973b8f0845SSimon J. Gerraty# parent will do staging. 983b8f0845SSimon J. GerratyMK_STAGING= no 993b8f0845SSimon J. Gerraty.endif 1003b8f0845SSimon J. Gerraty 101d4a14c85SRui Paulo.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) 102d4a14c85SRui Paulo.include <bsd.progs.mk> 103d4a14c85SRui Paulo.endif 104ada17d7bSJulio Merino.include <bsd.files.mk> 105d4a14c85SRui Paulo 1066f5639e3SSimon J. Gerraty.if !defined(PROG) && ${MK_STAGING} != "no" 1076f5639e3SSimon J. Gerraty.if !defined(_SKIP_BUILD) 1086f5639e3SSimon J. Gerraty# this will handle staging if needed 1096f5639e3SSimon J. Gerraty_SKIP_STAGING= no 1106f5639e3SSimon J. Gerraty# but we don't want it to build anything 1116f5639e3SSimon J. Gerraty_SKIP_BUILD= 1126f5639e3SSimon J. Gerraty.endif 1136f5639e3SSimon J. Gerraty.if !empty(PROGS) 1146f5639e3SSimon J. Gerratystage_files.prog: ${PROGS} 1156f5639e3SSimon J. Gerraty.endif 1166f5639e3SSimon J. Gerraty.include <bsd.prog.mk> 1176f5639e3SSimon J. Gerraty.endif 1183b8f0845SSimon J. Gerraty 1196f5639e3SSimon J. Gerraty.if !target(objwarn) 12050c5d27bSSimon J. Gerraty.include <bsd.obj.mk> 1216f5639e3SSimon J. Gerraty.endif 122