1 # $Id: Makefile,v 1.143 2021/02/06 18:31:30 sjg Exp $
3 # $NetBSD: Makefile,v 1.269 2021/02/06 18:26:03 sjg Exp $
5 # Unit tests for make(1)
7 # The main targets are:
12 # run 'all', and compare to expected results
14 # move generated output to expected results
19 # The make program to be tested.
24 # Each feature should get its own set of tests in its own suitably
25 # named makefile (*.mk), with its own set of expected results (*.exp),
26 # and it should be added to the TESTS list.
28 # A few *.mk files are helper files for other tests (such as include-sub.mk)
29 # and are thus not added to TESTS. Such files must be ignored in
30 # src/tests/usr.bin/make/t_make.sh.
35 # we use these below but we might be an older make
36 .MAKE.OS?= ${uname -s:L:sh}
37 .MAKE.UID?= ${id -u:L:sh}
39 # Each test is in a sub-makefile.
40 # Keep the list sorted.
41 # Any test that is commented out must be ignored in
42 # src/tests/usr.bin/make/t_make.sh as well.
44 #TESTS+= archive-suffix
46 TESTS+= cmd-errors-jobs
47 TESTS+= cmd-errors-lint
50 TESTS+= cmdline-redirect-stdin
51 TESTS+= cmdline-undefined
54 TESTS+= cond-cmp-numeric
55 TESTS+= cond-cmp-numeric-eq
56 TESTS+= cond-cmp-numeric-ge
57 TESTS+= cond-cmp-numeric-gt
58 TESTS+= cond-cmp-numeric-le
59 TESTS+= cond-cmp-numeric-lt
60 TESTS+= cond-cmp-numeric-ne
61 TESTS+= cond-cmp-string
62 TESTS+= cond-cmp-unary
65 TESTS+= cond-func-commands
66 TESTS+= cond-func-defined
67 TESTS+= cond-func-empty
68 TESTS+= cond-func-exists
69 TESTS+= cond-func-make
70 TESTS+= cond-func-make-main
71 TESTS+= cond-func-target
75 TESTS+= cond-op-and-lint
78 TESTS+= cond-op-or-lint
79 TESTS+= cond-op-parentheses
81 TESTS+= cond-token-number
82 TESTS+= cond-token-plain
83 TESTS+= cond-token-string
84 TESTS+= cond-token-var
85 TESTS+= cond-undef-lint
88 TESTS+= counter-append
91 TESTS+= dep-colon-bug-cross-file
92 TESTS+= dep-double-colon
93 TESTS+= dep-double-colon-indep
102 TESTS+= depsrc-ignore
106 TESTS+= depsrc-nometa
107 TESTS+= depsrc-nometa_cmp
108 TESTS+= depsrc-nopath
109 TESTS+= depsrc-notmain
110 TESTS+= depsrc-optional
112 TESTS+= depsrc-precious
113 TESTS+= depsrc-recursive
114 TESTS+= depsrc-silent
116 TESTS+= depsrc-usebefore
117 TESTS+= depsrc-usebefore-double-colon
121 TESTS+= deptgt-begin-fail
122 TESTS+= deptgt-begin-fail-indirect
123 TESTS+= deptgt-default
124 TESTS+= deptgt-delete_on_error
126 TESTS+= deptgt-end-fail
127 TESTS+= deptgt-end-fail-all
128 TESTS+= deptgt-end-fail-indirect
129 TESTS+= deptgt-end-jobs
131 TESTS+= deptgt-ignore
132 TESTS+= deptgt-interrupt
134 TESTS+= deptgt-makeflags
135 TESTS+= deptgt-no_parallel
136 TESTS+= deptgt-nopath
137 TESTS+= deptgt-notparallel
138 TESTS+= deptgt-objdir
141 TESTS+= deptgt-path-suffix
143 TESTS+= deptgt-precious
145 TESTS+= deptgt-silent
147 TESTS+= deptgt-suffixes
149 TESTS+= dir-expand-path
151 TESTS+= directive-dinclude
152 TESTS+= directive-elif
153 TESTS+= directive-elifdef
154 TESTS+= directive-elifmake
155 TESTS+= directive-elifndef
156 TESTS+= directive-elifnmake
157 TESTS+= directive-else
158 TESTS+= directive-endfor
159 TESTS+= directive-endif
160 TESTS+= directive-error
161 TESTS+= directive-export
162 TESTS+= directive-export-env
163 TESTS+= directive-export-impl
164 TESTS+= directive-export-gmake
165 TESTS+= directive-export-literal
166 TESTS+= directive-for
167 TESTS+= directive-for-errors
168 TESTS+= directive-for-escape
169 TESTS+= directive-for-generating-endif
170 TESTS+= directive-for-lines
171 TESTS+= directive-for-null
172 TESTS+= directive-hyphen-include
174 TESTS+= directive-if-nested
175 TESTS+= directive-ifdef
176 TESTS+= directive-ifmake
177 TESTS+= directive-ifndef
178 TESTS+= directive-ifnmake
179 TESTS+= directive-include
180 TESTS+= directive-include-fatal
181 TESTS+= directive-info
182 TESTS+= directive-misspellings
183 TESTS+= directive-sinclude
184 TESTS+= directive-undef
185 TESTS+= directive-unexport
186 TESTS+= directive-unexport-env
187 TESTS+= directive-warning
193 TESTS+= # escape # broken by reverting POSIX changes
197 TESTS+= export-variants
200 TESTS+= gnode-submake
201 TESTS+= hanoi-include
205 #TESTS+= job-output-long-lines
206 TESTS+= jobs-empty-commands
207 TESTS+= jobs-error-indirect
208 TESTS+= jobs-error-nested
209 TESTS+= jobs-error-nested-make
211 TESTS+= make-exported
219 TESTS+= objdir-writable
222 TESTS+= opt-backwards
225 TESTS+= opt-debug-all
226 TESTS+= opt-debug-archive
227 TESTS+= opt-debug-curdir
228 TESTS+= opt-debug-cond
229 TESTS+= opt-debug-dir
230 TESTS+= opt-debug-errors
231 TESTS+= opt-debug-file
232 TESTS+= opt-debug-for
233 TESTS+= opt-debug-graph1
234 TESTS+= opt-debug-graph2
235 TESTS+= opt-debug-graph3
236 TESTS+= opt-debug-hash
237 #TESTS+= opt-debug-jobs
238 TESTS+= opt-debug-lint
239 TESTS+= opt-debug-loud
240 TESTS+= opt-debug-meta
241 TESTS+= opt-debug-making
242 TESTS+= opt-debug-no-rm
243 TESTS+= opt-debug-parse
244 TESTS+= opt-debug-suff
245 TESTS+= opt-debug-targets
246 TESTS+= opt-debug-varraw
247 TESTS+= opt-debug-var
248 TESTS+= opt-debug-x-trace
253 TESTS+= opt-include-dir
255 TESTS+= opt-jobs-internal
256 TESTS+= opt-jobs-no-action
257 TESTS+= opt-keep-going
258 TESTS+= opt-keep-going-multiple
259 TESTS+= opt-m-include-dir
260 TESTS+= opt-no-action
261 TESTS+= opt-no-action-at-all
262 TESTS+= opt-no-action-runflags
263 TESTS+= opt-no-action-touch
268 TESTS+= opt-touch-jobs
269 TESTS+= opt-tracefile
270 TESTS+= opt-var-expanded
271 TESTS+= opt-var-literal
272 TESTS+= opt-warnings-as-errors
273 TESTS+= opt-where-am-i
274 TESTS+= opt-x-reduce-exported
279 TESTS+= # posix1 # broken by reverting POSIX changes
286 TESTS+= sh-jobs-error
287 TESTS+= sh-leading-at
288 TESTS+= sh-leading-hyphen
289 TESTS+= sh-leading-plus
290 TESTS+= sh-meta-chars
291 TESTS+= sh-multi-line
292 TESTS+= sh-single-line
299 TESTS+= suff-add-later
300 TESTS+= suff-clear-regular
301 TESTS+= suff-clear-single
302 TESTS+= suff-incomplete
305 TESTS+= suff-main-several
309 TESTS+= suff-transform-debug
310 TESTS+= suff-transform-endless
311 TESTS+= suff-transform-expand
312 TESTS+= suff-transform-select
317 TESTS+= use-inference
319 TESTS+= var-class-cmdline
320 TESTS+= var-class-env
321 TESTS+= var-class-global
322 TESTS+= var-class-local
323 TESTS+= var-class-local-legacy
325 TESTS+= var-op-append
326 TESTS+= var-op-assign
327 TESTS+= var-op-default
328 TESTS+= var-op-expand
331 TESTS+= var-recursive
337 TESTS+= varmod-assign
338 TESTS+= varmod-defined
340 TESTS+= varmod-exclam-shell
341 TESTS+= varmod-extension
342 TESTS+= varmod-gmtime
345 TESTS+= varmod-ifelse
346 TESTS+= varmod-indirect
347 TESTS+= varmod-l-name-to-value
348 TESTS+= varmod-localtime
351 TESTS+= varmod-match-escape
352 TESTS+= varmod-no-match
354 TESTS+= varmod-order-reverse
355 TESTS+= varmod-order-shuffle
358 TESTS+= varmod-quote-dollar
360 TESTS+= varmod-remember
362 TESTS+= varmod-select-words
365 TESTS+= varmod-subst-regex
368 TESTS+= varmod-to-abs
369 TESTS+= varmod-to-lower
370 TESTS+= varmod-to-many-words
371 TESTS+= varmod-to-one-word
372 TESTS+= varmod-to-separator
373 TESTS+= varmod-to-upper
374 TESTS+= varmod-undefined
375 TESTS+= varmod-unique
377 TESTS+= varname-dollar
378 TESTS+= varname-dot-alltargets
379 TESTS+= varname-dot-curdir
380 TESTS+= varname-dot-includes
381 TESTS+= varname-dot-includedfromdir
382 TESTS+= varname-dot-includedfromfile
383 TESTS+= varname-dot-libs
384 TESTS+= varname-dot-make-dependfile
385 TESTS+= varname-dot-make-expand_variables
386 TESTS+= varname-dot-make-exported
387 TESTS+= varname-dot-make-jobs
388 TESTS+= varname-dot-make-jobs-prefix
389 TESTS+= varname-dot-make-level
390 TESTS+= varname-dot-make-makefile_preference
391 TESTS+= varname-dot-make-makefiles
392 TESTS+= varname-dot-make-meta-bailiwick
393 TESTS+= varname-dot-make-meta-created
394 TESTS+= varname-dot-make-meta-files
395 TESTS+= varname-dot-make-meta-ignore_filter
396 TESTS+= varname-dot-make-meta-ignore_paths
397 TESTS+= varname-dot-make-meta-ignore_patterns
398 TESTS+= varname-dot-make-meta-prefix
399 TESTS+= varname-dot-make-mode
400 TESTS+= varname-dot-make-path_filemon
401 TESTS+= varname-dot-make-pid
402 TESTS+= varname-dot-make-ppid
403 TESTS+= varname-dot-make-save_dollars
404 TESTS+= varname-dot-makeflags
405 TESTS+= varname-dot-makeoverrides
406 TESTS+= varname-dot-newline
407 TESTS+= varname-dot-objdir
408 TESTS+= varname-dot-parsedir
409 TESTS+= varname-dot-parsefile
410 TESTS+= varname-dot-path
411 TESTS+= varname-dot-shell
412 TESTS+= varname-dot-targets
413 TESTS+= varname-empty
415 TESTS+= varname-make_print_var_on_error
416 TESTS+= varname-make_print_var_on_error-jobs
417 TESTS+= varname-makefile
418 TESTS+= varname-makeflags
420 TESTS+= varname-vpath
421 TESTS+= varparse-dynamic
422 TESTS+= varparse-errors
424 TESTS+= varparse-undef-partial
427 # Ideas for more tests:
429 # char-005C-backslash.mk
431 # escape-cond-func-arg.mk
432 # escape-cond-func-arg.mk
434 # escape-varmod-define.mk
435 # escape-varmod-match.mk
437 # escape-varassign-varname.mk
438 # escape-varassign-varname-cmdline.mk
439 # escape-varassign-value.mk
440 # escape-varassign-value-cmdline.mk
441 # escape-dependency-source.mk
442 # escape-dependency-target.mk
443 # escape-for-varname.mk
445 # posix-*.mk (see posix.mk and posix1.mk)
447 # Additional environment variables for some of the tests.
448 # The base environment is -i PATH="$PATH".
449 ENV.depsrc-optional+= TZ=UTC
450 ENV.envfirst= FROM_ENV=value-from-env
451 ENV.varmisc= FROM_ENV=env
452 ENV.varmisc+= FROM_ENV_BEFORE=env
453 ENV.varmisc+= FROM_ENV_AFTER=env
454 ENV.varmod-localtime+= TZ=Europe/Berlin
455 ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2
457 # Override make flags for some of the tests; default is -k.
458 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
459 # settings FLAGS.test=-dv here, since that is closer to the test code.
460 FLAGS.cond-func-make= via-cmdline
461 FLAGS.directive-ifmake= first second
462 FLAGS.doterror= # none, especially not -k
463 FLAGS.jobs-error-indirect= # none, especially not -k
464 FLAGS.jobs-error-nested= # none, especially not -k
465 FLAGS.jobs-error-nested-make= # none, especially not -k
466 FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain'
468 # Some tests need extra postprocessing.
469 SED_CMDS.dir= ${:D remove output from -DCLEANUP mode }
470 SED_CMDS.dir+= -e '/^OpenDirs_Done:/d'
471 SED_CMDS.dir+= -e '/^CachedDir /d'
472 SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d'
473 SED_CMDS.export-all= ${SED_CMDS.export}
474 SED_CMDS.export-env= ${SED_CMDS.export}
475 SED_CMDS.cmdline= -e 's,uid${.MAKE.UID}/,,'
476 SED_CMDS.job-output-long-lines= \
477 ${:D Job separators on their own line are ok. } \
478 -e '/^--- job-[ab] ---$$/d' \
479 ${:D Plain output lines are ok as well. } \
480 ${:D They may come in multiples of 1024 or as 10000. } \
483 ${:D The following lines should rather not occur since the job } \
484 ${:D marker should always be at the beginning of the line. } \
485 -e '/^aa*--- job-b ---$$/d' \
486 -e '/^bb*--- job-a ---$$/d'
487 SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1}
488 SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2}
489 SED_CMDS.opt-debug-graph3= ${STD_SED_CMDS.dg3}
490 SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),'
491 SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,'
492 SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,'
493 SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
494 SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,'
495 # The "-q" may be there or not, see jobs.c, variable shells.
496 SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,'
497 SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output}
498 SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output}
499 # For Compat_RunCommand, useShell == FALSE.
500 SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,'
501 # For Compat_RunCommand, useShell == TRUE.
502 SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,'
503 SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,'
504 SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj}
505 SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output}
506 SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1}
507 SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1}
508 SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1}
509 SED_CMDS.var-op-shell+= ${STD_SED_CMDS.shell}
510 SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,'
511 SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,'
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 SED_CMDS.varname-empty= -e 's,${.CURDIR},<curdir>,g'
520 SED_CMDS.varname-empty+= -e '/\.PARSEDIR/d'
521 SED_CMDS.varname-empty+= -e '/\.SHELL/d'
523 # Some tests need an additional round of postprocessing.
524 POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/'
525 POSTPROC.gnode-submake= awk '/Input graph/, /^$$/'
527 # Some tests reuse other tests, which makes them unnecessarily fragile.
528 export-all.rawout: export.mk
529 unexport.rawout: export.mk
530 unexport-env.rawout: export.mk
532 # End of the configuration section.
534 # Some standard sed commands, to be used in the SED_CMDS above.
536 # Omit details such as process IDs from the output of the -dg1 option.
537 STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,<curdir>,'
538 STD_SED_CMDS.dg1+= -e '/\.MAKE.PATH_FILEMON/d'
539 STD_SED_CMDS.dg1+= -e '/^MAKE_VERSION/d;/^\#.*\/mk/d'
540 STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,'
541 STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,'
542 STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,'
543 STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,'
544 STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,'
545 STD_SED_CMDS.dg1+= -e 's,^\(\.SHELL *=\) .*,\1 <details omitted>,'
547 STD_SED_CMDS.dg2= ${STD_SED_CMDS.dg1}
548 STD_SED_CMDS.dg2+= -e 's,\(last modified\) ..:..:.. ... ..\, ....,\1 <timestamp>,'
549 STD_SED_CMDS.dg3= ${STD_SED_CMDS.dg2}
551 # Omit details such as process IDs from the output of the -dj option.
553 -e '/Process/d;/JobFinish:/d' \
554 -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \
555 -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \
556 -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \
557 -e 's,^\( Command:\) .*,\1 <shell>,'
559 # Reduce the noise for tests running with the -n option, since there is no
560 # other way to suppress the echoing of the commands.
561 STD_SED_CMDS.hide-from-output= \
562 -e '/^echo hide-from-output/d' \
563 -e 's,hide-from-output ,,' \
564 -e 's,hide-from-output,,'
566 # Normalize the output for error messages from the shell.
569 # NetBSD sh ...: not found
570 # NetBSD ksh ksh: ...: not found
571 # bash 5.0.18 bash: ...: command not found
572 # bash 5.1.0 bash: line 1: ...: command not found
573 # dash dash: 1: ...: not found
575 # $shell -c '< /nonexistent'
576 # NetBSD sh sh: cannot open /nonexistent: no such file
577 # NetBSD ksh ksh: cannot open /nonexistent: No such file or directory
578 # bash 5.0.18 bash: /nonexistent: No such file or directory
579 # bash 5.1.0 bash: line 1: /nonexistent: No such file or directory
580 # dash dash: 1: cannot open /nonexistent: No such file
582 # echo '< /nonexistent' | $shell
583 # NetBSD sh sh: cannot open /nonexistent: no such file
584 # NetBSD ksh ksh: <stdin>[1]: cannot open /nonexistent: No such file or directory
585 # bash 5.0.18 bash: line 1: /nonexistent: No such file or directory
586 # bash 5.1.0 bash: line 1: /nonexistent: No such file or directory
587 # dash dash: 1: cannot open /nonexistent: No such file
589 STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,'
590 STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,'
591 STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,'
593 # End of the configuration helpers section.
595 .-include "Makefile.inc"
596 .-include "Makefile.config"
598 UNIT_TESTS:= ${.PARSEDIR}
601 .if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes
602 OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@}
604 OUTFILES= ${TESTS:=.out}
609 CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp
610 CLEANFILES+= obj*.[och] lib*.a # posix1.mk
611 CLEANFILES+= issue* .[ab]* # suffixes.mk
612 CLEANDIRS= dir dummy # posix1.mk
624 .if defined(.PARSEDIR)
625 # ensure consistent results from sort(1)
631 .if ${.MAKE.MODE:Unormal:Mmeta} != ""
632 # we don't need the noise
637 # for many tests we need a TMPDIR that will not collide
639 .if ${.OBJDIR} != ${.CURDIR}
641 TMPDIR:= ${.OBJDIR}/tmp
643 TMPDIR:= ${TMPDIR:U/tmp}/uid${.MAKE.UID}
645 # make sure it exists
646 .if !exist(${TMPDIR})
647 x!= echo; mkdir -p ${TMPDIR}
650 MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc
651 MAKE_TEST_ENV+= TMPDIR=${TMPDIR}
653 .if ${.MAKE.OS} == "NetBSD"
654 LIMIT_RESOURCES?= ulimit -v 200000
658 # Each test is run in a sub-make, to keep the tests for interfering with
659 # each other, and because they use different environment variables and
660 # command line options.
661 .SUFFIXES: .mk .rawout .out
663 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
665 ${LIMIT_RESOURCES}; \
667 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
669 -r -C ${.CURDIR} -f ${.IMPSRC} \
670 ${FLAGS.${.PREFIX:T}:U-k} \
671 > ${.TARGET}.tmp 2>&1 \
672 && status=$$? || status=$$?; \
673 echo $$status > ${.TARGET:R}.status
674 @mv ${.TARGET}.tmp ${.TARGET}
676 # Postprocess the test output so that the results can be compared.
678 # always pretend .MAKE was called 'make'
679 _SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
680 _SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
681 _SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}[][0-9]* warning,make warning,'
682 _SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
683 # replace anything after 'stopped in' with unit-tests
684 _SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
685 _SED_CMDS+= -e 's,${TMPDIR},TMPDIR,g'
686 # strip ${.CURDIR}/ from the output
687 _SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g'
688 _SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
689 # on AT&T derrived systems; false exits 255 not 1
690 .if ${.MAKE.OS:N*BSD} != ""
691 _SED_CMDS+= -e 's,\(Error code\) 255,\1 1,'
695 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
696 < ${.IMPSRC} > ${.TARGET}.tmp1
697 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
699 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
700 @mv ${.TARGET}.tmp2 ${.TARGET}
702 .if empty(DIFF_FLAGS)
708 # Compare all output files
709 test: ${OUTFILES} .PHONY
711 for test in ${TESTS}; do \
712 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out && continue || \
713 ${DIFF_ECHO} diff ${UNIT_TESTS}/$${test}.exp $${test}.out; \
714 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
715 || failed="$${failed}$${failed:+ }$${test}" ; \
717 if [ -n "$${failed}" ]; then \
718 echo "Failed tests: $${failed}" ; false ; \
720 echo "All tests passed" ; \
724 @for test in ${TESTS}; do \
725 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
726 || { echo "Replacing $${test}.exp" ; \
727 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
730 .if exists(${TEST_MAKE})
731 ${TESTS:=.rawout}: ${TEST_MAKE}
732 # in meta mode, we *know* if a target script is impacted
733 # by a makefile change.
734 .if ${.MAKE.MODE:Unormal:Mmeta} == ""
735 ${TESTS:=.rawout}: ${.PARSEDIR}/Makefile