1 # This is a generated file, do NOT edit!
2 # See contrib/bmake/bsd.after-import.mk
5 # $Id: Makefile,v 1.115 2020/11/18 04:01:07 sjg Exp $
7 # $NetBSD: Makefile,v 1.206 2020/11/18 01:12:00 sjg Exp $
9 # Unit tests for make(1)
11 # The main targets are:
16 # run 'all', and compare to expected results
18 # move generated output to expected results
23 # The make program to be tested.
28 # Each feature should get its own set of tests in its own suitably
29 # named makefile (*.mk), with its own set of expected results (*.exp),
30 # and it should be added to the TESTS list.
32 # A few *.mk files are helper files for other tests (such as include-sub.mk)
33 # and are thus not added to TESTS. Such files must be ignored in
34 # src/tests/usr.bin/make/t_make.sh.
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.
42 TESTS+= archive-suffix
44 TESTS+= cmd-errors-lint
47 TESTS+= cmdline-undefined
49 TESTS+= cond-cmp-numeric
50 TESTS+= cond-cmp-numeric-eq
51 TESTS+= cond-cmp-numeric-ge
52 TESTS+= cond-cmp-numeric-gt
53 TESTS+= cond-cmp-numeric-le
54 TESTS+= cond-cmp-numeric-lt
55 TESTS+= cond-cmp-numeric-ne
56 TESTS+= cond-cmp-string
57 TESTS+= cond-cmp-unary
59 TESTS+= cond-func-commands
60 TESTS+= cond-func-defined
61 TESTS+= cond-func-empty
62 TESTS+= cond-func-exists
63 TESTS+= cond-func-make
64 TESTS+= cond-func-target
68 TESTS+= cond-op-and-lint
71 TESTS+= cond-op-or-lint
72 TESTS+= cond-op-parentheses
74 TESTS+= cond-token-number
75 TESTS+= cond-token-plain
76 TESTS+= cond-token-string
77 TESTS+= cond-token-var
78 TESTS+= cond-undef-lint
81 TESTS+= counter-append
84 TESTS+= dep-colon-bug-cross-file
85 TESTS+= dep-double-colon
86 TESTS+= dep-double-colon-indep
100 TESTS+= depsrc-nometa_cmp
101 TESTS+= depsrc-nopath
102 TESTS+= depsrc-notmain
103 TESTS+= depsrc-optional
105 TESTS+= depsrc-precious
106 TESTS+= depsrc-recursive
107 TESTS+= depsrc-silent
109 TESTS+= depsrc-usebefore
110 TESTS+= depsrc-usebefore-double-colon
114 TESTS+= deptgt-default
115 TESTS+= deptgt-delete_on_error
117 TESTS+= deptgt-end-jobs
119 TESTS+= deptgt-ignore
120 TESTS+= deptgt-interrupt
122 TESTS+= deptgt-makeflags
123 TESTS+= deptgt-no_parallel
124 TESTS+= deptgt-nopath
125 TESTS+= deptgt-notparallel
126 TESTS+= deptgt-objdir
129 TESTS+= deptgt-path-suffix
131 TESTS+= deptgt-precious
133 TESTS+= deptgt-silent
135 TESTS+= deptgt-suffixes
137 TESTS+= dir-expand-path
139 TESTS+= directive-dinclude
140 TESTS+= directive-elif
141 TESTS+= directive-elifdef
142 TESTS+= directive-elifmake
143 TESTS+= directive-elifndef
144 TESTS+= directive-elifnmake
145 TESTS+= directive-else
146 TESTS+= directive-endif
147 TESTS+= directive-error
148 TESTS+= directive-export
149 TESTS+= directive-export-env
150 TESTS+= directive-export-gmake
151 TESTS+= directive-export-literal
152 TESTS+= directive-for
153 TESTS+= directive-for-generating-endif
154 TESTS+= directive-hyphen-include
156 TESTS+= directive-if-nested
157 TESTS+= directive-ifdef
158 TESTS+= directive-ifmake
159 TESTS+= directive-ifndef
160 TESTS+= directive-ifnmake
161 TESTS+= directive-include
162 TESTS+= directive-include-fatal
163 TESTS+= directive-info
164 TESTS+= directive-sinclude
165 TESTS+= directive-undef
166 TESTS+= directive-unexport
167 TESTS+= directive-unexport-env
168 TESTS+= directive-warning
174 TESTS+= # escape # broken by reverting POSIX changes
178 TESTS+= export-variants
181 TESTS+= gnode-submake
182 TESTS+= hanoi-include
186 #TESTS+= job-output-long-lines
188 TESTS+= make-exported
194 TESTS+= objdir-writable
196 TESTS+= opt-backwards
199 TESTS+= opt-debug-all
200 TESTS+= opt-debug-archive
201 TESTS+= opt-debug-curdir
202 TESTS+= opt-debug-cond
203 TESTS+= opt-debug-dir
204 TESTS+= opt-debug-errors
205 TESTS+= opt-debug-file
206 TESTS+= opt-debug-for
207 TESTS+= opt-debug-graph1
208 TESTS+= opt-debug-graph2
209 TESTS+= opt-debug-graph3
210 TESTS+= opt-debug-hash
211 #TESTS+= opt-debug-jobs
212 TESTS+= opt-debug-lint
213 TESTS+= opt-debug-loud
214 TESTS+= opt-debug-meta
215 TESTS+= opt-debug-making
216 TESTS+= opt-debug-no-rm
217 TESTS+= opt-debug-parse
218 TESTS+= opt-debug-suff
219 TESTS+= opt-debug-targets
220 TESTS+= opt-debug-varraw
221 TESTS+= opt-debug-var
222 TESTS+= opt-debug-x-trace
227 TESTS+= opt-include-dir
229 TESTS+= opt-jobs-internal
230 TESTS+= opt-keep-going
231 TESTS+= opt-m-include-dir
232 TESTS+= opt-no-action
233 TESTS+= opt-no-action-at-all
238 TESTS+= opt-touch-jobs
239 TESTS+= opt-tracefile
240 TESTS+= opt-var-expanded
241 TESTS+= opt-var-literal
242 TESTS+= opt-warnings-as-errors
243 TESTS+= opt-where-am-i
244 TESTS+= opt-x-reduce-exported
249 TESTS+= # posix1 # broken by reverting POSIX changes
255 TESTS+= sh-jobs-error
256 TESTS+= sh-leading-at
257 TESTS+= sh-leading-hyphen
258 TESTS+= sh-leading-plus
259 TESTS+= sh-meta-chars
260 TESTS+= sh-multi-line
261 TESTS+= sh-single-line
268 TESTS+= suff-add-later
269 TESTS+= suff-clear-regular
270 TESTS+= suff-clear-single
275 TESTS+= suff-transform-endless
276 TESTS+= suff-transform-expand
277 TESTS+= suff-transform-select
282 TESTS+= use-inference
284 TESTS+= var-class-cmdline
285 TESTS+= var-class-env
286 TESTS+= var-class-global
287 TESTS+= var-class-local
288 TESTS+= var-class-local-legacy
290 TESTS+= var-op-append
291 TESTS+= var-op-assign
292 TESTS+= var-op-default
293 TESTS+= var-op-expand
296 TESTS+= var-recursive
302 TESTS+= varmod-assign
303 TESTS+= varmod-defined
305 TESTS+= varmod-exclam-shell
306 TESTS+= varmod-extension
307 TESTS+= varmod-gmtime
310 TESTS+= varmod-ifelse
311 TESTS+= varmod-l-name-to-value
312 TESTS+= varmod-localtime
315 TESTS+= varmod-match-escape
316 TESTS+= varmod-no-match
318 TESTS+= varmod-order-reverse
319 TESTS+= varmod-order-shuffle
322 TESTS+= varmod-quote-dollar
324 TESTS+= varmod-remember
326 TESTS+= varmod-select-words
329 TESTS+= varmod-subst-regex
332 TESTS+= varmod-to-abs
333 TESTS+= varmod-to-lower
334 TESTS+= varmod-to-many-words
335 TESTS+= varmod-to-one-word
336 TESTS+= varmod-to-separator
337 TESTS+= varmod-to-upper
338 TESTS+= varmod-undefined
339 TESTS+= varmod-unique
341 TESTS+= varname-dollar
342 TESTS+= varname-dot-alltargets
343 TESTS+= varname-dot-curdir
344 TESTS+= varname-dot-includes
345 TESTS+= varname-dot-includedfromdir
346 TESTS+= varname-dot-includedfromfile
347 TESTS+= varname-dot-libs
348 TESTS+= varname-dot-make-dependfile
349 TESTS+= varname-dot-make-expand_variables
350 TESTS+= varname-dot-make-exported
351 TESTS+= varname-dot-make-jobs
352 TESTS+= varname-dot-make-jobs-prefix
353 TESTS+= varname-dot-make-level
354 TESTS+= varname-dot-make-makefile_preference
355 TESTS+= varname-dot-make-makefiles
356 TESTS+= varname-dot-make-meta-bailiwick
357 TESTS+= varname-dot-make-meta-created
358 TESTS+= varname-dot-make-meta-files
359 TESTS+= varname-dot-make-meta-ignore_filter
360 TESTS+= varname-dot-make-meta-ignore_paths
361 TESTS+= varname-dot-make-meta-ignore_patterns
362 TESTS+= varname-dot-make-meta-prefix
363 TESTS+= varname-dot-make-mode
364 TESTS+= varname-dot-make-path_filemon
365 TESTS+= varname-dot-make-pid
366 TESTS+= varname-dot-make-ppid
367 TESTS+= varname-dot-make-save_dollars
368 TESTS+= varname-dot-makeoverrides
369 TESTS+= varname-dot-newline
370 TESTS+= varname-dot-objdir
371 TESTS+= varname-dot-parsedir
372 TESTS+= varname-dot-parsefile
373 TESTS+= varname-dot-path
374 TESTS+= varname-dot-shell
375 TESTS+= varname-dot-targets
376 TESTS+= varname-empty
378 TESTS+= varname-make_print_var_on_error
379 TESTS+= varname-make_print_var_on_error-jobs
380 TESTS+= varname-makefile
381 TESTS+= varname-makeflags
383 TESTS+= varname-vpath
384 TESTS+= varparse-dynamic
385 TESTS+= varparse-errors
387 TESTS+= varparse-undef-partial
390 # Ideas for more tests:
392 # char-005C-backslash.mk
394 # escape-cond-func-arg.mk
395 # escape-cond-func-arg.mk
397 # escape-varmod-define.mk
398 # escape-varmod-match.mk
400 # escape-varassign-varname.mk
401 # escape-varassign-varname-cmdline.mk
402 # escape-varassign-value.mk
403 # escape-varassign-value-cmdline.mk
404 # escape-dependency-source.mk
405 # escape-dependency-target.mk
406 # escape-for-varname.mk
408 # posix-*.mk (see posix.mk and posix1.mk)
410 .if ${.OBJDIR} != ${.CURDIR}
411 RO_OBJDIR:= ${.OBJDIR}/roobj
413 RO_OBJDIR:= ${TMPDIR:U/tmp}/roobj
415 # Additional environment variables for some of the tests.
416 # The base environment is -i PATH="$PATH".
417 ENV.depsrc-optional+= TZ=UTC
418 ENV.envfirst= FROM_ENV=value-from-env
419 ENV.objdir-writable+= RO_OBJDIR=${RO_OBJDIR}
420 ENV.varmisc= FROM_ENV=env
421 ENV.varmisc+= FROM_ENV_BEFORE=env
422 ENV.varmisc+= FROM_ENV_AFTER=env
423 ENV.varmod-localtime+= TZ=Europe/Berlin
424 ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2
426 # Override make flags for some of the tests; default is -k.
427 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
428 # settings FLAGS.test=-dv here, since that is closer to the test code.
429 FLAGS.cond-func-make= via-cmdline
430 FLAGS.directive-ifmake= first second
431 FLAGS.doterror= # none, especially not -k
432 FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain'
434 # Some tests need extra postprocessing.
436 -e '/^[^=_A-Za-z0-9]*=/d'
437 # these all share the same requirement
438 .for t in export-all export-env
439 SED_CMDS.$t= ${SED_CMDS.export}
441 SED_CMDS.directive-export-gmake= \
442 ${:D dash is a pain } \
444 SED_CMDS.job-output-long-lines= \
445 ${:D Job separators on their own line are ok. } \
446 -e '/^--- job-[ab] ---$$/d' \
447 ${:D Plain output lines are ok as well. } \
448 ${:D They may come in multiples of 1024 or as 10000. } \
451 ${:D The following lines should rather not occur since the job } \
452 ${:D marker should always be at the beginning of the line. } \
453 -e '/^aa*--- job-b ---$$/d' \
454 -e '/^bb*--- job-a ---$$/d'
455 SED_CMDS.objdir-writable= -e 's,${RO_OBJDIR},OBJDIR/roobj,g'
456 SED_CMDS.opt-debug-graph1= \
457 -e 's,${.CURDIR},CURDIR,'
458 SED_CMDS.opt-debug-graph1+= \
459 -e '/Global Variables:/,/Suffixes:/d'
460 SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
461 SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),'
462 SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,'
463 SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,'
464 SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
465 # The "-q" may be there or not, see jobs.c, variable shells.
466 SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: sh\) -q,\1,'
467 SED_CMDS.var-op-shell+= -e 's,^${.SHELL:T}: ,,'
468 SED_CMDS.var-op-shell+= -e '/command/{ s,^[1-9]: ,,;s,No such.*,not found,; }'
470 ${:D canonicalize .SHELL } \
471 -e 's,${.SHELL},</path/to/shell>,'
472 SED_CMDS.varmod-subst-regex+= \
473 -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
474 SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,'
475 SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
476 SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
477 SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g'
478 SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g'
479 SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g'
481 # Some tests need an additional round of postprocessing.
482 POSTPROC.deptgt-suffixes= \
483 ${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p'
484 POSTPROC.gnode-submake= awk '/Input graph/, /^$$/'
485 POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
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
492 # End of the configuration section.
496 .sinclude "Makefile.inc"
497 .sinclude "Makefile.config"
499 UNIT_TESTS:= ${srcdir}
502 .if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes
503 OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@}
505 OUTFILES= ${TESTS:=.out}
510 CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp
511 CLEANFILES+= obj*.[och] lib*.a # posix1.mk
512 CLEANFILES+= issue* .[ab]* # suffixes.mk
513 CLEANDIRS= dir dummy # posix1.mk
525 .if defined(.PARSEDIR)
526 # ensure consistent results from sort(1)
532 .if ${.MAKE.MODE:Unormal:Mmeta} != ""
533 # we don't need the noise
537 MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc
539 # Each test is run in a sub-make, to keep the tests for interfering with
540 # each other, and because they use different environment variables and
541 # command line options.
542 .SUFFIXES: .mk .rawout .out
544 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
547 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
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}
556 # Postprocess the test output so that the results can be compared.
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'
570 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
571 < ${.IMPSRC} > ${.TARGET}.tmp1
572 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
574 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
575 @mv ${.TARGET}.tmp2 ${.TARGET}
577 # Compare all output files
578 test: ${OUTFILES} .PHONY
580 for test in ${TESTS}; do \
581 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
582 || failed="$${failed}$${failed:+ }$${test}" ; \
584 if [ -n "$${failed}" ]; then \
585 echo "Failed tests: $${failed}" ; false ; \
587 echo "All tests passed" ; \
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 ; } \
597 .if exists(${TEST_MAKE})
598 ${TESTS:=.rawout}: ${TEST_MAKE}
599 # in meta mode, we *know* if a target script is impacted
600 # by a makefile change.
601 .if ${.MAKE.MODE:Unormal:Mmeta} == ""
602 ${TESTS:=.rawout}: ${.PARSEDIR}/Makefile
606 .sinclude <bsd.obj.mk>