atf.test.mk revision 256763
1# $FreeBSD: head/share/mk/atf.test.mk 256763 2013-10-19 06:50:56Z rpaulo $
2#
3# Logic to build and install ATF test programs; i.e. test programs linked
4# against the ATF libraries.
5
6.include <bsd.init.mk>
7
8# List of C, C++ and shell test programs to build.
9#
10# Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS,
11# respectively, from bsd.prog.mk.  However, the build rules are tweaked to
12# require the ATF libraries.
13#
14# Test programs registered in this manner are set to be installed into TESTSDIR
15# (which should be overriden by the Makefile) and are not required to provide a
16# manpage.
17ATF_TESTS_C?=
18ATF_TESTS_CXX?=
19ATF_TESTS_SH?=
20
21# Whether to allow using the deprecated ATF tools or not.
22#
23# If 'yes', this file will generate Atffiles when requested and will also
24# support using the deprecated atf-run tool to execute the tests.
25ALLOW_DEPRECATED_ATF_TOOLS?= no
26
27# Knob to control the handling of the Atffile for this Makefile.
28#
29# If 'yes', an Atffile exists in the source tree and is installed into
30# TESTSDIR.
31#
32# If 'auto', an Atffile is automatically generated based on the list of test
33# programs built by the Makefile and is installed into TESTSDIR.  This is the
34# default and is sufficient in the majority of the cases.
35#
36# If 'no', no Atffile is installed.
37ATFFILE?= auto
38
39.if !empty(ATF_TESTS_C)
40PROGS+= ${ATF_TESTS_C}
41_TESTS+= ${ATF_TESTS_C}
42.for _T in ${ATF_TESTS_C}
43BINDIR.${_T}= ${TESTSDIR}
44MAN.${_T}?= # empty
45SRCS.${_T}?= ${_T}.c
46DPADD.${_T}+= ${LIBATF_C}
47LDADD.${_T}+= -latf-c
48TEST_INTERFACE.${_T}= atf
49.endfor
50.endif
51
52.if !empty(ATF_TESTS_CXX)
53PROGS_CXX+= ${ATF_TESTS_CXX}
54PROGS+= ${ATF_TESTS_CXX}
55_TESTS+= ${ATF_TESTS_CXX}
56.for _T in ${ATF_TESTS_CXX}
57BINDIR.${_T}= ${TESTSDIR}
58MAN.${_T}?= # empty
59SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
60DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
61LDADD.${_T}+= -latf-c++ -latf-c
62TEST_INTERFACE.${_T}= atf
63.endfor
64.endif
65
66.if !empty(ATF_TESTS_SH)
67SCRIPTS+= ${ATF_TESTS_SH}
68_TESTS+= ${ATF_TESTS_SH}
69.for _T in ${ATF_TESTS_SH}
70SCRIPTSDIR_${_T}= ${TESTSDIR}
71TEST_INTERFACE.${_T}= atf
72CLEANFILES+= ${_T} ${_T}.tmp
73ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
74${_T}: ${ATF_TESTS_SH_SRC_${_T}}
75	echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp
76	cat ${.ALLSRC} >> ${.TARGET}.tmp
77	chmod +x ${.TARGET}.tmp
78	mv ${.TARGET}.tmp ${.TARGET}
79.endfor
80.endif
81
82.if ${ALLOW_DEPRECATED_ATF_TOOLS} != "no"
83
84.if ${ATFFILE:tl} != "no"
85FILES+=	Atffile
86FILESDIR_Atffile= ${TESTSDIR}
87
88.if ${ATFFILE:tl} == "auto"
89CLEANFILES+= Atffile Atffile.tmp
90
91Atffile: Makefile
92	@{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \
93	echo; \
94	echo '# Automatically generated by atf-test.mk.'; \
95	echo; \
96	echo 'prop: test-suite = "'${TESTSUITE}'"'; \
97	echo; \
98	for tp in ${ATF_TESTS_C} ${ATF_TESTS_CXX} ${ATF_TESTS_SH} \
99	    ${TESTS_SUBDIRS}; \
100	do \
101	    echo "tp: $${tp}"; \
102	done; } >Atffile.tmp
103	@mv Atffile.tmp Atffile
104.endif
105.endif
106
107.endif
108
109.include <bsd.test.mk>
110