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