1# 2# You must include bsd.test.mk instead of this file from your Makefile. 3# 4# Logic to build and install plain test programs. A plain test programs it not 5# supposed to use any specific testing framework: all it does is run some code 6# and report the test's pass or fail status via a 0 or 1 exit code. 7 8.if !target(__<bsd.test.mk>__) 9.error plain.test.mk cannot be included directly. 10.endif 11 12# List of C, C++ and shell test programs to build. 13# 14# Programs listed here are built according to the semantics of bsd.prog.mk for 15# PROGS, PROGS_CXX and SCRIPTS, respectively. 16# 17# Test programs registered in this manner are set to be installed into TESTSDIR 18# (which should be overridden by the Makefile) and are not required to provide a 19# manpage. 20PLAIN_TESTS_C?= 21PLAIN_TESTS_CXX?= 22PLAIN_TESTS_SH?= 23 24.if !empty(PLAIN_TESTS_C) 25PROGS+= ${PLAIN_TESTS_C} 26_TESTS+= ${PLAIN_TESTS_C} 27.for _T in ${PLAIN_TESTS_C} 28BINDIR.${_T}= ${TESTSDIR} 29MAN.${_T}?= # empty 30SRCS.${_T}?= ${_T}.c 31TEST_INTERFACE.${_T}= plain 32.endfor 33.endif 34 35.if !empty(PLAIN_TESTS_CXX) 36PROGS_CXX+= ${PLAIN_TESTS_CXX} 37_TESTS+= ${PLAIN_TESTS_CXX} 38.for _T in ${PLAIN_TESTS_CXX} 39BINDIR.${_T}= ${TESTSDIR} 40MAN.${_T}?= # empty 41SRCS.${_T}?= ${_T}.cc 42TEST_INTERFACE.${_T}= plain 43.endfor 44.endif 45 46.if !empty(PLAIN_TESTS_PORCH) 47SCRIPTS+= ${PLAIN_TESTS_PORCH:S/$/.orch/} 48_TESTS+= ${PLAIN_TESTS_PORCH} 49.for _T in ${PLAIN_TESTS_PORCH} 50SCRIPTSDIR_${_T}.orch= ${TESTSDIR} 51 52TEST_INTERFACE.${_T}= plain 53TEST_METADATA.${_T}+= required_programs="porch" 54.endfor 55.endif 56 57.if !empty(PLAIN_TESTS_SH) 58SCRIPTS+= ${PLAIN_TESTS_SH} 59_TESTS+= ${PLAIN_TESTS_SH} 60.for _T in ${PLAIN_TESTS_SH} 61SCRIPTSDIR_${_T}= ${TESTSDIR} 62TEST_INTERFACE.${_T}= plain 63CLEANFILES+= ${_T} ${_T}.tmp 64# TODO(jmmv): It seems to me that this SED and SRC functionality should 65# exist in bsd.prog.mk along the support for SCRIPTS. Move it there if 66# this proves to be useful within the tests. 67PLAIN_TESTS_SH_SED_${_T}?= # empty 68PLAIN_TESTS_SH_SRC_${_T}?= ${_T}.sh 69${_T}: ${PLAIN_TESTS_SH_SRC_${_T}} 70.if empty(PLAIN_TESTS_SH_SED_${_T}) 71 cat ${.ALLSRC:N*Makefile*} >${.TARGET}.tmp 72.else 73 cat ${.ALLSRC:N*Makefile*} \ 74 | sed ${PLAIN_TESTS_SH_SED_${_T}} >${.TARGET}.tmp 75.endif 76 chmod +x ${.TARGET}.tmp 77 mv ${.TARGET}.tmp ${.TARGET} 78.endfor 79.endif 80