1 # This is a generated file, do NOT edit!
2 # See contrib/bmake/bsd.after-import.mk
5 # $Id: Makefile,v 1.107 2020/11/02 00:40:25 sjg Exp $
7 # $NetBSD: Makefile,v 1.181 2020/11/01 19:02:22 rillig 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
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
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-target
67 TESTS+= cond-op-parentheses
69 TESTS+= cond-token-number
70 TESTS+= cond-token-plain
71 TESTS+= cond-token-string
72 TESTS+= cond-token-var
73 TESTS+= cond-undef-lint
76 TESTS+= counter-append
79 TESTS+= dep-colon-bug-cross-file
80 TESTS+= dep-double-colon
81 TESTS+= dep-double-colon-indep
95 TESTS+= depsrc-nometa_cmp
97 TESTS+= depsrc-notmain
98 TESTS+= depsrc-optional
100 TESTS+= depsrc-precious
101 TESTS+= depsrc-recursive
102 TESTS+= depsrc-silent
104 TESTS+= depsrc-usebefore
105 TESTS+= depsrc-usebefore-double-colon
109 TESTS+= deptgt-default
110 TESTS+= deptgt-delete_on_error
112 TESTS+= deptgt-end-jobs
114 TESTS+= deptgt-ignore
115 TESTS+= deptgt-interrupt
117 TESTS+= deptgt-makeflags
118 TESTS+= deptgt-no_parallel
119 TESTS+= deptgt-nopath
120 TESTS+= deptgt-notparallel
121 TESTS+= deptgt-objdir
124 TESTS+= deptgt-path-suffix
126 TESTS+= deptgt-precious
128 TESTS+= deptgt-silent
130 TESTS+= deptgt-suffixes
132 TESTS+= dir-expand-path
134 TESTS+= directive-dinclude
135 TESTS+= directive-elif
136 TESTS+= directive-elifdef
137 TESTS+= directive-elifmake
138 TESTS+= directive-elifndef
139 TESTS+= directive-elifnmake
140 TESTS+= directive-else
141 TESTS+= directive-endif
142 TESTS+= directive-error
143 TESTS+= directive-export
144 TESTS+= directive-export-env
145 TESTS+= directive-export-gmake
146 TESTS+= directive-export-literal
147 TESTS+= directive-for
148 TESTS+= directive-for-generating-endif
149 TESTS+= directive-hyphen-include
151 TESTS+= directive-ifdef
152 TESTS+= directive-ifmake
153 TESTS+= directive-ifndef
154 TESTS+= directive-ifnmake
155 TESTS+= directive-include
156 TESTS+= directive-include-fatal
157 TESTS+= directive-info
158 TESTS+= directive-sinclude
159 TESTS+= directive-undef
160 TESTS+= directive-unexport
161 TESTS+= directive-unexport-env
162 TESTS+= directive-warning
169 TESTS+= # escape # broken by reverting POSIX changes
173 TESTS+= export-variants
176 TESTS+= hanoi-include
179 #TESTS+= job-output-long-lines
181 TESTS+= make-exported
188 TESTS+= opt-backwards
191 TESTS+= opt-debug-all
192 TESTS+= opt-debug-archive
193 TESTS+= opt-debug-curdir
194 TESTS+= opt-debug-cond
195 TESTS+= opt-debug-dir
196 TESTS+= opt-debug-errors
197 TESTS+= opt-debug-file
198 TESTS+= opt-debug-for
199 TESTS+= opt-debug-graph1
200 TESTS+= opt-debug-graph2
201 TESTS+= opt-debug-graph3
202 TESTS+= opt-debug-hash
203 #TESTS+= opt-debug-jobs
204 TESTS+= opt-debug-lint
205 TESTS+= opt-debug-loud
206 TESTS+= opt-debug-meta
207 TESTS+= opt-debug-making
208 TESTS+= opt-debug-no-rm
209 TESTS+= opt-debug-parse
210 TESTS+= opt-debug-suff
211 TESTS+= opt-debug-targets
212 TESTS+= opt-debug-varraw
213 TESTS+= opt-debug-var
214 TESTS+= opt-debug-x-trace
219 TESTS+= opt-include-dir
221 TESTS+= opt-jobs-internal
222 TESTS+= opt-keep-going
223 TESTS+= opt-m-include-dir
224 TESTS+= opt-no-action
225 TESTS+= opt-no-action-at-all
230 TESTS+= opt-tracefile
231 TESTS+= opt-var-expanded
232 TESTS+= opt-var-literal
233 TESTS+= opt-warnings-as-errors
234 TESTS+= opt-where-am-i
235 TESTS+= opt-x-reduce-exported
240 TESTS+= # posix1 # broken by reverting POSIX changes
246 TESTS+= sh-jobs-error
247 TESTS+= sh-leading-at
248 TESTS+= sh-leading-hyphen
249 TESTS+= sh-leading-plus
250 TESTS+= sh-meta-chars
251 TESTS+= sh-multi-line
252 TESTS+= sh-single-line
257 TESTS+= suff-add-later
258 TESTS+= suff-clear-regular
259 TESTS+= suff-clear-single
263 TESTS+= suff-transform-endless
264 TESTS+= suff-transform-expand
265 TESTS+= suff-transform-select
270 TESTS+= use-inference
272 TESTS+= var-class-cmdline
273 TESTS+= var-class-env
274 TESTS+= var-class-global
275 TESTS+= var-class-local
276 TESTS+= var-class-local-legacy
278 TESTS+= var-op-append
279 TESTS+= var-op-assign
280 TESTS+= var-op-default
281 TESTS+= var-op-expand
284 TESTS+= var-recursive
290 TESTS+= varmod-assign
291 TESTS+= varmod-defined
293 TESTS+= varmod-exclam-shell
294 TESTS+= varmod-extension
295 TESTS+= varmod-gmtime
298 TESTS+= varmod-ifelse
299 TESTS+= varmod-l-name-to-value
300 TESTS+= varmod-localtime
303 TESTS+= varmod-match-escape
304 TESTS+= varmod-no-match
306 TESTS+= varmod-order-reverse
307 TESTS+= varmod-order-shuffle
310 TESTS+= varmod-quote-dollar
312 TESTS+= varmod-remember
314 TESTS+= varmod-select-words
317 TESTS+= varmod-subst-regex
320 TESTS+= varmod-to-abs
321 TESTS+= varmod-to-lower
322 TESTS+= varmod-to-many-words
323 TESTS+= varmod-to-one-word
324 TESTS+= varmod-to-separator
325 TESTS+= varmod-to-upper
326 TESTS+= varmod-undefined
327 TESTS+= varmod-unique
329 TESTS+= varname-dollar
330 TESTS+= varname-dot-alltargets
331 TESTS+= varname-dot-curdir
332 TESTS+= varname-dot-includes
333 TESTS+= varname-dot-includedfromdir
334 TESTS+= varname-dot-includedfromfile
335 TESTS+= varname-dot-libs
336 TESTS+= varname-dot-make-dependfile
337 TESTS+= varname-dot-make-expand_variables
338 TESTS+= varname-dot-make-exported
339 TESTS+= varname-dot-make-jobs
340 TESTS+= varname-dot-make-jobs-prefix
341 TESTS+= varname-dot-make-level
342 TESTS+= varname-dot-make-makefile_preference
343 TESTS+= varname-dot-make-makefiles
344 TESTS+= varname-dot-make-meta-bailiwick
345 TESTS+= varname-dot-make-meta-created
346 TESTS+= varname-dot-make-meta-files
347 TESTS+= varname-dot-make-meta-ignore_filter
348 TESTS+= varname-dot-make-meta-ignore_paths
349 TESTS+= varname-dot-make-meta-ignore_patterns
350 TESTS+= varname-dot-make-meta-prefix
351 TESTS+= varname-dot-make-mode
352 TESTS+= varname-dot-make-path_filemon
353 TESTS+= varname-dot-make-pid
354 TESTS+= varname-dot-make-ppid
355 TESTS+= varname-dot-make-save_dollars
356 TESTS+= varname-dot-makeoverrides
357 TESTS+= varname-dot-newline
358 TESTS+= varname-dot-objdir
359 TESTS+= varname-dot-parsedir
360 TESTS+= varname-dot-parsefile
361 TESTS+= varname-dot-path
362 TESTS+= varname-dot-shell
363 TESTS+= varname-dot-targets
364 TESTS+= varname-empty
366 TESTS+= varname-make_print_var_on_error
367 TESTS+= varname-make_print_var_on_error-jobs
368 TESTS+= varname-makefile
369 TESTS+= varname-makeflags
371 TESTS+= varname-vpath
372 TESTS+= varparse-dynamic
374 TESTS+= varparse-undef-partial
378 # Additional environment variables for some of the tests.
379 # The base environment is -i PATH="$PATH".
380 ENV.envfirst= FROM_ENV=value-from-env
381 ENV.varmisc= FROM_ENV=env
382 ENV.varmisc+= FROM_ENV_BEFORE=env
383 ENV.varmisc+= FROM_ENV_AFTER=env
384 ENV.varmod-localtime+= TZ=Europe/Berlin
386 # Override make flags for some of the tests; default is -k.
387 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
388 # settings FLAGS.test=-dv here, since that is closer to the test code.
389 FLAGS.cond-func-make= via-cmdline
390 FLAGS.directive-ifmake= first second
391 FLAGS.doterror= # none
395 FLAGS.opt-keep-going= -k
396 FLAGS.opt-no-action= -n
398 FLAGS.opt-var-expanded= -v VAR -v VALUE
399 FLAGS.opt-var-literal= -V VAR -V VALUE
400 FLAGS.opt-warnings-as-errors= -W
403 FLAGS.sh-leading-plus= -n
404 FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmline-plain'
406 # Some tests need extra postprocessing.
408 -e '/^[^=_A-Za-z0-9]*=/d'
409 # these all share the same requirement
410 .for t in export-all export-env
411 SED_CMDS.$t= ${SED_CMDS.export}
413 SED_CMDS.job-output-long-lines= \
414 ${:D Job separators on their own line are ok. } \
415 -e '/^--- job-[ab] ---$$/d' \
416 ${:D Plain output lines are ok as well. } \
417 ${:D They may come in multiples of 1024 or as 10000. } \
420 ${:D The following lines should rather not occur since the job } \
421 ${:D marker should always be at the beginning of the line. } \
422 -e '/^aa*--- job-b ---$$/d' \
423 -e '/^bb*--- job-a ---$$/d'
424 SED_CMDS.opt-debug-graph1= \
425 -e 's,${.CURDIR},CURDIR,'
426 SED_CMDS.opt-debug-graph1+= \
427 -e '/Global Variables:/,/Suffixes:/d'
428 SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
429 SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),'
430 SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,'
431 SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,'
432 SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
433 # The "-q" may be there or not, see jobs.c, variable shells.
434 SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: sh\) -q,\1,'
435 SED_CMDS.varmod-subst-regex+= \
436 -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
437 SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,'
438 SED_CMDS.varshell+= -e 's,^${.SHELL:T}: ,,'
439 SED_CMDS.varshell+= -e '/command/s,No such.*,not found,'
440 SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
441 SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
442 SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g'
443 SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g'
444 SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g'
446 # Some tests need an additional round of postprocessing.
447 POSTPROC.deptgt-suffixes= \
448 ${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p'
449 POSTPROC.varname= ${TOOL_SED} -n -e '/^MAGIC/p' -e '/^ORDER_/p'
450 POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
452 # Some tests reuse other tests, which makes them unnecessarily fragile.
453 export-all.rawout: export.mk
454 unexport.rawout: export.mk
455 unexport-env.rawout: export.mk
457 # End of the configuration section.
461 .sinclude "Makefile.inc"
462 .sinclude "Makefile.config"
464 UNIT_TESTS:= ${srcdir}
467 .if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes
468 OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@}
470 OUTFILES= ${TESTS:=.out}
475 CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp
476 CLEANFILES+= obj*.[och] lib*.a # posix1.mk
477 CLEANFILES+= issue* .[ab]* # suffixes.mk
478 CLEANDIRS= dir dummy # posix1.mk
490 .if defined(.PARSEDIR)
491 # ensure consistent results from sort(1)
497 .if ${.MAKE.MODE:Unormal:Mmeta} != ""
498 # we don't need the noise
502 MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc
504 # Each test is run in a sub-make, to keep the tests for interfering with
505 # each other, and because they use different environment variables and
506 # command line options.
507 .SUFFIXES: .mk .rawout .out
509 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
512 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
514 -r -C ${.CURDIR} -f ${.IMPSRC} \
515 ${FLAGS.${.PREFIX:T}:U-k} \
516 > ${.TARGET}.tmp 2>&1 \
517 && status=$$? || status=$$?; \
518 echo $$status > ${.TARGET:R}.status
519 @mv ${.TARGET}.tmp ${.TARGET}
521 # Postprocess the test output so that the results can be compared.
523 # always pretend .MAKE was called 'make'
524 _SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
525 _SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
526 # replace anything after 'stopped in' with unit-tests
527 _SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
528 # strip ${.CURDIR}/ from the output
529 _SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g'
530 _SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
533 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
534 < ${.IMPSRC} > ${.TARGET}.tmp1
535 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
537 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
538 @mv ${.TARGET}.tmp2 ${.TARGET}
540 # Compare all output files
541 test: ${OUTFILES} .PHONY
543 for test in ${TESTS}; do \
544 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
545 || failed="$${failed}$${failed:+ }$${test}" ; \
547 if [ -n "$${failed}" ]; then \
548 echo "Failed tests: $${failed}" ; false ; \
550 echo "All tests passed" ; \
554 @for test in ${TESTS}; do \
555 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
556 || { echo "Replacing $${test}.exp" ; \
557 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
560 .if exists(${TEST_MAKE})
561 ${TESTS:=.rawout}: ${TEST_MAKE}
562 # in meta mode, we *know* if a target script is impacted
563 # by a makefile change.
564 .if ${.MAKE.MODE:Unormal:Mmeta} == ""
565 ${TESTS:=.rawout}: ${.PARSEDIR}/Makefile
569 .sinclude <bsd.obj.mk>