1# This is a generated file, do NOT edit! 2# See contrib/bmake/bsd.after-import.mk 3# 4# $FreeBSD$ 5# $Id: Makefile,v 1.107 2020/11/02 00:40:25 sjg Exp $ 6# 7# $NetBSD: Makefile,v 1.181 2020/11/01 19:02:22 rillig Exp $ 8# 9# Unit tests for make(1) 10# 11# The main targets are: 12# 13# all: 14# run all the tests 15# test: 16# run 'all', and compare to expected results 17# accept: 18# move generated output to expected results 19# 20# Settable variables 21# 22# TEST_MAKE 23# The make program to be tested. 24# 25# 26# Adding a test case 27# 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. 31# 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. 35# 36 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 42TESTS+= archive-suffix 43TESTS+= cmd-interrupt 44TESTS+= cmdline 45TESTS+= comment 46TESTS+= cond-cmp-numeric 47TESTS+= cond-cmp-numeric-eq 48TESTS+= cond-cmp-numeric-ge 49TESTS+= cond-cmp-numeric-gt 50TESTS+= cond-cmp-numeric-le 51TESTS+= cond-cmp-numeric-lt 52TESTS+= cond-cmp-numeric-ne 53TESTS+= cond-cmp-string 54TESTS+= cond-cmp-unary 55TESTS+= cond-func 56TESTS+= cond-func-commands 57TESTS+= cond-func-defined 58TESTS+= cond-func-empty 59TESTS+= cond-func-exists 60TESTS+= cond-func-make 61TESTS+= cond-func-target 62TESTS+= cond-late 63TESTS+= cond-op 64TESTS+= cond-op-and 65TESTS+= cond-op-not 66TESTS+= cond-op-or 67TESTS+= cond-op-parentheses 68TESTS+= cond-short 69TESTS+= cond-token-number 70TESTS+= cond-token-plain 71TESTS+= cond-token-string 72TESTS+= cond-token-var 73TESTS+= cond-undef-lint 74TESTS+= cond1 75TESTS+= counter 76TESTS+= counter-append 77TESTS+= dep 78TESTS+= dep-colon 79TESTS+= dep-colon-bug-cross-file 80TESTS+= dep-double-colon 81TESTS+= dep-double-colon-indep 82TESTS+= dep-exclam 83TESTS+= dep-none 84TESTS+= dep-percent 85TESTS+= dep-var 86TESTS+= dep-wildcards 87TESTS+= depsrc 88TESTS+= depsrc-end 89TESTS+= depsrc-exec 90TESTS+= depsrc-ignore 91TESTS+= depsrc-made 92TESTS+= depsrc-make 93TESTS+= depsrc-meta 94TESTS+= depsrc-nometa 95TESTS+= depsrc-nometa_cmp 96TESTS+= depsrc-nopath 97TESTS+= depsrc-notmain 98TESTS+= depsrc-optional 99TESTS+= depsrc-phony 100TESTS+= depsrc-precious 101TESTS+= depsrc-recursive 102TESTS+= depsrc-silent 103TESTS+= depsrc-use 104TESTS+= depsrc-usebefore 105TESTS+= depsrc-usebefore-double-colon 106TESTS+= depsrc-wait 107TESTS+= deptgt 108TESTS+= deptgt-begin 109TESTS+= deptgt-default 110TESTS+= deptgt-delete_on_error 111TESTS+= deptgt-end 112TESTS+= deptgt-end-jobs 113TESTS+= deptgt-error 114TESTS+= deptgt-ignore 115TESTS+= deptgt-interrupt 116TESTS+= deptgt-main 117TESTS+= deptgt-makeflags 118TESTS+= deptgt-no_parallel 119TESTS+= deptgt-nopath 120TESTS+= deptgt-notparallel 121TESTS+= deptgt-objdir 122TESTS+= deptgt-order 123TESTS+= deptgt-path 124TESTS+= deptgt-path-suffix 125TESTS+= deptgt-phony 126TESTS+= deptgt-precious 127TESTS+= deptgt-shell 128TESTS+= deptgt-silent 129TESTS+= deptgt-stale 130TESTS+= deptgt-suffixes 131TESTS+= dir 132TESTS+= dir-expand-path 133TESTS+= directive 134TESTS+= directive-dinclude 135TESTS+= directive-elif 136TESTS+= directive-elifdef 137TESTS+= directive-elifmake 138TESTS+= directive-elifndef 139TESTS+= directive-elifnmake 140TESTS+= directive-else 141TESTS+= directive-endif 142TESTS+= directive-error 143TESTS+= directive-export 144TESTS+= directive-export-env 145TESTS+= directive-export-gmake 146TESTS+= directive-export-literal 147TESTS+= directive-for 148TESTS+= directive-for-generating-endif 149TESTS+= directive-hyphen-include 150TESTS+= directive-if 151TESTS+= directive-ifdef 152TESTS+= directive-ifmake 153TESTS+= directive-ifndef 154TESTS+= directive-ifnmake 155TESTS+= directive-include 156TESTS+= directive-include-fatal 157TESTS+= directive-info 158TESTS+= directive-sinclude 159TESTS+= directive-undef 160TESTS+= directive-unexport 161TESTS+= directive-unexport-env 162TESTS+= directive-warning 163TESTS+= directives 164TESTS+= dollar 165TESTS+= doterror 166TESTS+= dotwait 167TESTS+= envfirst 168TESTS+= error 169TESTS+= # escape # broken by reverting POSIX changes 170TESTS+= export 171TESTS+= export-all 172TESTS+= export-env 173TESTS+= export-variants 174TESTS+= forloop 175TESTS+= forsubst 176TESTS+= hanoi-include 177TESTS+= impsrc 178TESTS+= include-main 179#TESTS+= job-output-long-lines 180TESTS+= lint 181TESTS+= make-exported 182TESTS+= moderrs 183TESTS+= modmatch 184TESTS+= modmisc 185TESTS+= modts 186TESTS+= modword 187TESTS+= opt 188TESTS+= opt-backwards 189TESTS+= opt-chdir 190TESTS+= opt-debug 191TESTS+= opt-debug-all 192TESTS+= opt-debug-archive 193TESTS+= opt-debug-curdir 194TESTS+= opt-debug-cond 195TESTS+= opt-debug-dir 196TESTS+= opt-debug-errors 197TESTS+= opt-debug-file 198TESTS+= opt-debug-for 199TESTS+= opt-debug-graph1 200TESTS+= opt-debug-graph2 201TESTS+= opt-debug-graph3 202TESTS+= opt-debug-hash 203#TESTS+= opt-debug-jobs 204TESTS+= opt-debug-lint 205TESTS+= opt-debug-loud 206TESTS+= opt-debug-meta 207TESTS+= opt-debug-making 208TESTS+= opt-debug-no-rm 209TESTS+= opt-debug-parse 210TESTS+= opt-debug-suff 211TESTS+= opt-debug-targets 212TESTS+= opt-debug-varraw 213TESTS+= opt-debug-var 214TESTS+= opt-debug-x-trace 215TESTS+= opt-define 216TESTS+= opt-env 217TESTS+= opt-file 218TESTS+= opt-ignore 219TESTS+= opt-include-dir 220TESTS+= opt-jobs 221TESTS+= opt-jobs-internal 222TESTS+= opt-keep-going 223TESTS+= opt-m-include-dir 224TESTS+= opt-no-action 225TESTS+= opt-no-action-at-all 226TESTS+= opt-query 227TESTS+= opt-raw 228TESTS+= opt-silent 229TESTS+= opt-touch 230TESTS+= opt-tracefile 231TESTS+= opt-var-expanded 232TESTS+= opt-var-literal 233TESTS+= opt-warnings-as-errors 234TESTS+= opt-where-am-i 235TESTS+= opt-x-reduce-exported 236TESTS+= order 237TESTS+= parse-var 238TESTS+= phony-end 239TESTS+= posix 240TESTS+= # posix1 # broken by reverting POSIX changes 241TESTS+= qequals 242TESTS+= recursive 243TESTS+= sh 244TESTS+= sh-dots 245TESTS+= sh-jobs 246TESTS+= sh-jobs-error 247TESTS+= sh-leading-at 248TESTS+= sh-leading-hyphen 249TESTS+= sh-leading-plus 250TESTS+= sh-meta-chars 251TESTS+= sh-multi-line 252TESTS+= sh-single-line 253TESTS+= shell-csh 254TESTS+= shell-custom 255TESTS+= shell-ksh 256TESTS+= shell-sh 257TESTS+= suff-add-later 258TESTS+= suff-clear-regular 259TESTS+= suff-clear-single 260TESTS+= suff-lookup 261TESTS+= suff-main 262TESTS+= suff-rebuild 263TESTS+= suff-transform-endless 264TESTS+= suff-transform-expand 265TESTS+= suff-transform-select 266TESTS+= sunshcmd 267TESTS+= ternary 268TESTS+= unexport 269TESTS+= unexport-env 270TESTS+= use-inference 271TESTS+= var-class 272TESTS+= var-class-cmdline 273TESTS+= var-class-env 274TESTS+= var-class-global 275TESTS+= var-class-local 276TESTS+= var-class-local-legacy 277TESTS+= var-op 278TESTS+= var-op-append 279TESTS+= var-op-assign 280TESTS+= var-op-default 281TESTS+= var-op-expand 282TESTS+= var-op-shell 283TESTS+= var-op-sunsh 284TESTS+= var-recursive 285TESTS+= varcmd 286TESTS+= vardebug 287TESTS+= varfind 288TESTS+= varmisc 289TESTS+= varmod 290TESTS+= varmod-assign 291TESTS+= varmod-defined 292TESTS+= varmod-edge 293TESTS+= varmod-exclam-shell 294TESTS+= varmod-extension 295TESTS+= varmod-gmtime 296TESTS+= varmod-hash 297TESTS+= varmod-head 298TESTS+= varmod-ifelse 299TESTS+= varmod-l-name-to-value 300TESTS+= varmod-localtime 301TESTS+= varmod-loop 302TESTS+= varmod-match 303TESTS+= varmod-match-escape 304TESTS+= varmod-no-match 305TESTS+= varmod-order 306TESTS+= varmod-order-reverse 307TESTS+= varmod-order-shuffle 308TESTS+= varmod-path 309TESTS+= varmod-quote 310TESTS+= varmod-quote-dollar 311TESTS+= varmod-range 312TESTS+= varmod-remember 313TESTS+= varmod-root 314TESTS+= varmod-select-words 315TESTS+= varmod-shell 316TESTS+= varmod-subst 317TESTS+= varmod-subst-regex 318TESTS+= varmod-sysv 319TESTS+= varmod-tail 320TESTS+= varmod-to-abs 321TESTS+= varmod-to-lower 322TESTS+= varmod-to-many-words 323TESTS+= varmod-to-one-word 324TESTS+= varmod-to-separator 325TESTS+= varmod-to-upper 326TESTS+= varmod-undefined 327TESTS+= varmod-unique 328TESTS+= varname 329TESTS+= varname-dollar 330TESTS+= varname-dot-alltargets 331TESTS+= varname-dot-curdir 332TESTS+= varname-dot-includes 333TESTS+= varname-dot-includedfromdir 334TESTS+= varname-dot-includedfromfile 335TESTS+= varname-dot-libs 336TESTS+= varname-dot-make-dependfile 337TESTS+= varname-dot-make-expand_variables 338TESTS+= varname-dot-make-exported 339TESTS+= varname-dot-make-jobs 340TESTS+= varname-dot-make-jobs-prefix 341TESTS+= varname-dot-make-level 342TESTS+= varname-dot-make-makefile_preference 343TESTS+= varname-dot-make-makefiles 344TESTS+= varname-dot-make-meta-bailiwick 345TESTS+= varname-dot-make-meta-created 346TESTS+= varname-dot-make-meta-files 347TESTS+= varname-dot-make-meta-ignore_filter 348TESTS+= varname-dot-make-meta-ignore_paths 349TESTS+= varname-dot-make-meta-ignore_patterns 350TESTS+= varname-dot-make-meta-prefix 351TESTS+= varname-dot-make-mode 352TESTS+= varname-dot-make-path_filemon 353TESTS+= varname-dot-make-pid 354TESTS+= varname-dot-make-ppid 355TESTS+= varname-dot-make-save_dollars 356TESTS+= varname-dot-makeoverrides 357TESTS+= varname-dot-newline 358TESTS+= varname-dot-objdir 359TESTS+= varname-dot-parsedir 360TESTS+= varname-dot-parsefile 361TESTS+= varname-dot-path 362TESTS+= varname-dot-shell 363TESTS+= varname-dot-targets 364TESTS+= varname-empty 365TESTS+= varname-make 366TESTS+= varname-make_print_var_on_error 367TESTS+= varname-make_print_var_on_error-jobs 368TESTS+= varname-makefile 369TESTS+= varname-makeflags 370TESTS+= varname-pwd 371TESTS+= varname-vpath 372TESTS+= varparse-dynamic 373TESTS+= varparse-mod 374TESTS+= varparse-undef-partial 375TESTS+= varquote 376TESTS+= varshell 377 378# Additional environment variables for some of the tests. 379# The base environment is -i PATH="$PATH". 380ENV.envfirst= FROM_ENV=value-from-env 381ENV.varmisc= FROM_ENV=env 382ENV.varmisc+= FROM_ENV_BEFORE=env 383ENV.varmisc+= FROM_ENV_AFTER=env 384ENV.varmod-localtime+= TZ=Europe/Berlin 385 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. 389FLAGS.cond-func-make= via-cmdline 390FLAGS.directive-ifmake= first second 391FLAGS.doterror= # none 392FLAGS.envfirst= -e 393FLAGS.export= # none 394FLAGS.opt-ignore= -i 395FLAGS.opt-keep-going= -k 396FLAGS.opt-no-action= -n 397FLAGS.opt-query= -q 398FLAGS.opt-var-expanded= -v VAR -v VALUE 399FLAGS.opt-var-literal= -V VAR -V VALUE 400FLAGS.opt-warnings-as-errors= -W 401FLAGS.order= -j1 402FLAGS.recursive= -dL 403FLAGS.sh-leading-plus= -n 404FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmline-plain' 405 406# Some tests need extra postprocessing. 407SED_CMDS.export= \ 408 -e '/^[^=_A-Za-z0-9]*=/d' 409# these all share the same requirement 410.for t in export-all export-env 411SED_CMDS.$t= ${SED_CMDS.export} 412.endfor 413SED_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. } \ 418 -e '/^aa*$$/d' \ 419 -e '/^bb*$$/d' \ 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' 424SED_CMDS.opt-debug-graph1= \ 425 -e 's,${.CURDIR},CURDIR,' 426SED_CMDS.opt-debug-graph1+= \ 427 -e '/Global Variables:/,/Suffixes:/d' 428SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,' 429SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),' 430SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,' 431SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,' 432SED_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. 434SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: sh\) -q,\1,' 435SED_CMDS.varmod-subst-regex+= \ 436 -e 's,\(Regex compilation error:\).*,\1 (details omitted),' 437SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,' 438SED_CMDS.varshell+= -e 's,^${.SHELL:T}: ,,' 439SED_CMDS.varshell+= -e '/command/s,No such.*,not found,' 440SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 441SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 442SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' 443SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g' 444SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g' 445 446# Some tests need an additional round of postprocessing. 447POSTPROC.deptgt-suffixes= \ 448 ${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p' 449POSTPROC.varname= ${TOOL_SED} -n -e '/^MAGIC/p' -e '/^ORDER_/p' 450POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p' 451 452# Some tests reuse other tests, which makes them unnecessarily fragile. 453export-all.rawout: export.mk 454unexport.rawout: export.mk 455unexport-env.rawout: export.mk 456 457# End of the configuration section. 458 459.MAIN: all 460 461.sinclude "Makefile.inc" 462.sinclude "Makefile.config" 463 464UNIT_TESTS:= ${srcdir} 465.PATH: ${UNIT_TESTS} 466 467.if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes 468OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@} 469.else 470OUTFILES= ${TESTS:=.out} 471.endif 472 473all: ${OUTFILES} 474 475CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp 476CLEANFILES+= obj*.[och] lib*.a # posix1.mk 477CLEANFILES+= issue* .[ab]* # suffixes.mk 478CLEANDIRS= dir dummy # posix1.mk 479 480clean: 481 rm -f ${CLEANFILES} 482 rm -rf ${CLEANDIRS} 483 484TEST_MAKE?= ${.MAKE} 485TOOL_SED?= sed 486TOOL_TR?= tr 487TOOL_DIFF?= diff 488DIFF_FLAGS?= -u 489 490.if defined(.PARSEDIR) 491# ensure consistent results from sort(1) 492LC_ALL= C 493LANG= C 494.export LANG LC_ALL 495.endif 496 497.if ${.MAKE.MODE:Unormal:Mmeta} != "" 498# we don't need the noise 499_MKMSG_TEST= : 500.endif 501 502MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc 503 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 508.mk.rawout: 509 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX} 510 @set -eu; \ 511 cd ${.OBJDIR}; \ 512 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \ 513 ${TEST_MAKE} \ 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} 520 521# Postprocess the test output so that the results can be compared. 522# 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' 531 532.rawout.out: 533 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \ 534 < ${.IMPSRC} > ${.TARGET}.tmp1 535 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2 536 @rm ${.TARGET}.tmp1 537 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2 538 @mv ${.TARGET}.tmp2 ${.TARGET} 539 540# Compare all output files 541test: ${OUTFILES} .PHONY 542 @failed= ; \ 543 for test in ${TESTS}; do \ 544 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ 545 || failed="$${failed}$${failed:+ }$${test}" ; \ 546 done ; \ 547 if [ -n "$${failed}" ]; then \ 548 echo "Failed tests: $${failed}" ; false ; \ 549 else \ 550 echo "All tests passed" ; \ 551 fi 552 553accept: 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 ; } \ 558 done 559 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 566.endif 567.endif 568 569.sinclude <bsd.obj.mk> 570