Deleted Added
full compact
atf.test.mk (259962) atf.test.mk (264483)
1# $FreeBSD: stable/10/share/mk/atf.test.mk 259962 2013-12-27 22:00:22Z jmmv $
1# $FreeBSD: stable/10/share/mk/atf.test.mk 264483 2014-04-14 23:51:57Z jmmv $
2#
2#
3# You must include bsd.test.mk instead of this file from your Makefile.
4#
3# Logic to build and install ATF test programs; i.e. test programs linked
4# against the ATF libraries.
5
5# Logic to build and install ATF test programs; i.e. test programs linked
6# against the ATF libraries.
7
6.include <bsd.init.mk>
8.if !target(__<bsd.test.mk>__)
9.error atf.test.mk cannot be included directly.
10.endif
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# Path to the prefix of the installed ATF tools, if any.
40#
41# If atf-run and atf-report are installed from ports, we automatically define a
42# realtest target below to run the tests using these tools. The tools are
43# searched for in the hierarchy specified by this variable.
44ATF_PREFIX?= /usr/local
45
46# C compiler passed to ATF tests that need to build code.
47ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc
48TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC}
49
50# C preprocessor passed to ATF tests that need to build code.
51ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp
52TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP}
53
54# C++ compiler passed to ATF tests that need to build code.
55ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++
56TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX}
57
58# Shell interpreter used to run atf-sh(1) based tests.
59ATF_SHELL?= ${DESTDIR}/bin/sh
60TESTS_ENV+= ATF_SHELL=${ATF_SHELL}
61
62.if !empty(ATF_TESTS_C)
63PROGS+= ${ATF_TESTS_C}
64_TESTS+= ${ATF_TESTS_C}
65.for _T in ${ATF_TESTS_C}
66BINDIR.${_T}= ${TESTSDIR}
67MAN.${_T}?= # empty
68SRCS.${_T}?= ${_T}.c
69DPADD.${_T}+= ${LIBATF_C}
70LDADD.${_T}+= -latf-c
71TEST_INTERFACE.${_T}= atf
72.endfor
73.endif
74
75.if !empty(ATF_TESTS_CXX)
76PROGS_CXX+= ${ATF_TESTS_CXX}
77_TESTS+= ${ATF_TESTS_CXX}
78.for _T in ${ATF_TESTS_CXX}
79BINDIR.${_T}= ${TESTSDIR}
80MAN.${_T}?= # empty
81SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
82DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
83LDADD.${_T}+= -latf-c++ -latf-c
84TEST_INTERFACE.${_T}= atf
85.endfor
86.endif
87
88.if !empty(ATF_TESTS_SH)
89SCRIPTS+= ${ATF_TESTS_SH}
90_TESTS+= ${ATF_TESTS_SH}
91.for _T in ${ATF_TESTS_SH}
92SCRIPTSDIR_${_T}= ${TESTSDIR}
93TEST_INTERFACE.${_T}= atf
94CLEANFILES+= ${_T} ${_T}.tmp
95ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
96${_T}: ${ATF_TESTS_SH_SRC_${_T}}
97 echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp
98 cat ${.ALLSRC} >> ${.TARGET}.tmp
99 chmod +x ${.TARGET}.tmp
100 mv ${.TARGET}.tmp ${.TARGET}
101.endfor
102.endif
103
104.if ${ALLOW_DEPRECATED_ATF_TOOLS} != "no"
105
106.if ${ATFFILE:tl} != "no"
107FILES+= Atffile
108FILESDIR_Atffile= ${TESTSDIR}
109
110.if ${ATFFILE:tl} == "auto"
111CLEANFILES+= Atffile Atffile.tmp
112
113Atffile: Makefile
114 @{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \
115 echo; \
116 echo '# Automatically generated by atf-test.mk.'; \
117 echo; \
118 echo 'prop: test-suite = "'${TESTSUITE}'"'; \
119 echo; \
120 for tp in ${ATF_TESTS_C} ${ATF_TESTS_CXX} ${ATF_TESTS_SH} \
121 ${TESTS_SUBDIRS}; \
122 do \
123 echo "tp: $${tp}"; \
124 done; } >Atffile.tmp
125 @mv Atffile.tmp Atffile
126.endif
127.endif
128
129ATF_REPORT?= ${ATF_PREFIX}/bin/atf-report
130ATF_RUN?= ${ATF_PREFIX}/bin/atf-run
131.if exists(${ATF_RUN}) && exists(${ATF_REPORT})
132# Definition of the "make test" target and supporting variables.
133#
134# This target, by necessity, can only work for native builds (i.e. a freeBSD
135# host building a release for the same system). The target runs ATF, which is
136# not in the toolchain, and the tests execute code built for the target host.
137#
138# Due to the dependencies of the binaries built by the source tree and how they
139# are used by tests, it is highly possible for a execution of "make test" to
140# report bogus results unless the new binaries are put in place.
141_TESTS_FIFO= ${.OBJDIR}/atf-run.fifo
142_TESTS_LOG= ${.OBJDIR}/atf-run.log
143CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG}
144realtest: .PHONY
145 @set -e; \
146 if [ -z "${TESTSDIR}" ]; then \
147 echo "*** No TESTSDIR defined; nothing to do."; \
148 exit 0; \
149 fi; \
150 cd ${DESTDIR}${TESTSDIR}; \
151 rm -f ${_TESTS_FIFO}; \
152 mkfifo ${_TESTS_FIFO}; \
153 tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \
154 set +e; \
155 ${TESTS_ENV} ${ATF_RUN} >> ${_TESTS_FIFO}; \
156 result=$${?}; \
157 wait; \
158 rm -f ${_TESTS_FIFO}; \
159 echo; \
160 echo "*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \
161 echo "***"; \
162 echo "*** WARNING: atf-run is deprecated; please install kyua instead"; \
163 exit $${result}
164.endif
165
166.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# Whether to allow using the deprecated ATF tools or not.
26#
27# If 'yes', this file will generate Atffiles when requested and will also
28# support using the deprecated atf-run tool to execute the tests.
29ALLOW_DEPRECATED_ATF_TOOLS?= no
30
31# Knob to control the handling of the Atffile for this Makefile.
32#
33# If 'yes', an Atffile exists in the source tree and is installed into
34# TESTSDIR.
35#
36# If 'auto', an Atffile is automatically generated based on the list of test
37# programs built by the Makefile and is installed into TESTSDIR. This is the
38# default and is sufficient in the majority of the cases.
39#
40# If 'no', no Atffile is installed.
41ATFFILE?= auto
42
43# Path to the prefix of the installed ATF tools, if any.
44#
45# If atf-run and atf-report are installed from ports, we automatically define a
46# realtest target below to run the tests using these tools. The tools are
47# searched for in the hierarchy specified by this variable.
48ATF_PREFIX?= /usr/local
49
50# C compiler passed to ATF tests that need to build code.
51ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc
52TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC}
53
54# C preprocessor passed to ATF tests that need to build code.
55ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp
56TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP}
57
58# C++ compiler passed to ATF tests that need to build code.
59ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++
60TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX}
61
62# Shell interpreter used to run atf-sh(1) based tests.
63ATF_SHELL?= ${DESTDIR}/bin/sh
64TESTS_ENV+= ATF_SHELL=${ATF_SHELL}
65
66.if !empty(ATF_TESTS_C)
67PROGS+= ${ATF_TESTS_C}
68_TESTS+= ${ATF_TESTS_C}
69.for _T in ${ATF_TESTS_C}
70BINDIR.${_T}= ${TESTSDIR}
71MAN.${_T}?= # empty
72SRCS.${_T}?= ${_T}.c
73DPADD.${_T}+= ${LIBATF_C}
74LDADD.${_T}+= -latf-c
75TEST_INTERFACE.${_T}= atf
76.endfor
77.endif
78
79.if !empty(ATF_TESTS_CXX)
80PROGS_CXX+= ${ATF_TESTS_CXX}
81_TESTS+= ${ATF_TESTS_CXX}
82.for _T in ${ATF_TESTS_CXX}
83BINDIR.${_T}= ${TESTSDIR}
84MAN.${_T}?= # empty
85SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
86DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
87LDADD.${_T}+= -latf-c++ -latf-c
88TEST_INTERFACE.${_T}= atf
89.endfor
90.endif
91
92.if !empty(ATF_TESTS_SH)
93SCRIPTS+= ${ATF_TESTS_SH}
94_TESTS+= ${ATF_TESTS_SH}
95.for _T in ${ATF_TESTS_SH}
96SCRIPTSDIR_${_T}= ${TESTSDIR}
97TEST_INTERFACE.${_T}= atf
98CLEANFILES+= ${_T} ${_T}.tmp
99ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
100${_T}: ${ATF_TESTS_SH_SRC_${_T}}
101 echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp
102 cat ${.ALLSRC} >> ${.TARGET}.tmp
103 chmod +x ${.TARGET}.tmp
104 mv ${.TARGET}.tmp ${.TARGET}
105.endfor
106.endif
107
108.if ${ALLOW_DEPRECATED_ATF_TOOLS} != "no"
109
110.if ${ATFFILE:tl} != "no"
111FILES+= Atffile
112FILESDIR_Atffile= ${TESTSDIR}
113
114.if ${ATFFILE:tl} == "auto"
115CLEANFILES+= Atffile Atffile.tmp
116
117Atffile: Makefile
118 @{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \
119 echo; \
120 echo '# Automatically generated by atf-test.mk.'; \
121 echo; \
122 echo 'prop: test-suite = "'${TESTSUITE}'"'; \
123 echo; \
124 for tp in ${ATF_TESTS_C} ${ATF_TESTS_CXX} ${ATF_TESTS_SH} \
125 ${TESTS_SUBDIRS}; \
126 do \
127 echo "tp: $${tp}"; \
128 done; } >Atffile.tmp
129 @mv Atffile.tmp Atffile
130.endif
131.endif
132
133ATF_REPORT?= ${ATF_PREFIX}/bin/atf-report
134ATF_RUN?= ${ATF_PREFIX}/bin/atf-run
135.if exists(${ATF_RUN}) && exists(${ATF_REPORT})
136# Definition of the "make test" target and supporting variables.
137#
138# This target, by necessity, can only work for native builds (i.e. a freeBSD
139# host building a release for the same system). The target runs ATF, which is
140# not in the toolchain, and the tests execute code built for the target host.
141#
142# Due to the dependencies of the binaries built by the source tree and how they
143# are used by tests, it is highly possible for a execution of "make test" to
144# report bogus results unless the new binaries are put in place.
145_TESTS_FIFO= ${.OBJDIR}/atf-run.fifo
146_TESTS_LOG= ${.OBJDIR}/atf-run.log
147CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG}
148realtest: .PHONY
149 @set -e; \
150 if [ -z "${TESTSDIR}" ]; then \
151 echo "*** No TESTSDIR defined; nothing to do."; \
152 exit 0; \
153 fi; \
154 cd ${DESTDIR}${TESTSDIR}; \
155 rm -f ${_TESTS_FIFO}; \
156 mkfifo ${_TESTS_FIFO}; \
157 tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \
158 set +e; \
159 ${TESTS_ENV} ${ATF_RUN} >> ${_TESTS_FIFO}; \
160 result=$${?}; \
161 wait; \
162 rm -f ${_TESTS_FIFO}; \
163 echo; \
164 echo "*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \
165 echo "***"; \
166 echo "*** WARNING: atf-run is deprecated; please install kyua instead"; \
167 exit $${result}
168.endif
169
170.endif
167
168.include <bsd.test.mk>