Added
Link Here
|
1 |
# vim: ts=4 sw=4 |
2 |
# $FreeBSD$ |
3 |
# |
4 |
# Ports test framework. |
5 |
# |
6 |
# USE_TESTS - Must be defined in port Makefile for this file to |
7 |
# be included. |
8 |
# |
9 |
# NO_TEST - Don't try to test an individual port, meant to be set |
10 |
# in individual ports |
11 |
# |
12 |
# TEST_DEPENDS - Dependencies required to run tests successfully. Will be |
13 |
# added to BUILD_DEPENDS. |
14 |
# |
15 |
# TEST_WRKSRC - Base directory for tests. Default ${WRKSRC}. |
16 |
# |
17 |
# TEST_ENV - Variables to be added to the test environment. They will |
18 |
# complement MAKE_ENV or SCRIPTS_ENV whichever applies, but |
19 |
# will only be set during the testing stage. |
20 |
# |
21 |
# TEST_TARGET - Alternate target name. Default: check if GNU_CONFIGURE is |
22 |
# is set, test otherwise. |
23 |
# |
24 |
# TEST_SCRIPT - If set, run script relative ${TEST_WRKSRC} instead of |
25 |
# invoking make. Uses ${SCRIPT_ENV}. Default: unset. |
26 |
# If the script is not executable set this variable to the |
27 |
# interpreter and add the actual script to TEST_SCRIPT_ARGS. |
28 |
# E.g.: |
29 |
# TEST_SCRIPT= ${PYTHON_CMD} |
30 |
# TEST_SCRIPT_ARGS=test.py run |
31 |
# |
32 |
# TEST_SCRIPT_ARGS - Arguments for ${TEST_SCRIPT} |
33 |
# |
34 |
# TEST_BROKEN_TESTS - List of tests relative to ${TEST_WRKSRC} that should be |
35 |
# removed prior to testing. This is meant for tests that |
36 |
# hang the test process if they are run. |
37 |
# |
38 |
# TEST_FAIL_OK - If the tests are known to fail, but the software considered |
39 |
# "in working order", set this variable and specify the |
40 |
# reason in a similar fashion as IGNORE. The tests will |
41 |
# still run so one can see the failures, but it will not hold |
42 |
# the installation process. |
43 |
# |
44 |
# Flags: |
45 |
# |
46 |
# TEST_INTERACTIVE - Set if the test requires tty input or a tty device. |
47 |
# |
48 |
# TEST_REQUIRE_NETWORKING - Set if the tests require networking. Tests will be |
49 |
# disabled by relevant user flag below and PACKAGE_BUILDING. |
50 |
# |
51 |
# TEST_REQUIRE_LOCALHOST - Set if the tests require localhost or 127.0.0.1 to |
52 |
# be available in the host. Also sets TEST_REQUIRE_NETWORKING. |
53 |
# Test will be disabled if jailed. |
54 |
# |
55 |
# TEST_REQUIRE_RAW_SOCKETS - Set if the tests require raw sockets. Sets |
56 |
# *_NETWORKING and tests will be disabled if jailed. |
57 |
# |
58 |
# User flags: |
59 |
# DISABLE_TESTS - This file won't even be included. |
60 |
# WITHOUT_NETWORKED_TESTS - Disable tests that require networking. |
61 |
# |
62 |
|
63 |
.if !defined(_TESTMKINCLUDED) |
64 |
|
65 |
_TESTMKINCLUDED=$$Rev$$ |
66 |
|
67 |
TEST_COOKIE?= ${WRKDIR}/.test_done.${PORTNAME}.${PREFIX:S/\//_/g} |
68 |
TEST_DIRS?= . #yes a dot |
69 |
TEST_ENV?= #empty |
70 |
TEST_WRKSRC?= ${WRKSRC} |
71 |
_TEST_IS_JAILED!= ${SYSCTL} -n security.jail.jailed |
72 |
|
73 |
.if defined(TEST_REQUIRE_LOCALHOST) |
74 |
TEST_REQUIRE_NETWORKING= Requires localhost |
75 |
.endif |
76 |
|
77 |
.if defined(TEST_REQUIRE_RAW_SOCKETS) |
78 |
TEST_REQUIRE_NETWORKING= Requires raw sockets |
79 |
.endif |
80 |
|
81 |
.if defined(PACKAGE_BUILDING) |
82 |
WITHOUT_NETWORKED_TESTS=yes |
83 |
.endif |
84 |
|
85 |
.if defined(TEST_REQUIRE_NETWORKING) && ${TEST_REQUIRE_NETWORKING} == yes |
86 |
TEST_REQUIRE_NETWORKING= Networked tests disabled by flag |
87 |
.endif |
88 |
|
89 |
_TEST_DEP= build |
90 |
.if ( defined(TEST_INTERACTIVE) && defined(BATCH) ) || \ |
91 |
defined(NO_TEST) || \ |
92 |
( defined(TEST_REQUIRE_LOCALHOST) && ${_TEST_IS_JAILED} == 1 ) || \ |
93 |
( defined(TEST_REQUIRE_RAW_SOCKETS) && ${_TEST_IS_JAILED} == 1 ) || \ |
94 |
( defined(TEST_REQUIRE_NETWORKING) && defined(WITHOUT_NETWORKED_TESTS) ) |
95 |
_TEST_SEQ= test-message |
96 |
.else |
97 |
_TEST_SEQ= test-message test-rm-broken pre-test do-test post-test \ |
98 |
test-results-message |
99 |
.endif |
100 |
|
101 |
.if defined(TEST_INTERACTIVE) && !defined(BATCH) |
102 |
IS_INTERACTIVE= yes |
103 |
.endif |
104 |
|
105 |
# Here we try to define some generic ways of testing that may work with many |
106 |
# ports |
107 |
|
108 |
# The bulk of GNU configure scripts use a check target, inspired by |
109 |
# automake or autotest. |
110 |
.if defined(GNU_CONFIGURE) |
111 |
TEST_TARGET?= check |
112 |
.else |
113 |
TEST_TARGET?= test |
114 |
.endif |
115 |
.if defined(USE_GMAKE) |
116 |
_TEST_MAKE= ${GMAKE} |
117 |
.else |
118 |
_TEST_MAKE= ${MAKE} |
119 |
.endif |
120 |
|
121 |
# Try to use build in Perl tests for Perl ports |
122 |
.if defined(PERL_CONFIGURE) ||defined(PERL_MODBUILD) |
123 |
TEST_ADD_RUNDEPS= yes |
124 |
# Build.pl tests run slightly differently |
125 |
.if defined(PERL_MODBUILD) |
126 |
_TEST_MAKE= ${PERL5} ${PL_BUILD} |
127 |
.endif # PERL_MODBUILD |
128 |
# Multiple test jobs support for Perl |
129 |
.if defined(DISABLE_MAKE_JOBS) || defined(MAKE_JOBS_UNSAFE) |
130 |
TEST_JOBS_NUMBER= # empty |
131 |
.else |
132 |
.if defined(MAKE_JOBS_SAFE) || defined(FORCE_MAKE_JOBS) |
133 |
TEST_JOBS_NUMBER?= `${SYSCTL} -n kern.smp.cpus` |
134 |
TEST_ENV+= HARNESS_OPTIONS=j${TEST_JOBS_NUMBER} |
135 |
.endif # MAKE_JOBS_SAFE or FORCE_MAKE_JOBS |
136 |
.endif # DISABLE_MAKE_JOBS or MAKE_JOBS_UNSAFE |
137 |
.endif # PERL_CONFIGURE or PERL_MODBUILD |
138 |
|
139 |
# TODO: add additional generic testing support here |
140 |
|
141 |
.if defined(TEST_ADD_RUNDEPS) |
142 |
TEST_DEPENDS+= ${RUN_DEPENDS} |
143 |
.endif |
144 |
|
145 |
.if defined(TEST_DEPENDS) |
146 |
BUILD_DEPENDS+= ${TEST_DEPENDS} |
147 |
.endif |
148 |
|
149 |
.if defined(TEST_FAIL_OK) |
150 |
_TEST_OK= ||true |
151 |
.else |
152 |
_TEST_OK= #empty |
153 |
.endif |
154 |
|
155 |
.endif # !_TESTMKINCLUDED |
156 |
|
157 |
.if defined(_POSTMKINCLUDED) && defined(_TESTMKINCLUDED) |
158 |
.if !target(test-message) |
159 |
test-message: |
160 |
.if defined(TEST_INTERACTIVE) && defined(BATCH) |
161 |
@${ECHO_MSG} "===> Skipping interactive tests" |
162 |
.elif defined(TEST_REQUIRE_LOCALHOST) && ${_TEST_IS_JAILED} == 1 |
163 |
@${ECHO_MSG} "===> Skipping tests: requires localhost and we are jailed" |
164 |
.elif defined(TEST_REQUIRE_RAW_SOCKETS) && ${_TEST_IS_JAILED} == 1 |
165 |
@${ECHO_MSG} "===> Skipping tests: requires raw sockets and we are jailed" |
166 |
.elif defined(TEST_REQUIRE_NETWORKING) && defined(WITHOUT_NETWORKED_TESTS) |
167 |
@${ECHO_MSG} "===> Skipping tests: ${TEST_REQUIRE_NETWORKING}" |
168 |
.elif defined(NO_TEST) |
169 |
@${ECHO_MSG} "===> Skipping tests: ${NO_TEST}" |
170 |
.else |
171 |
@${ECHO_MSG} "===> Testing for ${PKGNAME}" |
172 |
.endif |
173 |
.if !defined(USE_TESTS) |
174 |
@${ECHO_MSG} "WARNING: USE_TESTS not set in ${PKGORIGIN}/Makefile" |
175 |
.endif |
176 |
.endif |
177 |
|
178 |
.if !target(test-rm-broken) |
179 |
test-rm-broken: |
180 |
.if defined(TEST_BROKEN_TESTS) |
181 |
@${ECHO_MSG} "===> Removing tests that may hang the test process:" |
182 |
.for test in ${TEST_BROKEN_TESTS} |
183 |
@${ECHO_MSG} " ${test}" |
184 |
@${RM} ${WRKSRC}/${test} |
185 |
.endfor |
186 |
.else |
187 |
@${DO_NADA} |
188 |
.endif # !defined TEST_BROKEN_TESTS |
189 |
.endif # !target |
190 |
|
191 |
# Can be used by port to see if any conditions apply that are not handled |
192 |
# gracefully by upstream test, like being jailed or having a running instance |
193 |
# of the program (databases/virtuoso for example). |
194 |
.if !target(pre-test) |
195 |
pre-test: |
196 |
@${DO_NADA} |
197 |
|
198 |
.endif |
199 |
|
200 |
# The real thing(tm) |
201 |
# Override this in Makefile if you really need something special. |
202 |
.if !target(do-test) |
203 |
do-test: |
204 |
.for dir in ${TEST_DIRS} |
205 |
.if !defined(TEST_SCRIPT) |
206 |
@cd ${WRKSRC}/${dir} && ${SETENV} ${MAKE_ENV} ${TEST_ENV} ${_TEST_MAKE} \ |
207 |
${TEST_TARGET} ${_TEST_OK} |
208 |
.else |
209 |
@cd ${WRKSRC}/${dir} && ${SETENV} ${SCRIPTS_ENV} ${TEST_ENV} \ |
210 |
${TEST_SCRIPT} ${TEST_SCRIPT_ARGS} ${_TEST_OK} |
211 |
.endif # !TEST_SCRIPT |
212 |
.endfor # test dirs |
213 |
.endif # !target(do-test) |
214 |
|
215 |
# Can be used by port to do clean ups or mail test results. |
216 |
.if !target(post-test) |
217 |
post-test: |
218 |
@${DO_NADA} |
219 |
.endif |
220 |
|
221 |
.if !target(test-results-message) |
222 |
test-results-message: |
223 |
.if defined(TEST_FAIL_OK) |
224 |
@${ECHO_CMD} |
225 |
@${ECHO_MSG} "===> Test may have failed because:" |
226 |
@${ECHO_CMD}; ${ECHO_MSG} "${TEST_FAIL_OK}"; ${ECHO_CMD} |
227 |
.endif |
228 |
@${ECHO_CMD} "===> Testing completed for ${PKGNAME}" |
229 |
.endif |
230 |
|
231 |
.if !target(retest) |
232 |
retest: |
233 |
-@${RM} ${TEST_COOKIE} |
234 |
@cd ${.CURDIR} && ${MAKE} test |
235 |
.endif |
236 |
|
237 |
.endif # defined(_POSTMKINCLUDED) && defined(_TESTMKINCLUDED) |