1# $FreeBSD$ 2# 3# You must include bsd.test.mk instead of this file from your Makefile. 4# 5# Logic to build and install ATF test programs; i.e. test programs linked 6# against the ATF libraries. 7 8.if !target(__<bsd.test.mk>__) 9.error atf.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 using PROGS, PROGS_CXX and SCRIPTS, 15# respectively, from bsd.prog.mk. However, the build rules are tweaked to 16# require the ATF libraries. 17# 18# Test programs registered in this manner are set to be installed into TESTSDIR 19# (which should be overriden by the Makefile) and are not required to provide a 20# manpage. 21ATF_TESTS_C?= 22ATF_TESTS_CXX?= 23ATF_TESTS_SH?= 24 25# Path to the prefix of the installed ATF tools, if any. 26# 27# If atf-run and atf-report are installed from ports, we automatically define a 28# realregress target below to run the tests using these tools. The tools are 29# searched for in the hierarchy specified by this variable. 30ATF_PREFIX?= /usr/local 31 32# C compiler passed to ATF tests that need to build code. 33ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc 34TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC} 35 36# C preprocessor passed to ATF tests that need to build code. 37ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp 38TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP} 39 40# C++ compiler passed to ATF tests that need to build code. 41ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++ 42TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX} 43 44# Shell interpreter used to run atf-sh(1) based tests. 45ATF_SHELL?= ${DESTDIR}/bin/sh 46TESTS_ENV+= ATF_SHELL=${ATF_SHELL} 47 48.if !empty(ATF_TESTS_C) 49PROGS+= ${ATF_TESTS_C} 50_TESTS+= ${ATF_TESTS_C} 51.for _T in ${ATF_TESTS_C} 52BINDIR.${_T}= ${TESTSDIR} 53MAN.${_T}?= # empty 54SRCS.${_T}?= ${_T}.c 55DPADD.${_T}+= ${LIBATF_C} 56.if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static) 57LDADD.${_T}+= ${LDADD_atf_c} 58.else 59LDADD.${_T}+= ${LIBATF_C} 60.endif 61TEST_INTERFACE.${_T}= atf 62.endfor 63.endif 64 65.if !empty(ATF_TESTS_CXX) 66PROGS_CXX+= ${ATF_TESTS_CXX} 67_TESTS+= ${ATF_TESTS_CXX} 68.for _T in ${ATF_TESTS_CXX} 69BINDIR.${_T}= ${TESTSDIR} 70MAN.${_T}?= # empty 71SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc} 72DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} 73.if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static) 74LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c} 75.else 76LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} 77.endif 78TEST_INTERFACE.${_T}= atf 79.endfor 80.endif 81 82.if !empty(ATF_TESTS_SH) 83SCRIPTS+= ${ATF_TESTS_SH} 84_TESTS+= ${ATF_TESTS_SH} 85.for _T in ${ATF_TESTS_SH} 86SCRIPTSDIR_${_T}= ${TESTSDIR} 87TEST_INTERFACE.${_T}= atf 88CLEANFILES+= ${_T} ${_T}.tmp 89# TODO(jmmv): It seems to me that this SED and SRC functionality should 90# exist in bsd.prog.mk along the support for SCRIPTS. Move it there if 91# this proves to be useful within the tests. 92ATF_TESTS_SH_SED_${_T}?= # empty 93ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh 94${_T}: ${ATF_TESTS_SH_SRC_${_T}} 95 echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp 96.if empty(ATF_TESTS_SH_SED_${_T}) 97 cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp 98.else 99 cat ${.ALLSRC:N*Makefile*} \ 100 | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp 101.endif 102 chmod +x ${.TARGET}.tmp 103 mv ${.TARGET}.tmp ${.TARGET} 104.endfor 105.endif 106