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 13*c4af37bbSEnji Cooper.ifndef TESTSDIR 14*c4af37bbSEnji Cooper.error "Please define TESTSDIR when including bsd.test.mk" 15*c4af37bbSEnji Cooper.endif 16*c4af37bbSEnji Cooper 17d4a14c85SRui Paulo# List of subdirectories containing tests into which to recurse. This has the 18d4a14c85SRui Paulo# same semantics as SUBDIR at build-time. However, the directories listed here 19d4a14c85SRui Paulo# get registered into the run-time test suite definitions so that the test 20d4a14c85SRui Paulo# engines know to recurse into these directories. 21d4a14c85SRui Paulo# 22d4a14c85SRui Paulo# In other words: list here any directories that contain test programs but use 23d4a14c85SRui Paulo# SUBDIR for directories that may contain helper binaries and/or data files. 24d4a14c85SRui PauloTESTS_SUBDIRS?= 2550c5d27bSSimon J. Gerraty 26a784098cSJulio Merino# If defined, indicates that the tests built by the Makefile are not part of 27a784098cSJulio Merino# the FreeBSD Test Suite. The implication of this is that the tests won't be 28a784098cSJulio Merino# installed under /usr/tests/ and that Kyua won't be able to run them. 29a784098cSJulio Merino#NOT_FOR_TEST_SUITE= 3050c5d27bSSimon J. Gerraty 3130cc088dSRui Paulo# List of variables to pass to the tests at run-time via the environment. 3230cc088dSRui PauloTESTS_ENV?= 3330cc088dSRui Paulo 34e8a34402SJulio Merino# Force all tests in a separate distribution file. 35e8a34402SJulio Merino# 36e8a34402SJulio Merino# We want this to be the case even when the distribution name is already 37e8a34402SJulio Merino# overriden. For example: we want the tests for programs in the 'games' 38e8a34402SJulio Merino# distribution to end up in the 'tests' distribution; the test programs 39e8a34402SJulio Merino# themselves have all the necessary logic to detect that the games are not 40e8a34402SJulio Merino# installed and thus won't cause false negatives. 41e8a34402SJulio MerinoDISTRIBUTION:= tests 42e8a34402SJulio Merino 4330cc088dSRui Paulo# Ordered list of directories to construct the PATH for the tests. 4430cc088dSRui PauloTESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \ 4530cc088dSRui Paulo ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin 4630cc088dSRui PauloTESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g} 4730cc088dSRui Paulo 4830cc088dSRui Paulo# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests. 4930cc088dSRui PauloTESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib 5030cc088dSRui PauloTESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g} 5130cc088dSRui Paulo 52f5fd950eSJulio Merino# List of all tests being built. The various *.test.mk modules extend this 53f5fd950eSJulio Merino# variable as needed. 54f5fd950eSJulio Merino_TESTS= 55f5fd950eSJulio Merino 56f5fd950eSJulio Merino# Pull in the definitions of all supported test interfaces. 57f5fd950eSJulio Merino.include <atf.test.mk> 58f5fd950eSJulio Merino.include <plain.test.mk> 59f5fd950eSJulio Merino.include <tap.test.mk> 60f5fd950eSJulio Merino 619aa97389SEnji Cooper.for ts in ${TESTS_SUBDIRS} 6205f0ff5aSEnji Cooper.if empty(SUBDIR:M${ts}) 639aa97389SEnji CooperSUBDIR+= ${ts} 64d4a14c85SRui Paulo.endif 659aa97389SEnji Cooper.endfor 6650c5d27bSSimon J. Gerraty 6750c5d27bSSimon J. Gerraty# it is rare for test cases to have man pages 6850c5d27bSSimon J. Gerraty.if !defined(MAN) 69c115b818SWarner LoshMAN= 7050c5d27bSSimon J. Gerraty.endif 7150c5d27bSSimon J. Gerraty 7250c5d27bSSimon J. Gerraty# tell progs.mk we might want to install things 7350c5d27bSSimon J. GerratyPROG_VARS+= BINDIR 7450c5d27bSSimon J. GerratyPROGS_TARGETS+= install 7550c5d27bSSimon J. Gerraty 76a784098cSJulio Merino.if !defined(NOT_FOR_TEST_SUITE) 77a784098cSJulio Merino.include <suite.test.mk> 786f5639e3SSimon J. Gerraty.endif 796f5639e3SSimon J. Gerraty 8050c5d27bSSimon J. Gerraty.if !target(realtest) 8150c5d27bSSimon J. Gerratyrealtest: .PHONY 8250c5d27bSSimon J. Gerraty @echo "$@ not defined; skipping" 8350c5d27bSSimon J. Gerraty.endif 8450c5d27bSSimon J. Gerraty 8550c5d27bSSimon J. Gerratytest: .PHONY 8650c5d27bSSimon J. Gerraty.ORDER: beforetest realtest 8750c5d27bSSimon J. Gerratytest: beforetest realtest 8850c5d27bSSimon J. Gerraty 8950c5d27bSSimon J. Gerraty.if target(aftertest) 9050c5d27bSSimon J. Gerraty.ORDER: realtest aftertest 9150c5d27bSSimon J. Gerratytest: aftertest 9250c5d27bSSimon J. Gerraty.endif 9350c5d27bSSimon J. Gerraty 94d4a14c85SRui Paulo.if !empty(SUBDIR) 95d4a14c85SRui Paulo.include <bsd.subdir.mk> 96d4a14c85SRui Paulo.endif 97d4a14c85SRui Paulo 983b8f0845SSimon J. Gerraty.ifdef PROG 993b8f0845SSimon J. Gerraty# we came here via bsd.progs.mk below 1003b8f0845SSimon J. Gerraty# parent will do staging. 1013b8f0845SSimon J. GerratyMK_STAGING= no 1023b8f0845SSimon J. Gerraty.endif 1033b8f0845SSimon J. Gerraty 104d4a14c85SRui Paulo.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) 105d4a14c85SRui Paulo.include <bsd.progs.mk> 106d4a14c85SRui Paulo.endif 107ada17d7bSJulio Merino.include <bsd.files.mk> 108d4a14c85SRui Paulo 1096f5639e3SSimon J. Gerraty.if !defined(PROG) && ${MK_STAGING} != "no" 1106f5639e3SSimon J. Gerraty.if !defined(_SKIP_BUILD) 1116f5639e3SSimon J. Gerraty# this will handle staging if needed 1126f5639e3SSimon J. Gerraty_SKIP_STAGING= no 1136f5639e3SSimon J. Gerraty# but we don't want it to build anything 1146f5639e3SSimon J. Gerraty_SKIP_BUILD= 1156f5639e3SSimon J. Gerraty.endif 1166f5639e3SSimon J. Gerraty.if !empty(PROGS) 1176f5639e3SSimon J. Gerratystage_files.prog: ${PROGS} 1186f5639e3SSimon J. Gerraty.endif 1196f5639e3SSimon J. Gerraty.include <bsd.prog.mk> 1206f5639e3SSimon J. Gerraty.endif 1213b8f0845SSimon J. Gerraty 1226f5639e3SSimon J. Gerraty.if !target(objwarn) 12350c5d27bSSimon J. Gerraty.include <bsd.obj.mk> 1246f5639e3SSimon J. Gerraty.endif 125