1 # $NetBSD: bsd.test.mk,v 1.24 2013/02/23 22:01:51 jmmv Exp $
8 .if defined
(TESTS_SUBDIRS
)
9 SUBDIR
+= ${TESTS_SUBDIRS}
12 .
include <bsd.subdir.mk
>
17 . for _T in
${TESTS_C}
18 BINDIR.
${_T}= ${TESTSDIR}
20 DPADD.
${_T}+= ${LIBATF_C}
25 .if defined
(TESTS_CXX
)
27 PROGS_CXX
+= ${TESTS_CXX}
28 . for _T in
${TESTS_CXX}
29 BINDIR.
${_T}= ${TESTSDIR}
30 LDADD.
${_T}+= -latf-c
++ -latf-c
31 DPADD.
${_T}+= ${LIBATF_CXX} ${LIBATF_C}
38 CLEANDIRFILES
+= ${TESTS_SH}
40 . for _T in
${TESTS_SH}
42 SCRIPTSDIR_
${_T}= ${TESTSDIR}
44 CLEANDIRFILES
+= ${_T}.tmp
46 TESTS_SH_SRC_
${_T}?
= ${_T}.sh
47 ${_T}: ${TESTS_SH_SRC_
${_T}}
49 echo
'#! /usr/bin/atf-sh' >${.TARGET
}.tmp
50 cat
${.ALLSRC
} >>${.TARGET
}.tmp
51 chmod
+x
${.TARGET
}.tmp
52 mv
${.TARGET
}.tmp
${.TARGET
}
63 # Additional list of 'tp' entries to add to the Atffile when ATFFILE=auto.
64 # These entries must all correspond to subdirectories to descend into.
66 # This is useful in the cases where the tests in a single directory come
67 # from various sources (e.g. src/tests and src/external/.../tests) and
68 # the installation of some of those tests rely on MK* variables being set.
69 ATFFILE_EXTRA_SUBDIRS?
=
71 .if
${ATFFILE
:tl
} != "no"
73 FILESDIR_Atffile
= ${TESTSDIR}
75 . if
${ATFFILE
:tl
} == "auto"
76 CLEANDIRFILES
+= Atffile Atffile.tmp
81 @
{ echo
'Content-Type: application/X-atf-atffile; version="1"'; \
83 echo
'# Automatically generated by bsd.test.mk.'; \
85 echo
'prop: test-suite = "NetBSD"'; \
87 for tp in
${TESTS_SUBDIRS
:N.WAIT
} ${_TESTS} ${ATFFILE_EXTRA_SUBDIRS}; \
91 @mv Atffile.tmp Atffile
95 .if
${KYUAFILE
:tl
} != "no"
97 FILESDIR_Kyuafile
= ${TESTSDIR}
99 . if
${KYUAFILE
:tl
} == "auto"
100 CLEANDIRFILES
+= Kyuafile Kyuafile.tmp
106 echo
'-- Automatically generated by bsd.test.mk.'; \
110 echo
'test_suite("NetBSD")'; \
111 if
[ -n
"${_TESTS}" ]; then \
113 for tp in
${_TESTS}; do \
114 echo
"atf_test_program{name=\"$${tp}\"}"; \
117 if
[ -n
"${TESTS_SUBDIRS:N.WAIT}" -o \
118 -n
"${ATFFILE_EXTRA_SUBDIRS}" ]; then \
120 for subdir in
${TESTS_SUBDIRS
:N.WAIT
} \
121 ${ATFFILE_EXTRA_SUBDIRS}; do \
122 echo
"include(\"$${subdir}/Kyuafile\")"; \
126 @mv Kyuafile.tmp Kyuafile
130 .if
${ATFFILE
:tl
} != "no" ||
${KYUAFILE
:tl
} != "no"
131 .
include <bsd.files.mk
>
134 .if
!empty
(SCRIPTS
) ||
!empty
(PROGS
) ||
!empty
(PROGS_CXX
)
135 .
include <bsd.prog.mk
>
139 # Definition of the "make test" target and supporting variables.
141 # This target, by necessity, can only work for native builds (i.e. a NetBSD
142 # host building a release for the same system). The target runs ATF, which is
143 # not in the toolchain, and the tests execute code built for the target host.
145 # Due to the dependencies of the binaries built by the source tree and how they
146 # are used by tests, it is highly possible for a execution of "make test" to
147 # report bogus results unless the new binaries are put in place.
150 TESTS_PATH
+= ${DESTDIR}/bin
${DESTDIR}/sbin
${DESTDIR}/usr
/bin
${DESTDIR}/usr
/sbin
151 TESTS_LD_LIBRARY_PATH
+= ${DESTDIR}/lib
${DESTDIR}/usr
/lib
153 TESTS_ENV
+= ATF_BUILD_CC
=${DESTDIR}/usr
/bin
/cc
154 TESTS_ENV
+= ATF_BUILD_CPP
=${DESTDIR}/usr
/bin
/cpp
155 TESTS_ENV
+= ATF_BUILD_CXX
=${DESTDIR}/usr
/bin
/c
++
156 TESTS_ENV
+= ATF_CONFDIR
=${DESTDIR}/etc
157 TESTS_ENV
+= ATF_INCLUDEDIR
=${DESTDIR}/usr
/include
158 TESTS_ENV
+= ATF_LIBDIR
=${DESTDIR}/usr
/lib
159 TESTS_ENV
+= ATF_LIBEXECDIR
=${DESTDIR}/usr
/libexec
160 TESTS_ENV
+= ATF_PKGDATADIR
=${DESTDIR}/usr
/share
/atf
161 TESTS_ENV
+= ATF_SHELL
=${DESTDIR}/bin
/sh
162 TESTS_ENV
+= LD_LIBRARY_PATH
=${TESTS_LD_LIBRARY_PATH
:tW
:S
/ /:/g
}
163 TESTS_ENV
+= PATH
=${TESTS_PATH
:tW
:S
/ /:/g
}
165 _TESTS_FIFO
= ${.OBJDIR
}/atf-run.fifo
166 _TESTS_LOG
= ${.OBJDIR
}/atf-run.log
167 CLEANDIRFILES
+= ${_TESTS_FIFO} ${_TESTS_LOG}
170 .if defined
(TESTSDIR
)
171 . if
${TESTSDIR} == ${TESTSBASE}
172 # Forbid this case. It is likely to cause false positives/negatives and it
173 # does not cover all the tests (e.g. it misses testing software in external).
175 @echo
"*** Sorry, you cannot use make test from src/tests. Install the"
176 @echo
"*** tests into their final location and run them from /usr/tests"
180 @echo
"*** WARNING: make test is experimental"
182 @echo
"*** Using this test does not preclude you from running the tests"
183 @echo
"*** installed in /usr/tests. This test run may raise false"
184 @echo
"*** positives and/or false negatives."
187 cd
${DESTDIR}${TESTSDIR}; \
188 rm -f
${_TESTS_FIFO}; \
189 mkfifo
${_TESTS_FIFO}; \
190 cat
${_TESTS_FIFO} | tee
${_TESTS_LOG} | \
191 ${TESTS_ENV} ${DESTDIR}/usr
/bin
/atf-report
& \
193 ${TESTS_ENV} ${DESTDIR}/usr
/bin
/atf-run
>>${_TESTS_FIFO} || result
=1; \
195 rm -f
${_TESTS_FIFO}; \
197 echo
"*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \
198 echo
"*** Once again, note that "make
test" is unsupported."; \
199 test $${result} -eq
0
203 @echo
"*** No TESTSDIR defined; nothing to do."
206 ##### Pull in related .mk logic
207 .
include <bsd.
clean.mk
>