Makefile revision 1.264
1# $NetBSD: Makefile,v 1.264 2021/01/30 12:46:38 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# we use these below but we might be an older make 35.MAKE.OS?= ${uname -s:L:sh} 36.MAKE.UID?= ${id -u:L:sh} 37 38# Each test is in a sub-makefile. 39# Keep the list sorted. 40# Any test that is commented out must be ignored in 41# src/tests/usr.bin/make/t_make.sh as well. 42TESTS+= archive 43TESTS+= archive-suffix 44TESTS+= cmd-errors 45TESTS+= cmd-errors-jobs 46TESTS+= cmd-errors-lint 47TESTS+= cmd-interrupt 48TESTS+= cmdline 49TESTS+= cmdline-undefined 50TESTS+= comment 51TESTS+= compat-error 52TESTS+= cond-cmp-numeric 53TESTS+= cond-cmp-numeric-eq 54TESTS+= cond-cmp-numeric-ge 55TESTS+= cond-cmp-numeric-gt 56TESTS+= cond-cmp-numeric-le 57TESTS+= cond-cmp-numeric-lt 58TESTS+= cond-cmp-numeric-ne 59TESTS+= cond-cmp-string 60TESTS+= cond-cmp-unary 61TESTS+= cond-eof 62TESTS+= cond-func 63TESTS+= cond-func-commands 64TESTS+= cond-func-defined 65TESTS+= cond-func-empty 66TESTS+= cond-func-exists 67TESTS+= cond-func-make 68TESTS+= cond-func-make-main 69TESTS+= cond-func-target 70TESTS+= cond-late 71TESTS+= cond-op 72TESTS+= cond-op-and 73TESTS+= cond-op-and-lint 74TESTS+= cond-op-not 75TESTS+= cond-op-or 76TESTS+= cond-op-or-lint 77TESTS+= cond-op-parentheses 78TESTS+= cond-short 79TESTS+= cond-token-number 80TESTS+= cond-token-plain 81TESTS+= cond-token-string 82TESTS+= cond-token-var 83TESTS+= cond-undef-lint 84TESTS+= cond1 85TESTS+= counter 86TESTS+= counter-append 87TESTS+= dep 88TESTS+= dep-colon 89TESTS+= dep-colon-bug-cross-file 90TESTS+= dep-double-colon 91TESTS+= dep-double-colon-indep 92TESTS+= dep-exclam 93TESTS+= dep-none 94TESTS+= dep-percent 95TESTS+= dep-var 96TESTS+= dep-wildcards 97TESTS+= depsrc 98TESTS+= depsrc-end 99TESTS+= depsrc-exec 100TESTS+= depsrc-ignore 101TESTS+= depsrc-made 102TESTS+= depsrc-make 103TESTS+= depsrc-meta 104TESTS+= depsrc-nometa 105TESTS+= depsrc-nometa_cmp 106TESTS+= depsrc-nopath 107TESTS+= depsrc-notmain 108TESTS+= depsrc-optional 109TESTS+= depsrc-phony 110TESTS+= depsrc-precious 111TESTS+= depsrc-recursive 112TESTS+= depsrc-silent 113TESTS+= depsrc-use 114TESTS+= depsrc-usebefore 115TESTS+= depsrc-usebefore-double-colon 116TESTS+= depsrc-wait 117TESTS+= deptgt 118TESTS+= deptgt-begin 119TESTS+= deptgt-begin-fail 120TESTS+= deptgt-begin-fail-indirect 121TESTS+= deptgt-default 122TESTS+= deptgt-delete_on_error 123TESTS+= deptgt-end 124TESTS+= deptgt-end-fail 125TESTS+= deptgt-end-fail-all 126TESTS+= deptgt-end-fail-indirect 127TESTS+= deptgt-end-jobs 128TESTS+= deptgt-error 129TESTS+= deptgt-ignore 130TESTS+= deptgt-interrupt 131TESTS+= deptgt-main 132TESTS+= deptgt-makeflags 133TESTS+= deptgt-no_parallel 134TESTS+= deptgt-nopath 135TESTS+= deptgt-notparallel 136TESTS+= deptgt-objdir 137TESTS+= deptgt-order 138TESTS+= deptgt-path 139TESTS+= deptgt-path-suffix 140TESTS+= deptgt-phony 141TESTS+= deptgt-precious 142TESTS+= deptgt-shell 143TESTS+= deptgt-silent 144TESTS+= deptgt-stale 145TESTS+= deptgt-suffixes 146TESTS+= dir 147TESTS+= dir-expand-path 148TESTS+= directive 149TESTS+= directive-dinclude 150TESTS+= directive-elif 151TESTS+= directive-elifdef 152TESTS+= directive-elifmake 153TESTS+= directive-elifndef 154TESTS+= directive-elifnmake 155TESTS+= directive-else 156TESTS+= directive-endfor 157TESTS+= directive-endif 158TESTS+= directive-error 159TESTS+= directive-export 160TESTS+= directive-export-env 161TESTS+= directive-export-impl 162TESTS+= directive-export-gmake 163TESTS+= directive-export-literal 164TESTS+= directive-for 165TESTS+= directive-for-errors 166TESTS+= directive-for-escape 167TESTS+= directive-for-generating-endif 168TESTS+= directive-for-lines 169TESTS+= directive-for-null 170TESTS+= directive-hyphen-include 171TESTS+= directive-if 172TESTS+= directive-if-nested 173TESTS+= directive-ifdef 174TESTS+= directive-ifmake 175TESTS+= directive-ifndef 176TESTS+= directive-ifnmake 177TESTS+= directive-include 178TESTS+= directive-include-fatal 179TESTS+= directive-info 180TESTS+= directive-misspellings 181TESTS+= directive-sinclude 182TESTS+= directive-undef 183TESTS+= directive-unexport 184TESTS+= directive-unexport-env 185TESTS+= directive-warning 186TESTS+= dollar 187TESTS+= doterror 188TESTS+= dotwait 189TESTS+= envfirst 190TESTS+= error 191TESTS+= # escape # broken by reverting POSIX changes 192TESTS+= export 193TESTS+= export-all 194TESTS+= export-env 195TESTS+= export-variants 196TESTS+= forloop 197TESTS+= forsubst 198TESTS+= gnode-submake 199TESTS+= hanoi-include 200TESTS+= impsrc 201TESTS+= include-main 202TESTS+= job-flags 203TESTS+= job-output-long-lines 204TESTS+= jobs-empty-commands 205TESTS+= jobs-error-indirect 206TESTS+= jobs-error-nested 207TESTS+= jobs-error-nested-make 208TESTS+= lint 209TESTS+= make-exported 210TESTS+= meta-cmd-cmp 211TESTS+= moderrs 212TESTS+= modmatch 213TESTS+= modmisc 214TESTS+= modts 215TESTS+= modword 216.if ${.MAKE.UID} > 0 217TESTS+= objdir-writable 218.endif 219TESTS+= opt 220TESTS+= opt-backwards 221TESTS+= opt-chdir 222TESTS+= opt-debug 223TESTS+= opt-debug-all 224TESTS+= opt-debug-archive 225TESTS+= opt-debug-curdir 226TESTS+= opt-debug-cond 227TESTS+= opt-debug-dir 228TESTS+= opt-debug-errors 229TESTS+= opt-debug-file 230TESTS+= opt-debug-for 231TESTS+= opt-debug-graph1 232TESTS+= opt-debug-graph2 233TESTS+= opt-debug-graph3 234TESTS+= opt-debug-hash 235TESTS+= opt-debug-jobs 236TESTS+= opt-debug-lint 237TESTS+= opt-debug-loud 238TESTS+= opt-debug-meta 239TESTS+= opt-debug-making 240TESTS+= opt-debug-no-rm 241TESTS+= opt-debug-parse 242TESTS+= opt-debug-suff 243TESTS+= opt-debug-targets 244TESTS+= opt-debug-varraw 245TESTS+= opt-debug-var 246TESTS+= opt-debug-x-trace 247TESTS+= opt-define 248TESTS+= opt-env 249TESTS+= opt-file 250TESTS+= opt-ignore 251TESTS+= opt-include-dir 252TESTS+= opt-jobs 253TESTS+= opt-jobs-internal 254TESTS+= opt-jobs-no-action 255TESTS+= opt-keep-going 256TESTS+= opt-keep-going-multiple 257TESTS+= opt-m-include-dir 258TESTS+= opt-no-action 259TESTS+= opt-no-action-at-all 260TESTS+= opt-no-action-runflags 261TESTS+= opt-no-action-touch 262TESTS+= opt-query 263TESTS+= opt-raw 264TESTS+= opt-silent 265TESTS+= opt-touch 266TESTS+= opt-touch-jobs 267TESTS+= opt-tracefile 268TESTS+= opt-var-expanded 269TESTS+= opt-var-literal 270TESTS+= opt-warnings-as-errors 271TESTS+= opt-where-am-i 272TESTS+= opt-x-reduce-exported 273TESTS+= order 274TESTS+= parse-var 275TESTS+= phony-end 276TESTS+= posix 277TESTS+= # posix1 # broken by reverting POSIX changes 278TESTS+= recursive 279TESTS+= sh 280TESTS+= sh-dots 281TESTS+= sh-errctl 282TESTS+= sh-flags 283TESTS+= sh-jobs 284TESTS+= sh-jobs-error 285TESTS+= sh-leading-at 286TESTS+= sh-leading-hyphen 287TESTS+= sh-leading-plus 288TESTS+= sh-meta-chars 289TESTS+= sh-multi-line 290TESTS+= sh-single-line 291TESTS+= shell-csh 292TESTS+= shell-custom 293TESTS+= shell-ksh 294TESTS+= shell-sh 295TESTS+= suff-add-later 296TESTS+= suff-clear-regular 297TESTS+= suff-clear-single 298TESTS+= suff-incomplete 299TESTS+= suff-lookup 300TESTS+= suff-main 301TESTS+= suff-main-several 302TESTS+= suff-phony 303TESTS+= suff-rebuild 304TESTS+= suff-self 305TESTS+= suff-transform-debug 306TESTS+= suff-transform-endless 307TESTS+= suff-transform-expand 308TESTS+= suff-transform-select 309TESTS+= sunshcmd 310TESTS+= ternary 311TESTS+= unexport 312TESTS+= unexport-env 313TESTS+= use-inference 314TESTS+= var-class 315TESTS+= var-class-cmdline 316TESTS+= var-class-env 317TESTS+= var-class-global 318TESTS+= var-class-local 319TESTS+= var-class-local-legacy 320TESTS+= var-op 321TESTS+= var-op-append 322TESTS+= var-op-assign 323TESTS+= var-op-default 324TESTS+= var-op-expand 325TESTS+= var-op-shell 326TESTS+= var-op-sunsh 327TESTS+= var-recursive 328TESTS+= varcmd 329TESTS+= vardebug 330TESTS+= varfind 331TESTS+= varmisc 332TESTS+= varmod 333TESTS+= varmod-assign 334TESTS+= varmod-defined 335TESTS+= varmod-edge 336TESTS+= varmod-exclam-shell 337TESTS+= varmod-extension 338TESTS+= varmod-gmtime 339TESTS+= varmod-hash 340TESTS+= varmod-head 341TESTS+= varmod-ifelse 342TESTS+= varmod-indirect 343TESTS+= varmod-l-name-to-value 344TESTS+= varmod-localtime 345TESTS+= varmod-loop 346TESTS+= varmod-match 347TESTS+= varmod-match-escape 348TESTS+= varmod-no-match 349TESTS+= varmod-order 350TESTS+= varmod-order-reverse 351TESTS+= varmod-order-shuffle 352TESTS+= varmod-path 353TESTS+= varmod-quote 354TESTS+= varmod-quote-dollar 355TESTS+= varmod-range 356TESTS+= varmod-remember 357TESTS+= varmod-root 358TESTS+= varmod-select-words 359TESTS+= varmod-shell 360TESTS+= varmod-subst 361TESTS+= varmod-subst-regex 362TESTS+= varmod-sysv 363TESTS+= varmod-tail 364TESTS+= varmod-to-abs 365TESTS+= varmod-to-lower 366TESTS+= varmod-to-many-words 367TESTS+= varmod-to-one-word 368TESTS+= varmod-to-separator 369TESTS+= varmod-to-upper 370TESTS+= varmod-undefined 371TESTS+= varmod-unique 372TESTS+= varname 373TESTS+= varname-dollar 374TESTS+= varname-dot-alltargets 375TESTS+= varname-dot-curdir 376TESTS+= varname-dot-includes 377TESTS+= varname-dot-includedfromdir 378TESTS+= varname-dot-includedfromfile 379TESTS+= varname-dot-libs 380TESTS+= varname-dot-make-dependfile 381TESTS+= varname-dot-make-expand_variables 382TESTS+= varname-dot-make-exported 383TESTS+= varname-dot-make-jobs 384TESTS+= varname-dot-make-jobs-prefix 385TESTS+= varname-dot-make-level 386TESTS+= varname-dot-make-makefile_preference 387TESTS+= varname-dot-make-makefiles 388TESTS+= varname-dot-make-meta-bailiwick 389TESTS+= varname-dot-make-meta-created 390TESTS+= varname-dot-make-meta-files 391TESTS+= varname-dot-make-meta-ignore_filter 392TESTS+= varname-dot-make-meta-ignore_paths 393TESTS+= varname-dot-make-meta-ignore_patterns 394TESTS+= varname-dot-make-meta-prefix 395TESTS+= varname-dot-make-mode 396TESTS+= varname-dot-make-path_filemon 397TESTS+= varname-dot-make-pid 398TESTS+= varname-dot-make-ppid 399TESTS+= varname-dot-make-save_dollars 400TESTS+= varname-dot-makeflags 401TESTS+= varname-dot-makeoverrides 402TESTS+= varname-dot-newline 403TESTS+= varname-dot-objdir 404TESTS+= varname-dot-parsedir 405TESTS+= varname-dot-parsefile 406TESTS+= varname-dot-path 407TESTS+= varname-dot-shell 408TESTS+= varname-dot-targets 409TESTS+= varname-empty 410TESTS+= varname-make 411TESTS+= varname-make_print_var_on_error 412TESTS+= varname-make_print_var_on_error-jobs 413TESTS+= varname-makefile 414TESTS+= varname-makeflags 415TESTS+= varname-pwd 416TESTS+= varname-vpath 417TESTS+= varparse-dynamic 418TESTS+= varparse-errors 419TESTS+= varparse-mod 420TESTS+= varparse-undef-partial 421TESTS+= varquote 422 423# Ideas for more tests: 424# char-0020-space.mk 425# char-005C-backslash.mk 426# escape-cond-str.mk 427# escape-cond-func-arg.mk 428# escape-cond-func-arg.mk 429# escape-varmod.mk 430# escape-varmod-define.mk 431# escape-varmod-match.mk 432# escape-varname.mk 433# escape-varassign-varname.mk 434# escape-varassign-varname-cmdline.mk 435# escape-varassign-value.mk 436# escape-varassign-value-cmdline.mk 437# escape-dependency-source.mk 438# escape-dependency-target.mk 439# escape-for-varname.mk 440# escape-for-item.mk 441# posix-*.mk (see posix.mk and posix1.mk) 442 443.if ${.OBJDIR} != ${.CURDIR} 444RO_OBJDIR:= ${.OBJDIR}/roobj 445.else 446RO_OBJDIR:= ${TMPDIR:U/tmp}/roobj 447.endif 448# Additional environment variables for some of the tests. 449# The base environment is -i PATH="$PATH". 450ENV.depsrc-optional+= TZ=UTC 451ENV.envfirst= FROM_ENV=value-from-env 452ENV.objdir-writable+= RO_OBJDIR=${RO_OBJDIR} 453ENV.varmisc= FROM_ENV=env 454ENV.varmisc+= FROM_ENV_BEFORE=env 455ENV.varmisc+= FROM_ENV_AFTER=env 456ENV.varmod-localtime+= TZ=Europe/Berlin 457ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2 458 459# Override make flags for some of the tests; default is -k. 460# If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of 461# settings FLAGS.test=-dv here, since that is closer to the test code. 462FLAGS.cond-func-make= via-cmdline 463FLAGS.directive-ifmake= first second 464FLAGS.doterror= # none, especially not -k 465FLAGS.jobs-error-indirect= # none, especially not -k 466FLAGS.jobs-error-nested= # none, especially not -k 467FLAGS.jobs-error-nested-make= # none, especially not -k 468FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain' 469 470# Some tests need extra postprocessing. 471SED_CMDS.dir= ${:D remove output from -DCLEANUP mode } 472SED_CMDS.dir+= -e '/^OpenDirs_Done:/d' 473SED_CMDS.dir+= -e '/^CachedDir /d' 474SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d' 475SED_CMDS.export-all= ${SED_CMDS.export} 476SED_CMDS.export-env= ${SED_CMDS.export} 477SED_CMDS.job-output-long-lines= \ 478 ${:D Job separators on their own line are ok. } \ 479 -e '/^--- job-[ab] ---$$/d' \ 480 ${:D Plain output lines are ok as well. } \ 481 ${:D They may come in multiples of 1024 or as 10000. } \ 482 -e '/^aa*$$/d' \ 483 -e '/^bb*$$/d' \ 484 ${:D The following lines should rather not occur since the job } \ 485 ${:D marker should always be at the beginning of the line. } \ 486 -e '/^aa*--- job-b ---$$/d' \ 487 -e '/^bb*--- job-a ---$$/d' 488SED_CMDS.objdir-writable= -e 's,${RO_OBJDIR},OBJDIR/roobj,g' 489SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} 490SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),' 491SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,' 492SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,' 493SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,' 494SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,' 495# The "-q" may be there or not, see jobs.c, variable shells. 496SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,' 497SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output} 498SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output} 499# For Compat_RunCommand, useShell == FALSE. 500SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,' 501# For Compat_RunCommand, useShell == TRUE. 502SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,' 503SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,' 504SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj} 505SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output} 506SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1} 507SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1} 508SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1} 509SED_CMDS.var-op-shell+= ${STD_SED_CMDS.shell} 510SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,' 511SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,' 512SED_CMDS.varmod-subst-regex+= \ 513 -e 's,\(Regex compilation error:\).*,\1 (details omitted),' 514SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 515SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 516SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' 517SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g' 518SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g' 519 520# Some tests need an additional round of postprocessing. 521POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/' 522POSTPROC.gnode-submake= awk '/Input graph/, /^$$/' 523POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p' 524 525# Some tests reuse other tests, which makes them unnecessarily fragile. 526export-all.rawout: export.mk 527unexport.rawout: export.mk 528unexport-env.rawout: export.mk 529 530# End of the configuration section. 531 532# Some standard sed commands, to be used in the SED_CMDS above. 533 534# Omit details such as process IDs from the output of the -dg1 option. 535STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,<curdir>,' 536STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,' 537STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,' 538STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,' 539STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,' 540STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,' 541 542# Omit details such as process IDs from the output of the -dj option. 543STD_SED_CMDS.dj= \ 544 -e '/Process/d;/JobFinish:/d' \ 545 -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \ 546 -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \ 547 -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \ 548 -e 's,^\( Command:\) .*,\1 <shell>,' 549 550# Reduce the noise for tests running with the -n option, since there is no 551# other way to suppress the echoing of the commands. 552STD_SED_CMDS.hide-from-output= \ 553 -e '/^echo hide-from-output/d' \ 554 -e 's,hide-from-output ,,' \ 555 -e 's,hide-from-output,,' 556 557# Normalize the output for error messages from the shell. 558# 559# $shell -c '...' 560# NetBSD sh ...: not found 561# NetBSD ksh ksh: ...: not found 562# bash 5.0.18 bash: ...: command not found 563# bash 5.1.0 bash: line 1: ...: command not found 564# dash dash: 1: ...: not found 565# 566# $shell -c '< /nonexistent' 567# NetBSD sh sh: cannot open /nonexistent: no such file 568# NetBSD ksh ksh: cannot open /nonexistent: No such file or directory 569# bash 5.0.18 bash: /nonexistent: No such file or directory 570# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 571# dash dash: 1: cannot open /nonexistent: No such file 572# 573# echo '< /nonexistent' | $shell 574# NetBSD sh sh: cannot open /nonexistent: no such file 575# NetBSD ksh ksh: <stdin>[1]: cannot open /nonexistent: No such file or directory 576# bash 5.0.18 bash: line 1: /nonexistent: No such file or directory 577# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 578# dash dash: 1: cannot open /nonexistent: No such file 579# 580STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,' 581STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,' 582STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,' 583 584# End of the configuration helpers section. 585 586.MAIN: all 587 588UNIT_TESTS:= ${.PARSEDIR} 589.PATH: ${UNIT_TESTS} 590 591.if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes 592OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@} 593.else 594OUTFILES= ${TESTS:=.out} 595.endif 596 597all: ${OUTFILES} 598 599CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp 600CLEANFILES+= obj*.[och] lib*.a # posix1.mk 601CLEANFILES+= issue* .[ab]* # suffixes.mk 602CLEANDIRS= dir dummy # posix1.mk 603 604clean: 605 rm -f ${CLEANFILES} 606 rm -rf ${CLEANDIRS} 607 608TEST_MAKE?= ${.MAKE} 609TOOL_SED?= sed 610 611# ensure consistent results from sort(1) 612LC_ALL= C 613LANG= C 614.export LANG LC_ALL 615 616MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc 617 618.if ${.MAKE.OS} == "NetBSD" 619LIMIT_RESOURCES?= ulimit -v 200000 620.endif 621LIMIT_RESOURCES?= : 622 623# Each test is run in a sub-make, to keep the tests for interfering with 624# each other, and because they use different environment variables and 625# command line options. 626.SUFFIXES: .mk .rawout .out 627.mk.rawout: 628 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX} 629 @set -eu; \ 630 ${LIMIT_RESOURCES}; \ 631 cd ${.OBJDIR}; \ 632 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \ 633 ${TEST_MAKE} \ 634 -r -C ${.CURDIR} -f ${.IMPSRC} \ 635 ${FLAGS.${.PREFIX:T}:U-k} \ 636 > ${.TARGET}.tmp 2>&1 \ 637 && status=$$? || status=$$?; \ 638 echo $$status > ${.TARGET:R}.status 639 @mv ${.TARGET}.tmp ${.TARGET} 640 641# Postprocess the test output so that the results can be compared. 642# 643# always pretend .MAKE was called 'make' 644_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' 645_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' 646_SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}[][0-9]* warning,make warning,' 647_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' 648# replace anything after 'stopped in' with unit-tests 649_SED_CMDS+= -e '/stopped/s, /.*, unit-tests,' 650# strip ${.CURDIR}/ from the output 651_SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g' 652_SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g' 653 654.rawout.out: 655 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \ 656 < ${.IMPSRC} > ${.TARGET}.tmp1 657 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2 658 @rm ${.TARGET}.tmp1 659 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2 660 @mv ${.TARGET}.tmp2 ${.TARGET} 661 662# Compare all output files 663test: ${OUTFILES} .PHONY 664 @failed= ; \ 665 for test in ${TESTS}; do \ 666 diff -u ${UNIT_TESTS}/$${test}.exp $${test}.out \ 667 || failed="$${failed}$${failed:+ }$${test}" ; \ 668 done ; \ 669 if [ -n "$${failed}" ]; then \ 670 echo "Failed tests: $${failed}" ; false ; \ 671 else \ 672 echo "All tests passed" ; \ 673 fi 674 675accept: 676 @for test in ${TESTS}; do \ 677 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 678 || { echo "Replacing $${test}.exp" ; \ 679 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 680 done 681 682# Note: only works for adding tests. 683# To remove a test, the $$mi file must be edited manually. 684sync-mi: 685 @set -eu; \ 686 cd "${MAKEFILE:tA:H}/../../.."; \ 687 mi="distrib/sets/lists/tests/mi"; \ 688 cvs update "$$mi"; \ 689 testsdir="usr.bin/make/unit-tests"; \ 690 fmt="./usr/tests/$$testsdir/%s\ttests-usr.bin-tests\tcompattestfile,atf\\n"; \ 691 cat "$$mi" > "$$mi.tmp"; \ 692 (cd "$$testsdir" && ls *.exp *.mk) | xargs printf "$$fmt" >> "$$mi.tmp"; \ 693 distrib/sets/fmt-list "$$mi.tmp"; \ 694 mv "$$mi.tmp" "$$mi"; \ 695 cvs diff "$$mi" || true 696 697.if exists(${TEST_MAKE}) 698${TESTS:=.rawout}: ${TEST_MAKE} 699# in meta mode, we *know* if a target script is impacted 700# by a makefile change. 701.if ${.MAKE.MODE:Unormal:Mmeta} == "" 702${TESTS:=.rawout}: ${.PARSEDIR}/Makefile 703.endif 704.endif 705 706.-include <bsd.obj.mk> 707