blob: 7e19087a4ff7d4c0692bbeba5aec63e2a3dc6a3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# $NetBSD$
# $FreeBSD$
#
.include <bsd.init.mk>
ATF_TESTS:=
.if make(*test)
TESTSDIR?= .
.endif
.if defined(ATF_TESTS_SUBDIRS)
# Only visit subdirs when building, etc because ATF does this it on its own.
.if !make(atf-test)
SUBDIR+= ${ATF_TESTS_SUBDIRS}
.endif
ATF_TESTS+= ${ATF_TESTS_SUBDIRS}
.include <bsd.subdir.mk>
.endif
.if defined(TESTS_C)
ATF_TESTS+= ${TESTS_C}
.for _T in ${TESTS_C}
SRCS.${_T}?= ${_T}.c
DPADD.${_T}+= ${LIBATF_C}
LDADD.${_T}+= -latf-c
.endfor
.endif
.if defined(TESTS_CXX)
ATF_TESTS+= ${TESTS_CXX}
.for _T in ${TESTS_CXX}
SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
LDADD.${_T}+= -latf-c++ -latf-c
.endfor
.endif
.if defined(TESTS_SH)
ATF_TESTS+= ${TESTS_SH}
.for _T in ${TESTS_SH}
CLEANFILES+= ${_T} ${_T}.tmp
TESTS_SH_SRC_${_T}?= ${_T}.sh
${_T}: ${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
ATFFILE?= auto
.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 = "'`uname -o`'"'; \
echo; \
for tp in ${ATF_TESTS}; do \
echo "tp: $${tp}"; \
done; } >Atffile.tmp
@mv Atffile.tmp Atffile
.endif
.endif
# Generate support variables for atf-test.
#
# atf-test can only work for native builds, i.e. a build host of a particular
# OS building a release for the same OS version and architecture. The target
# runs ATF, which is on the build host, and the tests execute code built for
# the target host.
#
# Due to the dependencies of the binaries built by the source tree and how they
# are used by tests, it is highly possible for a execution of "make test" to
# report bogus results unless the new binaries are put in place.
# XXX (gcooper): Executing ATF from outside the source tree is improper; it
# should be built as part of the OS toolchain build for the host OS and
# executed from there.
ATF_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
TESTS_ENV+= PATH=${ATF_PATH:ts:}:${PATH}
ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc
ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp
ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++
ATF_CONFDIR?= ${DESTDIR}/etc
ATF_INCLUDEDIR?= ${DESTDIR}/usr/include
ATF_LIBDIR?= ${DESTDIR}/usr/lib
ATF_LIBEXECDIR?= ${DESTDIR}/usr/libexec
ATF_PKGDATADIR?= ${DESTDIR}/usr/share/atf
ATF_SHELL?= ${DESTDIR}/bin/sh
LD_LIBRARY_PATH?= ${TESTS_LD_LIBRARY_PATH:tW:S/ /:/g}
ATF_ENV_VARS= \
ATF_BUILD_CC \
ATF_BUILD_CPP \
ATF_BUILD_CXX \
ATF_CONFDIR \
ATF_INCLUDEDIR \
ATF_LIBDIR \
ATF_LIBEXECDIR \
ATF_PKGDATADIR \
ATF_SHELL \
.for v in ${ATF_ENV_VARS}
.if !empty($v)
TESTS_ENV+= $v=${$v}
.endif
.endfor
_TESTS_FIFO= ${.OBJDIR}/atf-run.fifo
_TESTS_LOG= ${.OBJDIR}/atf-run.log
CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG}
ATF_BIN?= ${DESTDIR}/usr/bin
ATF_REPORT?= ${ATF_BIN}/atf-report
ATF_RUN?= ${ATF_BIN}/atf-run
.PHONY: realtest
realtest:
.if defined(TESTSDIR)
@set -e; \
cd ${DESTDIR}${TESTSDIR}; \
rm -f ${_TESTS_FIFO}; \
mkfifo ${_TESTS_FIFO}; \
tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \
set +e; \
${TESTS_ENV} ${ATF_RUN} >> ${_TESTS_FIFO}; \
result=$${?}; \
wait; \
rm -f ${_TESTS_FIFO}; \
echo; \
echo "*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \
exit $${result}
.endif
.include <bsd.test.mk>
|