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