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