1 # This is a generated file, do NOT edit!
2 # See contrib/bmake/bsd.after-import.mk
5 # $Id: Makefile,v 1.92 2020/09/02 18:39:29 sjg Exp $
7 # $NetBSD: Makefile,v 1.130 2020/09/02 05:33:57 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.
41 TESTS+= # archive # broken on FreeBSD, enabled in t_make.sh
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
55 TESTS+= cond-func-commands
56 TESTS+= cond-func-defined
57 TESTS+= cond-func-empty
58 TESTS+= cond-func-exists
59 TESTS+= cond-func-make
60 TESTS+= cond-func-target
66 TESTS+= cond-op-parentheses
68 TESTS+= cond-token-number
69 TESTS+= cond-token-plain
70 TESTS+= cond-token-string
71 TESTS+= cond-token-var
77 TESTS+= dep-double-colon
89 TESTS+= depsrc-nometa_cmp
91 TESTS+= depsrc-notmain
92 TESTS+= depsrc-optional
94 TESTS+= depsrc-precious
95 TESTS+= depsrc-recursive
98 TESTS+= depsrc-usebefore
99 TESTS+= depsrc-usebefore-double-colon
103 TESTS+= deptgt-default
104 TESTS+= deptgt-delete_on_error
107 TESTS+= deptgt-ignore
108 TESTS+= deptgt-interrupt
110 TESTS+= deptgt-makeflags
111 TESTS+= deptgt-no_parallel
112 TESTS+= deptgt-nopath
113 TESTS+= deptgt-notparallel
114 TESTS+= deptgt-objdir
117 TESTS+= deptgt-path-suffix
119 TESTS+= deptgt-precious
121 TESTS+= deptgt-silent
123 TESTS+= deptgt-suffixes
125 TESTS+= dir-expand-path
127 TESTS+= directive-elif
128 TESTS+= directive-elifdef
129 TESTS+= directive-elifmake
130 TESTS+= directive-elifndef
131 TESTS+= directive-elifnmake
132 TESTS+= directive-else
133 TESTS+= directive-endif
134 TESTS+= directive-error
135 TESTS+= directive-export
136 TESTS+= directive-export-env
137 TESTS+= directive-export-literal
138 TESTS+= directive-for
139 TESTS+= directive-for-generating-endif
141 TESTS+= directive-ifdef
142 TESTS+= directive-ifmake
143 TESTS+= directive-ifndef
144 TESTS+= directive-ifnmake
145 TESTS+= directive-info
146 TESTS+= directive-undef
147 TESTS+= directive-unexport
148 TESTS+= directive-unexport-env
149 TESTS+= directive-warning
156 TESTS+= # escape # broken by reverting POSIX changes
160 TESTS+= export-variants
167 TESTS+= make-exported
175 TESTS+= opt-backwards
183 TESTS+= opt-include-dir
185 TESTS+= opt-jobs-internal
186 TESTS+= opt-keep-going
187 TESTS+= opt-m-include-dir
188 TESTS+= opt-no-action
189 TESTS+= opt-no-action-at-all
194 TESTS+= opt-tracefile
195 TESTS+= opt-var-expanded
196 TESTS+= opt-var-literal
197 TESTS+= opt-warnings-as-errors
198 TESTS+= opt-where-am-i
199 TESTS+= opt-x-reduce-exported
203 TESTS+= # posix1 # broken by reverting POSIX changes
209 TESTS+= sh-jobs-error
210 TESTS+= sh-leading-at
211 TESTS+= sh-leading-hyphen
212 TESTS+= sh-leading-plus
213 TESTS+= sh-meta-chars
214 TESTS+= sh-multi-line
215 TESTS+= sh-single-line
216 TESTS+= # suffixes # runs into an endless loop (try -dA)
222 TESTS+= use-inference
224 TESTS+= var-class-cmdline
225 TESTS+= var-class-env
226 TESTS+= var-class-global
227 TESTS+= var-class-local
228 TESTS+= var-class-local-legacy
230 TESTS+= var-op-append
231 TESTS+= var-op-assign
232 TESTS+= var-op-default
233 TESTS+= var-op-expand
240 TESTS+= varmod-assign
241 TESTS+= varmod-defined
243 TESTS+= varmod-exclam-shell
244 TESTS+= varmod-extension
245 TESTS+= varmod-gmtime
248 TESTS+= varmod-ifelse
249 TESTS+= varmod-l-name-to-value
250 TESTS+= varmod-localtime
253 TESTS+= varmod-match-escape
254 TESTS+= varmod-no-match
256 TESTS+= varmod-order-reverse
257 TESTS+= varmod-order-shuffle
260 TESTS+= varmod-quote-dollar
262 TESTS+= varmod-remember
264 TESTS+= varmod-select-words
267 TESTS+= varmod-subst-regex
270 TESTS+= varmod-to-abs
271 TESTS+= varmod-to-lower
272 TESTS+= varmod-to-many-words
273 TESTS+= varmod-to-one-word
274 TESTS+= varmod-to-separator
275 TESTS+= varmod-to-upper
276 TESTS+= varmod-undefined
277 TESTS+= varmod-unique
279 TESTS+= varname-dollar
280 TESTS+= varname-dot-alltargets
281 TESTS+= varname-dot-curdir
282 TESTS+= varname-dot-includes
283 TESTS+= varname-dot-includedfromdir
284 TESTS+= varname-dot-includedfromfile
285 TESTS+= varname-dot-libs
286 TESTS+= varname-dot-make-dependfile
287 TESTS+= varname-dot-make-expand_variables
288 TESTS+= varname-dot-make-exported
289 TESTS+= varname-dot-make-jobs
290 TESTS+= varname-dot-make-jobs-prefix
291 TESTS+= varname-dot-make-level
292 TESTS+= varname-dot-make-makefile_preference
293 TESTS+= varname-dot-make-makefiles
294 TESTS+= varname-dot-make-meta-bailiwick
295 TESTS+= varname-dot-make-meta-created
296 TESTS+= varname-dot-make-meta-files
297 TESTS+= varname-dot-make-meta-ignore_filter
298 TESTS+= varname-dot-make-meta-ignore_paths
299 TESTS+= varname-dot-make-meta-ignore_patterns
300 TESTS+= varname-dot-make-meta-prefix
301 TESTS+= varname-dot-make-mode
302 TESTS+= varname-dot-make-path_filemon
303 TESTS+= varname-dot-make-pid
304 TESTS+= varname-dot-make-ppid
305 TESTS+= varname-dot-make-save_dollars
306 TESTS+= varname-dot-makeoverrides
307 TESTS+= varname-dot-newline
308 TESTS+= varname-dot-objdir
309 TESTS+= varname-dot-parsedir
310 TESTS+= varname-dot-parsefile
311 TESTS+= varname-dot-path
312 TESTS+= varname-dot-shell
313 TESTS+= varname-dot-targets
314 TESTS+= varname-empty
316 TESTS+= varname-make_print_var_on_error
317 TESTS+= varname-makeflags
319 TESTS+= varname-vpath
320 TESTS+= varparse-dynamic
324 # Additional environment variables for some of the tests.
325 # The base environment is -i PATH="$PATH".
326 ENV.envfirst= FROM_ENV=value-from-env
327 ENV.varmisc= FROM_ENV=env
328 ENV.varmisc+= FROM_ENV_BEFORE=env
329 ENV.varmisc+= FROM_ENV_AFTER=env
331 # Override make flags for some of the tests; default is -k.
332 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
333 # settings FLAGS.test=-dv here, since that is closer to the test code.
336 FLAGS.directive-ifmake= first second
337 FLAGS.doterror= # none
341 FLAGS.opt-debug-g1= -dg1
343 FLAGS.opt-keep-going= -k
344 FLAGS.opt-no-action= -n
346 FLAGS.opt-var-expanded= -v VAR -v VALUE
347 FLAGS.opt-var-literal= -V VAR -V VALUE
348 FLAGS.opt-warnings-as-errors= -W
351 FLAGS.sh-leading-plus= -n
352 FLAGS.vardebug= -k -dv FROM_CMDLINE=
353 FLAGS.varmod-match-escape= -dv
354 FLAGS.varname-dot-shell= -dpv
355 FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmline-plain'
357 # Some tests need extra post-processing.
358 SED_CMDS.opt-debug-g1= -e 's,${.CURDIR},CURDIR,'
359 SED_CMDS.opt-debug-g1+= -e '/Global Variables:/,/Suffixes:/d'
360 SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
361 SED_CMDS.varmod-subst-regex+= \
362 -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
363 SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,'
364 SED_CMDS.varshell+= -e 's,^${.SHELL:T}: ,,'
365 SED_CMDS.varshell+= -e '/command/s,No such.*,not found,'
366 SED_CMDS.varname-dot-shell= -e 's, = /.*, = (details omitted),'
367 SED_CMDS.varname-dot-shell+= -e 's,"/[^"]*","(details omitted)",'
368 SED_CMDS.varname-dot-shell+= -e 's,\[/[^]]*\],[(details omitted)],'
370 # Some tests need an additional round of postprocessing.
371 POSTPROC.counter= ${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
372 POSTPROC.deptgt-suffixes= \
373 ${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p'
374 POSTPROC.vardebug= ${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
375 POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
376 POSTPROC.varname-dot-shell= \
377 awk '/\.SHELL/ || /^ParseReadLine/'
378 POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
380 # Some tests reuse other tests, which makes them unnecessarily fragile.
381 export-all.rawout: export.mk
382 unexport.rawout: export.mk
383 unexport-env.rawout: export.mk
385 # End of the configuration section.
389 .sinclude "Makefile.inc"
390 .sinclude "Makefile.config"
392 UNIT_TESTS:= ${srcdir}
395 OUTFILES= ${TESTS:=.out}
399 CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp
400 CLEANFILES+= obj*.[och] lib*.a # posix1.mk
401 CLEANFILES+= issue* .[ab]* # suffixes.mk
402 CLEANDIRS= dir dummy # posix1.mk
414 .if defined(.PARSEDIR)
415 # ensure consistent results from sort(1)
421 .if ${.MAKE.MODE:Unormal:Mmeta} != ""
422 # we don't need the noise
426 # the tests are actually done with sub-makes.
427 .SUFFIXES: .mk .rawout .out
429 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
432 env -i PATH="$$PATH" ${ENV.${.TARGET:R}} \
434 -r -C ${.CURDIR} -f ${.IMPSRC} \
435 ${FLAGS.${.TARGET:R}:U-k} \
436 > ${.TARGET}.tmp 2>&1 \
437 && status=$$? || status=$$?; \
438 echo $$status > ${.TARGET:R}.status
439 @mv ${.TARGET}.tmp ${.TARGET}
441 # Post-process the test output so that the results can be compared.
443 # always pretend .MAKE was called 'make'
444 _SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
445 _SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
446 # replace anything after 'stopped in' with unit-tests
447 _SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
448 # strip ${.CURDIR}/ from the output
449 _SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g'
450 _SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
453 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.TARGET:R}} \
454 < ${.IMPSRC} > ${.TARGET}.tmp1
455 @${POSTPROC.${.TARGET:R}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
457 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
458 @mv ${.TARGET}.tmp2 ${.TARGET}
460 # Compare all output files
461 test: ${OUTFILES} .PHONY
463 for test in ${TESTS}; do \
464 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
465 || failed="$${failed}$${failed:+ }$${test}" ; \
467 if [ -n "$${failed}" ]; then \
468 echo "Failed tests: $${failed}" ; false ; \
470 echo "All tests passed" ; \
474 @for test in ${TESTS}; do \
475 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
476 || { echo "Replacing $${test}.exp" ; \
477 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
480 .if exists(${TEST_MAKE})
481 ${TESTS:=.rawout}: ${TEST_MAKE} ${.PARSEDIR}/Makefile
484 .sinclude <bsd.obj.mk>