1# $NetBSD: bsd.test.mk,v 1.21 2012/08/25 22:21:16 jmmv Exp $ 2# $FreeBSD$ 3 4.include <bsd.init.mk> 5 6.if defined(TESTS_C) 7PROGS+= ${TESTS_C} 8.for _T in ${TESTS_C} 9BINDIR.${_T}= ${TESTSDIR} 10MAN.${_T}?= # empty 11.endfor 12.endif 13 14.if defined(TESTS_CXX) 15PROGS_CXX+= ${TESTS_CXX} 16PROGS+= ${TESTS_CXX} 17.for _T in ${TESTS_CXX} 18BINDIR.${_T}= ${TESTSDIR} 19MAN.${_T}?= # empty 20.endfor 21.endif 22 23.if defined(TESTS_SH) 24SCRIPTS+= ${TESTS_SH} 25.for _T in ${TESTS_SH} 26SCRIPTSDIR_${_T}= ${TESTSDIR} 27.endfor 28.endif 29 30TESTSBASE?= ${DESTDIR}/usr/tests 31 32# it is rare for test cases to have man pages 33.if !defined(MAN) 34WITHOUT_MAN=yes 35.export WITHOUT_MAN 36.endif 37 38# tell progs.mk we might want to install things 39BINDIR = ${TESTSDIR} 40PROGS_TARGETS+= install 41 42.ifdef PROG 43# we came here via bsd.progs.mk below 44# parent will do staging. 45MK_STAGING= no 46.endif 47 48.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) 49.include <bsd.progs.mk> 50.endif 51 52beforetest: .PHONY 53.if defined(TESTSDIR) 54.if ${TESTSDIR} == ${TESTSBASE} 55# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and 56# it does not cover all the tests (e.g. it misses testing software in external). 57 @echo "*** Sorry, you cannot use make test from src/tests. Install the" 58 @echo "*** tests into their final location and run them from ${TESTSBASE}" 59 @false 60.else 61 @echo "*** Using this test does not preclude you from running the tests" 62 @echo "*** installed in ${TESTSBASE}. This test run may raise false" 63 @echo "*** positives and/or false negatives." 64.endif 65.else 66 @echo "*** No TESTSDIR defined; nothing to do." 67 @false 68.endif 69 @echo 70 71.if !target(realtest) 72realtest: .PHONY 73 @echo "$@ not defined; skipping" 74.endif 75 76test: .PHONY 77.ORDER: beforetest realtest 78test: beforetest realtest 79 80.if target(aftertest) 81.ORDER: realtest aftertest 82test: aftertest 83.endif 84 85.if !defined(PROG) && ${MK_STAGING} != "no" 86.if !defined(_SKIP_BUILD) 87# this will handle staging if needed 88_SKIP_STAGING= no 89# but we don't want it to build anything 90_SKIP_BUILD= 91.endif 92.if !empty(PROGS) 93stage_files.prog: ${PROGS} 94.endif 95 96.include <bsd.prog.mk> 97 98.endif 99.if !target(objwarn) 100.include <bsd.obj.mk> 101.endif 102