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