1 # $NetBSD: bsd.test.mk,v 1.21 2012/08/25 22:21:16 jmmv Exp $
8 .if defined
(TESTS_SUBDIRS
)
9 SUBDIR
+= ${TESTS_SUBDIRS}
10 _TESTS
:= ${TESTS_SUBDIRS
:N.WAIT
}
13 .
include <bsd.subdir.mk
>
18 . for _T in
${TESTS_C}
19 BINDIR.
${_T}= ${TESTSDIR}
21 DPADD.
${_T}+= ${LIBATF_C}
26 .if defined
(TESTS_CXX
)
28 PROGS_CXX
+= ${TESTS_CXX}
29 . for _T in
${TESTS_CXX}
30 BINDIR.
${_T}= ${TESTSDIR}
31 LDADD.
${_T}+= -latf-c
++ -latf-c
32 DPADD.
${_T}+= ${LIBATF_CXX} ${LIBATF_C}
39 CLEANDIRFILES
+= ${TESTS_SH}
41 . for _T in
${TESTS_SH}
43 SCRIPTSDIR_
${_T}= ${TESTSDIR}
45 CLEANDIRFILES
+= ${_T}.tmp
47 TESTS_SH_SRC_
${_T}?
= ${_T}.sh
48 ${_T}: ${TESTS_SH_SRC_
${_T}}
50 echo
'#! /usr/bin/atf-sh' >${.TARGET
}.tmp
51 cat
${.ALLSRC
} >>${.TARGET
}.tmp
52 chmod
+x
${.TARGET
}.tmp
53 mv
${.TARGET
}.tmp
${.TARGET
}
59 .if
${ATFFILE
:tl
} != "no"
61 FILESDIR_Atffile
= ${TESTSDIR}
63 . if
${ATFFILE
:tl
} == "auto"
64 CLEANDIRFILES
+= Atffile Atffile.tmp
69 @
{ echo
'Content-Type: application/X-atf-atffile; version="1"'; \
71 echo
'# Automatically generated by bsd.test.mk.'; \
73 echo
'prop: test-suite = "NetBSD"'; \
75 for tp in
${_TESTS}; do \
78 @mv Atffile.tmp Atffile
81 .
include <bsd.files.mk
>
84 .if
!empty
(SCRIPTS
) ||
!empty
(PROGS
) ||
!empty
(PROGS_CXX
)
85 .
include <bsd.prog.mk
>
89 # Definition of the "make test" target and supporting variables.
91 # This target, by necessity, can only work for native builds (i.e. a NetBSD
92 # host building a release for the same system). The target runs ATF, which is
93 # not in the toolchain, and the tests execute code built for the target host.
95 # Due to the dependencies of the binaries built by the source tree and how they
96 # are used by tests, it is highly possible for a execution of "make test" to
97 # report bogus results unless the new binaries are put in place.
100 TESTS_PATH
+= ${DESTDIR}/bin
${DESTDIR}/sbin
${DESTDIR}/usr
/bin
${DESTDIR}/usr
/sbin
101 TESTS_LD_LIBRARY_PATH
+= ${DESTDIR}/lib
${DESTDIR}/usr
/lib
103 TESTS_ENV
+= ATF_BUILD_CC
=${DESTDIR}/usr
/bin
/cc
104 TESTS_ENV
+= ATF_BUILD_CPP
=${DESTDIR}/usr
/bin
/cpp
105 TESTS_ENV
+= ATF_BUILD_CXX
=${DESTDIR}/usr
/bin
/c
++
106 TESTS_ENV
+= ATF_CONFDIR
=${DESTDIR}/etc
107 TESTS_ENV
+= ATF_INCLUDEDIR
=${DESTDIR}/usr
/include
108 TESTS_ENV
+= ATF_LIBDIR
=${DESTDIR}/usr
/lib
109 TESTS_ENV
+= ATF_LIBEXECDIR
=${DESTDIR}/usr
/libexec
110 TESTS_ENV
+= ATF_PKGDATADIR
=${DESTDIR}/usr
/share
/atf
111 TESTS_ENV
+= ATF_SHELL
=${DESTDIR}/bin
/sh
112 TESTS_ENV
+= LD_LIBRARY_PATH
=${TESTS_LD_LIBRARY_PATH
:tW
:S
/ /:/g
}
113 TESTS_ENV
+= PATH
=${TESTS_PATH
:tW
:S
/ /:/g
}
115 _TESTS_FIFO
= ${.OBJDIR
}/atf-run.fifo
116 _TESTS_LOG
= ${.OBJDIR
}/atf-run.log
117 CLEANDIRFILES
+= ${_TESTS_FIFO} ${_TESTS_LOG}
120 .if defined
(TESTSDIR
)
121 . if
${TESTSDIR} == ${TESTSBASE}
122 # Forbid this case. It is likely to cause false positives/negatives and it
123 # does not cover all the tests (e.g. it misses testing software in external).
125 @echo
"*** Sorry, you cannot use make test from src/tests. Install the"
126 @echo
"*** tests into their final location and run them from /usr/tests"
130 @echo
"*** WARNING: make test is experimental"
132 @echo
"*** Using this test does not preclude you from running the tests"
133 @echo
"*** installed in /usr/tests. This test run may raise false"
134 @echo
"*** positives and/or false negatives."
137 cd
${DESTDIR}${TESTSDIR}; \
138 rm -f
${_TESTS_FIFO}; \
139 mkfifo
${_TESTS_FIFO}; \
140 cat
${_TESTS_FIFO} | tee
${_TESTS_LOG} | \
141 ${TESTS_ENV} ${DESTDIR}/usr
/bin
/atf-report
& \
143 ${TESTS_ENV} ${DESTDIR}/usr
/bin
/atf-run
>>${_TESTS_FIFO} || result
=1; \
145 rm -f
${_TESTS_FIFO}; \
147 echo
"*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \
148 echo
"*** Once again, note that "make
test" is unsupported."; \
149 test $${result} -eq
0
153 @echo
"*** No TESTSDIR defined; nothing to do."
156 ##### Pull in related .mk logic
157 .
include <bsd.
clean.mk
>