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