freebsd-dev/share/mk/atf.test.mk

104 lines
2.6 KiB
Makefile
Raw Normal View History

# $FreeBSD$
#
# Logic to build and install ATF test programs; i.e. test programs linked
# against the ATF libraries.
.include <bsd.init.mk>
# List of C, C++ and shell test programs to build.
#
# Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS,
# respectively, from bsd.prog.mk. However, the build rules are tweaked to
# require the ATF libraries.
#
# Test programs registered in this manner are set to be installed into TESTSDIR
# (which should be overriden by the Makefile) and are not required to provide a
# manpage.
ATF_TESTS_C?=
ATF_TESTS_CXX?=
ATF_TESTS_SH?=
# Whether to allow using the deprecated ATF tools or not.
#
# If 'yes', this file will generate Atffiles when requested and will also
# support using the deprecated atf-run tool to execute the tests.
ALLOW_DEPRECATED_ATF_TOOLS?= no
# Knob to control the handling of the Atffile for this Makefile.
#
# If 'yes', an Atffile exists in the source tree and is installed into
# TESTSDIR.
#
# If 'auto', an Atffile is automatically generated based on the list of test
# programs built by the Makefile and is installed into TESTSDIR. This is the
# default and is sufficient in the majority of the cases.
#
# If 'no', no Atffile is installed.
ATFFILE?= auto
.if !empty(ATF_TESTS_C)
PROGS+= ${ATF_TESTS_C}
.for _T in ${ATF_TESTS_C}
BINDIR.${_T}= ${TESTSDIR}
MAN.${_T}?= # empty
SRCS.${_T}?= ${_T}.c
DPADD.${_T}+= ${LIBATF_C}
LDADD.${_T}+= -latf-c
.endfor
.endif
.if !empty(ATF_TESTS_CXX)
PROGS_CXX+= ${ATF_TESTS_CXX}
PROGS+= ${ATF_TESTS_CXX}
.for _T in ${ATF_TESTS_CXX}
BINDIR.${_T}= ${TESTSDIR}
MAN.${_T}?= # empty
SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
LDADD.${_T}+= -latf-c++ -latf-c
.endfor
.endif
.if !empty(ATF_TESTS_SH)
SCRIPTS+= ${ATF_TESTS_SH}
.for _T in ${ATF_TESTS_SH}
SCRIPTSDIR_${_T}= ${TESTSDIR}
CLEANFILES+= ${_T} ${_T}.tmp
ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
${_T}: ${ATF_TESTS_SH_SRC_${_T}}
echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp
cat ${.ALLSRC} >> ${.TARGET}.tmp
chmod +x ${.TARGET}.tmp
mv ${.TARGET}.tmp ${.TARGET}
.endfor
.endif
.if ${ALLOW_DEPRECATED_ATF_TOOLS} != "no"
.if ${ATFFILE:tl} != "no"
FILES+= Atffile
FILESDIR_Atffile= ${TESTSDIR}
.if ${ATFFILE:tl} == "auto"
CLEANFILES+= Atffile Atffile.tmp
Atffile: Makefile
@{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \
echo; \
echo '# Automatically generated by atf-test.mk.'; \
echo; \
echo 'prop: test-suite = "'${TESTSUITE}'"'; \
echo; \
for tp in ${ATF_TESTS_C} ${ATF_TESTS_CXX} ${ATF_TESTS_SH} \
${TESTS_SUBDIRS}; \
do \
echo "tp: $${tp}"; \
done; } >Atffile.tmp
@mv Atffile.tmp Atffile
.endif
.endif
.endif
.include <bsd.test.mk>