Makefile revision 1.252 1 # $NetBSD: Makefile,v 1.252 2020/12/19 16:00:17 rillig Exp $
2 #
3 # Unit tests for make(1)
4 #
5 # The main targets are:
6 #
7 # all:
8 # run all the tests
9 # test:
10 # run 'all', and compare to expected results
11 # accept:
12 # move generated output to expected results
13 #
14 # Settable variables
15 #
16 # TEST_MAKE
17 # The make program to be tested.
18 #
19 #
20 # Adding a test case
21 #
22 # Each feature should get its own set of tests in its own suitably
23 # named makefile (*.mk), with its own set of expected results (*.exp),
24 # and it should be added to the TESTS list.
25 #
26 # Any added files must also be added to src/distrib/sets/lists/tests/mi.
27 # To do that, just run "make sync-mi" in this directory.
28 #
29 # A few *.mk files are helper files for other tests (such as include-sub.mk)
30 # and are thus not added to TESTS. Such files must be ignored in
31 # src/tests/usr.bin/make/t_make.sh.
32 #
33
34 # we use this below but we might be an older make
35 .MAKE.UID?= ${id -u:L:sh}
36
37 # Each test is in a sub-makefile.
38 # Keep the list sorted.
39 # Any test that is commented out must be ignored in
40 # src/tests/usr.bin/make/t_make.sh as well.
41 TESTS+= archive
42 TESTS+= archive-suffix
43 TESTS+= cmd-errors
44 TESTS+= cmd-errors-lint
45 TESTS+= cmd-interrupt
46 TESTS+= cmdline
47 TESTS+= cmdline-undefined
48 TESTS+= comment
49 TESTS+= compat-error
50 TESTS+= cond-cmp-numeric
51 TESTS+= cond-cmp-numeric-eq
52 TESTS+= cond-cmp-numeric-ge
53 TESTS+= cond-cmp-numeric-gt
54 TESTS+= cond-cmp-numeric-le
55 TESTS+= cond-cmp-numeric-lt
56 TESTS+= cond-cmp-numeric-ne
57 TESTS+= cond-cmp-string
58 TESTS+= cond-cmp-unary
59 TESTS+= cond-eof
60 TESTS+= cond-func
61 TESTS+= cond-func-commands
62 TESTS+= cond-func-defined
63 TESTS+= cond-func-empty
64 TESTS+= cond-func-exists
65 TESTS+= cond-func-make
66 TESTS+= cond-func-make-main
67 TESTS+= cond-func-target
68 TESTS+= cond-late
69 TESTS+= cond-op
70 TESTS+= cond-op-and
71 TESTS+= cond-op-and-lint
72 TESTS+= cond-op-not
73 TESTS+= cond-op-or
74 TESTS+= cond-op-or-lint
75 TESTS+= cond-op-parentheses
76 TESTS+= cond-short
77 TESTS+= cond-token-number
78 TESTS+= cond-token-plain
79 TESTS+= cond-token-string
80 TESTS+= cond-token-var
81 TESTS+= cond-undef-lint
82 TESTS+= cond1
83 TESTS+= counter
84 TESTS+= counter-append
85 TESTS+= dep
86 TESTS+= dep-colon
87 TESTS+= dep-colon-bug-cross-file
88 TESTS+= dep-double-colon
89 TESTS+= dep-double-colon-indep
90 TESTS+= dep-exclam
91 TESTS+= dep-none
92 TESTS+= dep-percent
93 TESTS+= dep-var
94 TESTS+= dep-wildcards
95 TESTS+= depsrc
96 TESTS+= depsrc-end
97 TESTS+= depsrc-exec
98 TESTS+= depsrc-ignore
99 TESTS+= depsrc-made
100 TESTS+= depsrc-make
101 TESTS+= depsrc-meta
102 TESTS+= depsrc-nometa
103 TESTS+= depsrc-nometa_cmp
104 TESTS+= depsrc-nopath
105 TESTS+= depsrc-notmain
106 TESTS+= depsrc-optional
107 TESTS+= depsrc-phony
108 TESTS+= depsrc-precious
109 TESTS+= depsrc-recursive
110 TESTS+= depsrc-silent
111 TESTS+= depsrc-use
112 TESTS+= depsrc-usebefore
113 TESTS+= depsrc-usebefore-double-colon
114 TESTS+= depsrc-wait
115 TESTS+= deptgt
116 TESTS+= deptgt-begin
117 TESTS+= deptgt-begin-fail
118 TESTS+= deptgt-begin-fail-indirect
119 TESTS+= deptgt-default
120 TESTS+= deptgt-delete_on_error
121 TESTS+= deptgt-end
122 TESTS+= deptgt-end-fail
123 TESTS+= deptgt-end-fail-all
124 TESTS+= deptgt-end-fail-indirect
125 TESTS+= deptgt-end-jobs
126 TESTS+= deptgt-error
127 TESTS+= deptgt-ignore
128 TESTS+= deptgt-interrupt
129 TESTS+= deptgt-main
130 TESTS+= deptgt-makeflags
131 TESTS+= deptgt-no_parallel
132 TESTS+= deptgt-nopath
133 TESTS+= deptgt-notparallel
134 TESTS+= deptgt-objdir
135 TESTS+= deptgt-order
136 TESTS+= deptgt-path
137 TESTS+= deptgt-path-suffix
138 TESTS+= deptgt-phony
139 TESTS+= deptgt-precious
140 TESTS+= deptgt-shell
141 TESTS+= deptgt-silent
142 TESTS+= deptgt-stale
143 TESTS+= deptgt-suffixes
144 TESTS+= dir
145 TESTS+= dir-expand-path
146 TESTS+= directive
147 TESTS+= directive-dinclude
148 TESTS+= directive-elif
149 TESTS+= directive-elifdef
150 TESTS+= directive-elifmake
151 TESTS+= directive-elifndef
152 TESTS+= directive-elifnmake
153 TESTS+= directive-else
154 TESTS+= directive-endif
155 TESTS+= directive-error
156 TESTS+= directive-export
157 TESTS+= directive-export-env
158 TESTS+= directive-export-gmake
159 TESTS+= directive-export-literal
160 TESTS+= directive-for
161 TESTS+= directive-for-generating-endif
162 TESTS+= directive-for-lines
163 TESTS+= directive-for-null
164 TESTS+= directive-hyphen-include
165 TESTS+= directive-if
166 TESTS+= directive-if-nested
167 TESTS+= directive-ifdef
168 TESTS+= directive-ifmake
169 TESTS+= directive-ifndef
170 TESTS+= directive-ifnmake
171 TESTS+= directive-include
172 TESTS+= directive-include-fatal
173 TESTS+= directive-info
174 TESTS+= directive-misspellings
175 TESTS+= directive-sinclude
176 TESTS+= directive-undef
177 TESTS+= directive-unexport
178 TESTS+= directive-unexport-env
179 TESTS+= directive-warning
180 TESTS+= dollar
181 TESTS+= doterror
182 TESTS+= dotwait
183 TESTS+= envfirst
184 TESTS+= error
185 TESTS+= # escape # broken by reverting POSIX changes
186 TESTS+= export
187 TESTS+= export-all
188 TESTS+= export-env
189 TESTS+= export-variants
190 TESTS+= forloop
191 TESTS+= forsubst
192 TESTS+= gnode-submake
193 TESTS+= hanoi-include
194 TESTS+= impsrc
195 TESTS+= include-main
196 TESTS+= job-flags
197 TESTS+= job-output-long-lines
198 TESTS+= jobs-error-indirect
199 TESTS+= jobs-error-nested
200 TESTS+= jobs-error-nested-make
201 TESTS+= lint
202 TESTS+= make-exported
203 TESTS+= meta-cmd-cmp
204 TESTS+= moderrs
205 TESTS+= modmatch
206 TESTS+= modmisc
207 TESTS+= modts
208 TESTS+= modword
209 .if ${.MAKE.UID} > 0
210 TESTS+= objdir-writable
211 .endif
212 TESTS+= opt
213 TESTS+= opt-backwards
214 TESTS+= opt-chdir
215 TESTS+= opt-debug
216 TESTS+= opt-debug-all
217 TESTS+= opt-debug-archive
218 TESTS+= opt-debug-curdir
219 TESTS+= opt-debug-cond
220 TESTS+= opt-debug-dir
221 TESTS+= opt-debug-errors
222 TESTS+= opt-debug-file
223 TESTS+= opt-debug-for
224 TESTS+= opt-debug-graph1
225 TESTS+= opt-debug-graph2
226 TESTS+= opt-debug-graph3
227 TESTS+= opt-debug-hash
228 TESTS+= opt-debug-jobs
229 TESTS+= opt-debug-lint
230 TESTS+= opt-debug-loud
231 TESTS+= opt-debug-meta
232 TESTS+= opt-debug-making
233 TESTS+= opt-debug-no-rm
234 TESTS+= opt-debug-parse
235 TESTS+= opt-debug-suff
236 TESTS+= opt-debug-targets
237 TESTS+= opt-debug-varraw
238 TESTS+= opt-debug-var
239 TESTS+= opt-debug-x-trace
240 TESTS+= opt-define
241 TESTS+= opt-env
242 TESTS+= opt-file
243 TESTS+= opt-ignore
244 TESTS+= opt-include-dir
245 TESTS+= opt-jobs
246 TESTS+= opt-jobs-internal
247 TESTS+= opt-jobs-no-action
248 TESTS+= opt-keep-going
249 TESTS+= opt-keep-going-multiple
250 TESTS+= opt-m-include-dir
251 TESTS+= opt-no-action
252 TESTS+= opt-no-action-at-all
253 TESTS+= opt-no-action-runflags
254 TESTS+= opt-query
255 TESTS+= opt-raw
256 TESTS+= opt-silent
257 TESTS+= opt-touch
258 TESTS+= opt-touch-jobs
259 TESTS+= opt-tracefile
260 TESTS+= opt-var-expanded
261 TESTS+= opt-var-literal
262 TESTS+= opt-warnings-as-errors
263 TESTS+= opt-where-am-i
264 TESTS+= opt-x-reduce-exported
265 TESTS+= order
266 TESTS+= parse-var
267 TESTS+= phony-end
268 TESTS+= posix
269 TESTS+= # posix1 # broken by reverting POSIX changes
270 TESTS+= recursive
271 TESTS+= sh
272 TESTS+= sh-dots
273 TESTS+= sh-errctl
274 TESTS+= sh-flags
275 TESTS+= sh-jobs
276 TESTS+= sh-jobs-error
277 TESTS+= sh-leading-at
278 TESTS+= sh-leading-hyphen
279 TESTS+= sh-leading-plus
280 TESTS+= sh-meta-chars
281 TESTS+= sh-multi-line
282 TESTS+= sh-single-line
283 TESTS+= shell-csh
284 TESTS+= shell-custom
285 TESTS+= shell-ksh
286 TESTS+= shell-sh
287 TESTS+= suff-add-later
288 TESTS+= suff-clear-regular
289 TESTS+= suff-clear-single
290 TESTS+= suff-incomplete
291 TESTS+= suff-lookup
292 TESTS+= suff-main
293 TESTS+= suff-main-several
294 TESTS+= suff-phony
295 TESTS+= suff-rebuild
296 TESTS+= suff-self
297 TESTS+= suff-transform-debug
298 TESTS+= suff-transform-endless
299 TESTS+= suff-transform-expand
300 TESTS+= suff-transform-select
301 TESTS+= sunshcmd
302 TESTS+= ternary
303 TESTS+= unexport
304 TESTS+= unexport-env
305 TESTS+= use-inference
306 TESTS+= var-class
307 TESTS+= var-class-cmdline
308 TESTS+= var-class-env
309 TESTS+= var-class-global
310 TESTS+= var-class-local
311 TESTS+= var-class-local-legacy
312 TESTS+= var-op
313 TESTS+= var-op-append
314 TESTS+= var-op-assign
315 TESTS+= var-op-default
316 TESTS+= var-op-expand
317 TESTS+= var-op-shell
318 TESTS+= var-op-sunsh
319 TESTS+= var-recursive
320 TESTS+= varcmd
321 TESTS+= vardebug
322 TESTS+= varfind
323 TESTS+= varmisc
324 TESTS+= varmod
325 TESTS+= varmod-assign
326 TESTS+= varmod-defined
327 TESTS+= varmod-edge
328 TESTS+= varmod-exclam-shell
329 TESTS+= varmod-extension
330 TESTS+= varmod-gmtime
331 TESTS+= varmod-hash
332 TESTS+= varmod-head
333 TESTS+= varmod-ifelse
334 TESTS+= varmod-indirect
335 TESTS+= varmod-l-name-to-value
336 TESTS+= varmod-localtime
337 TESTS+= varmod-loop
338 TESTS+= varmod-match
339 TESTS+= varmod-match-escape
340 TESTS+= varmod-no-match
341 TESTS+= varmod-order
342 TESTS+= varmod-order-reverse
343 TESTS+= varmod-order-shuffle
344 TESTS+= varmod-path
345 TESTS+= varmod-quote
346 TESTS+= varmod-quote-dollar
347 TESTS+= varmod-range
348 TESTS+= varmod-remember
349 TESTS+= varmod-root
350 TESTS+= varmod-select-words
351 TESTS+= varmod-shell
352 TESTS+= varmod-subst
353 TESTS+= varmod-subst-regex
354 TESTS+= varmod-sysv
355 TESTS+= varmod-tail
356 TESTS+= varmod-to-abs
357 TESTS+= varmod-to-lower
358 TESTS+= varmod-to-many-words
359 TESTS+= varmod-to-one-word
360 TESTS+= varmod-to-separator
361 TESTS+= varmod-to-upper
362 TESTS+= varmod-undefined
363 TESTS+= varmod-unique
364 TESTS+= varname
365 TESTS+= varname-dollar
366 TESTS+= varname-dot-alltargets
367 TESTS+= varname-dot-curdir
368 TESTS+= varname-dot-includes
369 TESTS+= varname-dot-includedfromdir
370 TESTS+= varname-dot-includedfromfile
371 TESTS+= varname-dot-libs
372 TESTS+= varname-dot-make-dependfile
373 TESTS+= varname-dot-make-expand_variables
374 TESTS+= varname-dot-make-exported
375 TESTS+= varname-dot-make-jobs
376 TESTS+= varname-dot-make-jobs-prefix
377 TESTS+= varname-dot-make-level
378 TESTS+= varname-dot-make-makefile_preference
379 TESTS+= varname-dot-make-makefiles
380 TESTS+= varname-dot-make-meta-bailiwick
381 TESTS+= varname-dot-make-meta-created
382 TESTS+= varname-dot-make-meta-files
383 TESTS+= varname-dot-make-meta-ignore_filter
384 TESTS+= varname-dot-make-meta-ignore_paths
385 TESTS+= varname-dot-make-meta-ignore_patterns
386 TESTS+= varname-dot-make-meta-prefix
387 TESTS+= varname-dot-make-mode
388 TESTS+= varname-dot-make-path_filemon
389 TESTS+= varname-dot-make-pid
390 TESTS+= varname-dot-make-ppid
391 TESTS+= varname-dot-make-save_dollars
392 TESTS+= varname-dot-makeflags
393 TESTS+= varname-dot-makeoverrides
394 TESTS+= varname-dot-newline
395 TESTS+= varname-dot-objdir
396 TESTS+= varname-dot-parsedir
397 TESTS+= varname-dot-parsefile
398 TESTS+= varname-dot-path
399 TESTS+= varname-dot-shell
400 TESTS+= varname-dot-targets
401 TESTS+= varname-empty
402 TESTS+= varname-make
403 TESTS+= varname-make_print_var_on_error
404 TESTS+= varname-make_print_var_on_error-jobs
405 TESTS+= varname-makefile
406 TESTS+= varname-makeflags
407 TESTS+= varname-pwd
408 TESTS+= varname-vpath
409 TESTS+= varparse-dynamic
410 TESTS+= varparse-errors
411 TESTS+= varparse-mod
412 TESTS+= varparse-undef-partial
413 TESTS+= varquote
414
415 # Ideas for more tests:
416 # char-0020-space.mk
417 # char-005C-backslash.mk
418 # escape-cond-str.mk
419 # escape-cond-func-arg.mk
420 # escape-cond-func-arg.mk
421 # escape-varmod.mk
422 # escape-varmod-define.mk
423 # escape-varmod-match.mk
424 # escape-varname.mk
425 # escape-varassign-varname.mk
426 # escape-varassign-varname-cmdline.mk
427 # escape-varassign-value.mk
428 # escape-varassign-value-cmdline.mk
429 # escape-dependency-source.mk
430 # escape-dependency-target.mk
431 # escape-for-varname.mk
432 # escape-for-item.mk
433 # posix-*.mk (see posix.mk and posix1.mk)
434
435 .if ${.OBJDIR} != ${.CURDIR}
436 RO_OBJDIR:= ${.OBJDIR}/roobj
437 .else
438 RO_OBJDIR:= ${TMPDIR:U/tmp}/roobj
439 .endif
440 # Additional environment variables for some of the tests.
441 # The base environment is -i PATH="$PATH".
442 ENV.depsrc-optional+= TZ=UTC
443 ENV.envfirst= FROM_ENV=value-from-env
444 ENV.objdir-writable+= RO_OBJDIR=${RO_OBJDIR}
445 ENV.varmisc= FROM_ENV=env
446 ENV.varmisc+= FROM_ENV_BEFORE=env
447 ENV.varmisc+= FROM_ENV_AFTER=env
448 ENV.varmod-localtime+= TZ=Europe/Berlin
449 ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2
450
451 # Override make flags for some of the tests; default is -k.
452 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
453 # settings FLAGS.test=-dv here, since that is closer to the test code.
454 FLAGS.cond-func-make= via-cmdline
455 FLAGS.directive-ifmake= first second
456 FLAGS.doterror= # none, especially not -k
457 FLAGS.jobs-error-indirect= # none, especially not -k
458 FLAGS.jobs-error-nested= # none, especially not -k
459 FLAGS.jobs-error-nested-make= # none, especially not -k
460 FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain'
461
462 # Some tests need extra postprocessing.
463 SED_CMDS.dir= ${:D remove output from -DCLEANUP mode }
464 SED_CMDS.dir+= -e '/^OpenDirs_Done:/d'
465 SED_CMDS.dir+= -e '/^CachedDir /d'
466 SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d'
467 SED_CMDS.export-all= ${SED_CMDS.export}
468 SED_CMDS.export-env= ${SED_CMDS.export}
469 SED_CMDS.job-output-long-lines= \
470 ${:D Job separators on their own line are ok. } \
471 -e '/^--- job-[ab] ---$$/d' \
472 ${:D Plain output lines are ok as well. } \
473 ${:D They may come in multiples of 1024 or as 10000. } \
474 -e '/^aa*$$/d' \
475 -e '/^bb*$$/d' \
476 ${:D The following lines should rather not occur since the job } \
477 ${:D marker should always be at the beginning of the line. } \
478 -e '/^aa*--- job-b ---$$/d' \
479 -e '/^bb*--- job-a ---$$/d'
480 SED_CMDS.objdir-writable= -e 's,${RO_OBJDIR},OBJDIR/roobj,g'
481 SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1}
482 SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),'
483 SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,'
484 SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,'
485 SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
486 SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,'
487 # The "-q" may be there or not, see jobs.c, variable shells.
488 SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,'
489 SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output}
490 SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output}
491 # For Compat_RunCommand, useShell == FALSE.
492 SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,'
493 # For Compat_RunCommand, useShell == TRUE.
494 SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,'
495 SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,'
496 SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj}
497 SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output}
498 SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1}
499 SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1}
500 SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1}
501 SED_CMDS.var-op-shell+= \
502 -e 's,^${.SHELL:T}: [ 0-9:]*,,' \
503 -e '/command/s,No such.*,not found,'
504 SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,'
505 SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,'
506 SED_CMDS.varmod-gmtime+= -e 's,Tue Jan 19 03:14:08 2038,<normalized>,'
507 SED_CMDS.varmod-gmtime+= ${:D FreeBSD i386 still has 32-bit time_t. }
508 SED_CMDS.varmod-gmtime+= -e 's,Fri Dec 13 20:45:52 1901,<normalized>,'
509 SED_CMDS.varmod-localtime+= -e 's,Tue Jan 19 04:14:08 2038,<normalized>,'
510 SED_CMDS.varmod-localtime+= ${:D FreeBSD i386 still has 32-bit time_t. }
511 SED_CMDS.varmod-localtime+= -e 's,Fri Dec 13 21:45:52 1901,<normalized>,'
512 SED_CMDS.varmod-subst-regex+= \
513 -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
514 SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
515 SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
516 SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g'
517 SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g'
518 SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g'
519
520 # Some tests need an additional round of postprocessing.
521 POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/'
522 POSTPROC.gnode-submake= awk '/Input graph/, /^$$/'
523 POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
524
525 # Some tests reuse other tests, which makes them unnecessarily fragile.
526 export-all.rawout: export.mk
527 unexport.rawout: export.mk
528 unexport-env.rawout: export.mk
529
530 # End of the configuration section.
531
532 # Some standard sed commands, to be used in the SED_CMDS above.
533
534 # Omit details such as process IDs from the output of the -dg1 option.
535 STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,<curdir>,'
536 STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,'
537 STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,'
538 STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,'
539 STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,'
540 STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,'
541
542 # Omit details such as process IDs from the output of the -dj option.
543 STD_SED_CMDS.dj= \
544 -e '/Process/d;/JobFinish:/d' \
545 -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \
546 -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \
547 -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \
548 -e 's,^\( Command:\) .*,\1 <shell>,'
549
550 # Reduce the noise for tests running with the -n option, since there is no
551 # other way to suppress the echoing of the commands.
552 STD_SED_CMDS.hide-from-output= \
553 -e '/^echo hide-from-output/d' \
554 -e 's,hide-from-output ,,' \
555 -e 's,hide-from-output,,'
556
557 # End of the configuration helpers section.
558
559 .MAIN: all
560
561 UNIT_TESTS:= ${.PARSEDIR}
562 .PATH: ${UNIT_TESTS}
563
564 .if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes
565 OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@}
566 .else
567 OUTFILES= ${TESTS:=.out}
568 .endif
569
570 all: ${OUTFILES}
571
572 CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp
573 CLEANFILES+= obj*.[och] lib*.a # posix1.mk
574 CLEANFILES+= issue* .[ab]* # suffixes.mk
575 CLEANDIRS= dir dummy # posix1.mk
576
577 clean:
578 rm -f ${CLEANFILES}
579 rm -rf ${CLEANDIRS}
580
581 TEST_MAKE?= ${.MAKE}
582 TOOL_SED?= sed
583
584 # ensure consistent results from sort(1)
585 LC_ALL= C
586 LANG= C
587 .export LANG LC_ALL
588
589 MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc
590
591 .if ${.MAKE.OS:U${uname -s:L:sh}} == "NetBSD"
592 LIMIT_RESOURCES?= ulimit -v 200000
593 .endif
594 LIMIT_RESOURCES?= :
595
596 # Each test is run in a sub-make, to keep the tests for interfering with
597 # each other, and because they use different environment variables and
598 # command line options.
599 .SUFFIXES: .mk .rawout .out
600 .mk.rawout:
601 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
602 @set -eu; \
603 ${LIMIT_RESOURCES}; \
604 cd ${.OBJDIR}; \
605 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
606 ${TEST_MAKE} \
607 -r -C ${.CURDIR} -f ${.IMPSRC} \
608 ${FLAGS.${.PREFIX:T}:U-k} \
609 > ${.TARGET}.tmp 2>&1 \
610 && status=$$? || status=$$?; \
611 echo $$status > ${.TARGET:R}.status
612 @mv ${.TARGET}.tmp ${.TARGET}
613
614 # Postprocess the test output so that the results can be compared.
615 #
616 # always pretend .MAKE was called 'make'
617 _SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
618 _SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
619 _SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}[][0-9]* warning,make warning,'
620 _SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
621 # replace anything after 'stopped in' with unit-tests
622 _SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
623 # strip ${.CURDIR}/ from the output
624 _SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g'
625 _SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
626
627 .rawout.out:
628 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
629 < ${.IMPSRC} > ${.TARGET}.tmp1
630 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
631 @rm ${.TARGET}.tmp1
632 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
633 @mv ${.TARGET}.tmp2 ${.TARGET}
634
635 # Compare all output files
636 test: ${OUTFILES} .PHONY
637 @failed= ; \
638 for test in ${TESTS}; do \
639 diff -u ${UNIT_TESTS}/$${test}.exp $${test}.out \
640 || failed="$${failed}$${failed:+ }$${test}" ; \
641 done ; \
642 if [ -n "$${failed}" ]; then \
643 echo "Failed tests: $${failed}" ; false ; \
644 else \
645 echo "All tests passed" ; \
646 fi
647
648 accept:
649 @for test in ${TESTS}; do \
650 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
651 || { echo "Replacing $${test}.exp" ; \
652 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
653 done
654
655 # Note: only works for adding tests.
656 # To remove a test, the $$mi file must be edited manually.
657 sync-mi:
658 @set -eu; \
659 cd "${MAKEFILE:tA:H}/../../.."; \
660 mi="distrib/sets/lists/tests/mi"; \
661 cvs update "$$mi"; \
662 testsdir="usr.bin/make/unit-tests"; \
663 fmt="./usr/tests/$$testsdir/%s\ttests-usr.bin-tests\tcompattestfile,atf\\n"; \
664 cat "$$mi" > "$$mi.tmp"; \
665 (cd "$$testsdir" && ls *.exp *.mk) | xargs printf "$$fmt" >> "$$mi.tmp"; \
666 distrib/sets/fmt-list "$$mi.tmp"; \
667 mv "$$mi.tmp" "$$mi"; \
668 cvs diff "$$mi" || true
669
670 .if exists(${TEST_MAKE})
671 ${TESTS:=.rawout}: ${TEST_MAKE}
672 # in meta mode, we *know* if a target script is impacted
673 # by a makefile change.
674 .if ${.MAKE.MODE:Unormal:Mmeta} == ""
675 ${TESTS:=.rawout}: ${.PARSEDIR}/Makefile
676 .endif
677 .endif
678
679 .-include <bsd.obj.mk>
680