]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - tools/build/make_check/Makefile
MFC r270190: Don't stop other parallel build legs on failure of make_check.
[FreeBSD/stable/9.git] / tools / build / make_check / Makefile
1 # $FreeBSD$
2
3 .MAKE.MODE=     normal
4
5 # Failure is handled by the invoker, don't kill other legs of a parallel build.
6 MAKE_JOB_ERROR_TOKEN=no
7
8 # Test for broken LHS expansion.
9 # This *must* cause make(1) to detect a recursive variable, and fail as such.
10 .if make(lhs_expn)
11 FOO=            ${BAR}
12 BAR${NIL}=      ${FOO}
13 FOO${BAR}=      ${FOO}
14 .endif
15
16 DATA1=  helllo
17 DATA2:= ${DATA1}
18 DATA3=  ${DATA2:S/ll/rr/g}
19 DATA4:= ${DATA2:S/ll/rr/g}
20 DATA2?= allo
21 DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
22 DATA2=  yello
23 DATA1:= ${DATA5:S/l/r/g}
24 NIL=
25
26 SMAKE=  MAKEFLAGS= ${MAKE} -C ${.CURDIR}
27
28 all:
29         @echo '1..17'
30         @${SMAKE} C_check || { ${MAKE} -C ${.CURDIR} failure ; }
31         @echo "ok 1 - C_check # Test of -C flag existence detected no regression."
32         @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
33                 diff -u ${.CURDIR}/regress.variables.out - || \
34                 ${SMAKE} failure
35         @echo "ok 2 - test_variables # Test variables detected no regression, output matches."
36         @${SMAKE} double 2>/dev/null || ${SMAKE} failure
37         @echo "ok 3 - test_targets # Test targets detected no regression."
38         @${SMAKE} sysvmatch || ${SMAKE} failure
39         @echo "ok 4 - sysvmatch # Test sysvmatch detected no regression."
40         @! ${SMAKE} lhs_expn && true || ${SMAKE} failure
41         @echo "ok 5 lhs_expn # Test lhs_expn detected no regression."
42         @${SMAKE} notdef || ${SMAKE} failure
43         @echo "ok 6 - notdef # Test notdef detected no regression."
44         @${SMAKE} modifiers || ${SMAKE} failure
45         @echo "ok 7 - modifiers # Test modifiers detected no regression."
46         @${SMAKE} funny_targets || ${SMAKE} failure
47         @echo "ok 8 funny_targets # Test funny_targets detected no regression."
48         @${SMAKE} arith_expr || ${SMAKE} failure
49         @echo "ok 9 arith_expr # Test arith_expr detected no regression."
50         @${SMAKE} PATH_exists || ${SMAKE} failure
51         @echo "ok 10 PATH_exists # Test PATH_exists detected no regression."
52         @${SMAKE} double_quotes || ${SMAKE} failure
53         @echo "ok 11 double_quotes # Test double_quotes detected no regression."
54         @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure
55         @echo "ok 12 double_quotes2 # Test double_quotes2 detected no regression."
56         @${SMAKE} pass_cmd_vars || ${SMAKE} failure
57         @echo "ok 13 pass_cmd_vars # Test pass_cmd_vars detected no regression."
58         @${SMAKE} plus_flag || ${SMAKE} failure
59         @echo "ok 14 plus_flag # Test plus_flag detected no regression."
60         @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure
61         @echo "ok 15 shell # Test shell detected no regression."
62         @${SMAKE} shell_1 || ${SMAKE} failure
63         @echo "ok 16 shell_1 # Test shell_1 detected no regression."
64         @${SMAKE} shell_2 || ${SMAKE} failure
65         @echo "ok 17 shell_2 # Test shell_2 detected no regression."
66
67 .if make(C_check)
68 C_check:
69 .endif
70
71 .if make(double)
72 # Doubly-defined targets.  make(1) will warn, but use the "right" one.  If it
73 # switches to using the "non-right" one, it breaks things worse than a little
74 # regression test.
75 double:
76         @true
77
78 double:
79         @false
80 .endif
81
82 .if make(sysvmatch)
83 # Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
84 sysvmatch:
85         @echo EMPTY ${NIL:=foo} LHS | \
86                 diff -u ${.CURDIR}/regress.sysvmatch.out - || false
87 .endif
88
89 # A bogus target for the lhs_expn test;  If this is reached, then the make(1)
90 # program has not errored out because of the recursion caused by not expanding
91 # the left-hand-side's embedded variables above.
92 lhs_expn:
93         @true
94
95 .if make(notdef)
96 # make(1) claims to only evaluate a conditional as far as is necessary
97 # to determine its value; that was not always the case.
98 .undef notdef
99 notdef:
100 .if defined(notdef) && ${notdef:U}
101 .endif
102 .endif
103
104 .if make(modifiers)
105 # See if make(1) supports the C modifier.
106 modifiers:
107         @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
108             grep -q "Unknown modifier 'C'"; then \
109                 false; \
110         fi
111 .endif
112
113 .if make(funny_targets)
114 funny_targets: colons::target exclamation!target
115 colons::target:
116 exclamation!target: 
117 .endif
118
119 .if make(arith_expr)
120 arith_expr:
121 # See if arithmetic expression parsing is broken.
122 # The different spacing below is intentional.
123 VALUE=  0
124 .if (${VALUE} < 0)||(${VALUE}>0)
125 .endif
126 .endif
127
128 .if make(PATH_exists)
129 PATH_exists:
130 .PATH: ${.CURDIR}
131 .if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
132 .error exists() failed
133 .endif
134 .endif
135
136 .if make(double_quotes)
137 VALUE=  foo ""
138 double_quotes:
139 .if ${VALUE:S/$//} != ${VALUE}
140 .error "" reduced to "
141 .endif
142 .endif
143
144 .if make(double_quotes2)
145 double_quotes2:
146         @cat /dev/null ""
147 .endif
148
149 #
150 # Check passing of variable via MAKEFLAGS
151 #
152 .if make(pass_cmd_vars)
153 pass_cmd_vars:
154         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
155         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
156         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
157         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
158 .endif
159
160 #
161 # Check that the variable definition arrived from the calling make
162 #
163 .if make(pass_cmd_vars_1)
164 # These values should get overridden by the commandline
165 CMD1=oops1
166 CMD2=oops2
167 pass_cmd_vars_1:
168         @:
169
170 .if ${CMD1} != cmd1 || ${CMD2} != cmd2
171 .error variables not passed through MAKEFLAGS
172 .endif
173 .endif
174
175 .if make(pass_cmd_vars_2)
176 # Check that we cannot override the passed variables
177 CMD1=foo1
178 CMD2=foo2
179
180 .if ${CMD1} != cmd1 || ${CMD2} != cmd2
181 .error MAKEFLAGS-passed variables overridden
182 .endif
183
184 pass_cmd_vars_2:
185         @:
186 .endif
187
188 .if make(pass_cmd_vars_3)
189 # Check that we can override the passed variables on the next sub-make's
190 # command line
191
192 pass_cmd_vars_3:
193         @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1
194 .endif
195
196 .if make(pass_cmd_vars_3_1)
197 .if ${CMD1} != foo1 || ${CMD2} != cmd2
198 .error MAKEFLAGS-passed variables not overridden on command line
199 .endif
200 pass_cmd_vars_3_1:
201         @:
202 .endif
203
204 .if make(pass_cmd_vars_4)
205 # Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
206 # by evaluating the .MAKEFLAGS target.
207
208 .MAKEFLAGS: CMD1=baz1
209
210 pass_cmd_vars_4:
211         @${SMAKE} pass_cmd_vars_4_1
212
213 .if ${CMD1} != baz1 || ${CMD2} != cmd2
214 .error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target
215 .endif
216
217 .endif
218 .if make(pass_cmd_vars_4_1)
219 .if ${CMD1} != baz1 || ${CMD2} != cmd2
220 .error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)
221 .endif
222 pass_cmd_vars_4_1:
223         @:
224 .endif
225
226 #
227 # Test whether make supports the '+' flag (meaning: execute even with -n)
228 #
229 .if make(plus_flag)
230 OUT != ${SMAKE} -n plus_flag_1
231 .if ${OUT:M/tmp} != "/tmp"
232 .error make doesn't handle + flag
233 .endif
234 plus_flag:
235         @:
236 .endif
237 .if make(plus_flag_1)
238 plus_flag_1:
239         +@cd /tmp; pwd
240 .endif
241
242 .if make(shell)
243 # Test if make fully supports the .SHELL specification.
244 .SHELL: path=/nonexistent
245 A!= echo ok
246 shell:
247 .endif
248
249 .if make(shell_1)
250 # Test if setting the shell by name only works. Because we have no ksh
251 # in the base system we test that we can set sh and csh. We try only exact
252 # matching names and do not exercise the rather strange matching algorithm.
253 shell_1:
254         @${SMAKE} shell_1_csh
255         @${SMAKE} shell_1_sh
256 .endif
257 .if make(shell_1_csh)
258 .SHELL: name="csh"
259 shell_1_csh:
260         @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$'
261 .endif
262 .if make(shell_1_sh)
263 .SHELL: name="sh"
264 shell_1_sh:
265         @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?sh$$'
266 .endif
267
268 .if make(shell_2)
269 # Test if we can replace the shell specification. We do this by using
270 # a shell scripts that prints us its arguments and standard input as the shell
271 shell_2: shell_test
272         @${SMAKE} -B shell_2B | \
273                 diff -u ${.CURDIR}/regress.shell_2B.out - || false
274         @${SMAKE} -j1 shell_2j | \
275                 diff -u ${.CURDIR}/regress.shell_2j.out - || false
276 .endif
277
278 .if make(shell_2B)
279 .SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors"
280
281 shell_2B:
282         -@funny $$
283         funnier $$
284 .endif
285
286 .if make(shell_2j)
287 .SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors"
288
289 shell_2j:
290         -@funny $$
291         funnier $$
292 .endif
293
294 failure:
295         @echo "not ok # Test failed: regression detected.  See above."
296         @false
297
298 CLEANFILES= shell_test
299
300 .include <bsd.obj.mk>