Makefile revision 1.263
1# $NetBSD: Makefile,v 1.263 2021/01/29 22:38:17 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-query 262TESTS+= opt-raw 263TESTS+= opt-silent 264TESTS+= opt-touch 265TESTS+= opt-touch-jobs 266TESTS+= opt-tracefile 267TESTS+= opt-var-expanded 268TESTS+= opt-var-literal 269TESTS+= opt-warnings-as-errors 270TESTS+= opt-where-am-i 271TESTS+= opt-x-reduce-exported 272TESTS+= order 273TESTS+= parse-var 274TESTS+= phony-end 275TESTS+= posix 276TESTS+= # posix1 # broken by reverting POSIX changes 277TESTS+= recursive 278TESTS+= sh 279TESTS+= sh-dots 280TESTS+= sh-errctl 281TESTS+= sh-flags 282TESTS+= sh-jobs 283TESTS+= sh-jobs-error 284TESTS+= sh-leading-at 285TESTS+= sh-leading-hyphen 286TESTS+= sh-leading-plus 287TESTS+= sh-meta-chars 288TESTS+= sh-multi-line 289TESTS+= sh-single-line 290TESTS+= shell-csh 291TESTS+= shell-custom 292TESTS+= shell-ksh 293TESTS+= shell-sh 294TESTS+= suff-add-later 295TESTS+= suff-clear-regular 296TESTS+= suff-clear-single 297TESTS+= suff-incomplete 298TESTS+= suff-lookup 299TESTS+= suff-main 300TESTS+= suff-main-several 301TESTS+= suff-phony 302TESTS+= suff-rebuild 303TESTS+= suff-self 304TESTS+= suff-transform-debug 305TESTS+= suff-transform-endless 306TESTS+= suff-transform-expand 307TESTS+= suff-transform-select 308TESTS+= sunshcmd 309TESTS+= ternary 310TESTS+= unexport 311TESTS+= unexport-env 312TESTS+= use-inference 313TESTS+= var-class 314TESTS+= var-class-cmdline 315TESTS+= var-class-env 316TESTS+= var-class-global 317TESTS+= var-class-local 318TESTS+= var-class-local-legacy 319TESTS+= var-op 320TESTS+= var-op-append 321TESTS+= var-op-assign 322TESTS+= var-op-default 323TESTS+= var-op-expand 324TESTS+= var-op-shell 325TESTS+= var-op-sunsh 326TESTS+= var-recursive 327TESTS+= varcmd 328TESTS+= vardebug 329TESTS+= varfind 330TESTS+= varmisc 331TESTS+= varmod 332TESTS+= varmod-assign 333TESTS+= varmod-defined 334TESTS+= varmod-edge 335TESTS+= varmod-exclam-shell 336TESTS+= varmod-extension 337TESTS+= varmod-gmtime 338TESTS+= varmod-hash 339TESTS+= varmod-head 340TESTS+= varmod-ifelse 341TESTS+= varmod-indirect 342TESTS+= varmod-l-name-to-value 343TESTS+= varmod-localtime 344TESTS+= varmod-loop 345TESTS+= varmod-match 346TESTS+= varmod-match-escape 347TESTS+= varmod-no-match 348TESTS+= varmod-order 349TESTS+= varmod-order-reverse 350TESTS+= varmod-order-shuffle 351TESTS+= varmod-path 352TESTS+= varmod-quote 353TESTS+= varmod-quote-dollar 354TESTS+= varmod-range 355TESTS+= varmod-remember 356TESTS+= varmod-root 357TESTS+= varmod-select-words 358TESTS+= varmod-shell 359TESTS+= varmod-subst 360TESTS+= varmod-subst-regex 361TESTS+= varmod-sysv 362TESTS+= varmod-tail 363TESTS+= varmod-to-abs 364TESTS+= varmod-to-lower 365TESTS+= varmod-to-many-words 366TESTS+= varmod-to-one-word 367TESTS+= varmod-to-separator 368TESTS+= varmod-to-upper 369TESTS+= varmod-undefined 370TESTS+= varmod-unique 371TESTS+= varname 372TESTS+= varname-dollar 373TESTS+= varname-dot-alltargets 374TESTS+= varname-dot-curdir 375TESTS+= varname-dot-includes 376TESTS+= varname-dot-includedfromdir 377TESTS+= varname-dot-includedfromfile 378TESTS+= varname-dot-libs 379TESTS+= varname-dot-make-dependfile 380TESTS+= varname-dot-make-expand_variables 381TESTS+= varname-dot-make-exported 382TESTS+= varname-dot-make-jobs 383TESTS+= varname-dot-make-jobs-prefix 384TESTS+= varname-dot-make-level 385TESTS+= varname-dot-make-makefile_preference 386TESTS+= varname-dot-make-makefiles 387TESTS+= varname-dot-make-meta-bailiwick 388TESTS+= varname-dot-make-meta-created 389TESTS+= varname-dot-make-meta-files 390TESTS+= varname-dot-make-meta-ignore_filter 391TESTS+= varname-dot-make-meta-ignore_paths 392TESTS+= varname-dot-make-meta-ignore_patterns 393TESTS+= varname-dot-make-meta-prefix 394TESTS+= varname-dot-make-mode 395TESTS+= varname-dot-make-path_filemon 396TESTS+= varname-dot-make-pid 397TESTS+= varname-dot-make-ppid 398TESTS+= varname-dot-make-save_dollars 399TESTS+= varname-dot-makeflags 400TESTS+= varname-dot-makeoverrides 401TESTS+= varname-dot-newline 402TESTS+= varname-dot-objdir 403TESTS+= varname-dot-parsedir 404TESTS+= varname-dot-parsefile 405TESTS+= varname-dot-path 406TESTS+= varname-dot-shell 407TESTS+= varname-dot-targets 408TESTS+= varname-empty 409TESTS+= varname-make 410TESTS+= varname-make_print_var_on_error 411TESTS+= varname-make_print_var_on_error-jobs 412TESTS+= varname-makefile 413TESTS+= varname-makeflags 414TESTS+= varname-pwd 415TESTS+= varname-vpath 416TESTS+= varparse-dynamic 417TESTS+= varparse-errors 418TESTS+= varparse-mod 419TESTS+= varparse-undef-partial 420TESTS+= varquote 421 422# Ideas for more tests: 423# char-0020-space.mk 424# char-005C-backslash.mk 425# escape-cond-str.mk 426# escape-cond-func-arg.mk 427# escape-cond-func-arg.mk 428# escape-varmod.mk 429# escape-varmod-define.mk 430# escape-varmod-match.mk 431# escape-varname.mk 432# escape-varassign-varname.mk 433# escape-varassign-varname-cmdline.mk 434# escape-varassign-value.mk 435# escape-varassign-value-cmdline.mk 436# escape-dependency-source.mk 437# escape-dependency-target.mk 438# escape-for-varname.mk 439# escape-for-item.mk 440# posix-*.mk (see posix.mk and posix1.mk) 441 442.if ${.OBJDIR} != ${.CURDIR} 443RO_OBJDIR:= ${.OBJDIR}/roobj 444.else 445RO_OBJDIR:= ${TMPDIR:U/tmp}/roobj 446.endif 447# Additional environment variables for some of the tests. 448# The base environment is -i PATH="$PATH". 449ENV.depsrc-optional+= TZ=UTC 450ENV.envfirst= FROM_ENV=value-from-env 451ENV.objdir-writable+= RO_OBJDIR=${RO_OBJDIR} 452ENV.varmisc= FROM_ENV=env 453ENV.varmisc+= FROM_ENV_BEFORE=env 454ENV.varmisc+= FROM_ENV_AFTER=env 455ENV.varmod-localtime+= TZ=Europe/Berlin 456ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2 457 458# Override make flags for some of the tests; default is -k. 459# If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of 460# settings FLAGS.test=-dv here, since that is closer to the test code. 461FLAGS.cond-func-make= via-cmdline 462FLAGS.directive-ifmake= first second 463FLAGS.doterror= # none, especially not -k 464FLAGS.jobs-error-indirect= # none, especially not -k 465FLAGS.jobs-error-nested= # none, especially not -k 466FLAGS.jobs-error-nested-make= # none, especially not -k 467FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain' 468 469# Some tests need extra postprocessing. 470SED_CMDS.dir= ${:D remove output from -DCLEANUP mode } 471SED_CMDS.dir+= -e '/^OpenDirs_Done:/d' 472SED_CMDS.dir+= -e '/^CachedDir /d' 473SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d' 474SED_CMDS.export-all= ${SED_CMDS.export} 475SED_CMDS.export-env= ${SED_CMDS.export} 476SED_CMDS.job-output-long-lines= \ 477 ${:D Job separators on their own line are ok. } \ 478 -e '/^--- job-[ab] ---$$/d' \ 479 ${:D Plain output lines are ok as well. } \ 480 ${:D They may come in multiples of 1024 or as 10000. } \ 481 -e '/^aa*$$/d' \ 482 -e '/^bb*$$/d' \ 483 ${:D The following lines should rather not occur since the job } \ 484 ${:D marker should always be at the beginning of the line. } \ 485 -e '/^aa*--- job-b ---$$/d' \ 486 -e '/^bb*--- job-a ---$$/d' 487SED_CMDS.objdir-writable= -e 's,${RO_OBJDIR},OBJDIR/roobj,g' 488SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} 489SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),' 490SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,' 491SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,' 492SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,' 493SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,' 494# The "-q" may be there or not, see jobs.c, variable shells. 495SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,' 496SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output} 497SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output} 498# For Compat_RunCommand, useShell == FALSE. 499SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,' 500# For Compat_RunCommand, useShell == TRUE. 501SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,' 502SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,' 503SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj} 504SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output} 505SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1} 506SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1} 507SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1} 508SED_CMDS.var-op-shell+= ${STD_SED_CMDS.shell} 509SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,' 510SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,' 511SED_CMDS.varmod-subst-regex+= \ 512 -e 's,\(Regex compilation error:\).*,\1 (details omitted),' 513SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 514SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 515SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' 516SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g' 517SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g' 518 519# Some tests need an additional round of postprocessing. 520POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/' 521POSTPROC.gnode-submake= awk '/Input graph/, /^$$/' 522POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p' 523 524# Some tests reuse other tests, which makes them unnecessarily fragile. 525export-all.rawout: export.mk 526unexport.rawout: export.mk 527unexport-env.rawout: export.mk 528 529# End of the configuration section. 530 531# Some standard sed commands, to be used in the SED_CMDS above. 532 533# Omit details such as process IDs from the output of the -dg1 option. 534STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,<curdir>,' 535STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,' 536STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,' 537STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,' 538STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,' 539STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,' 540 541# Omit details such as process IDs from the output of the -dj option. 542STD_SED_CMDS.dj= \ 543 -e '/Process/d;/JobFinish:/d' \ 544 -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \ 545 -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \ 546 -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \ 547 -e 's,^\( Command:\) .*,\1 <shell>,' 548 549# Reduce the noise for tests running with the -n option, since there is no 550# other way to suppress the echoing of the commands. 551STD_SED_CMDS.hide-from-output= \ 552 -e '/^echo hide-from-output/d' \ 553 -e 's,hide-from-output ,,' \ 554 -e 's,hide-from-output,,' 555 556# Normalize the output for error messages from the shell. 557# 558# $shell -c '...' 559# NetBSD sh ...: not found 560# NetBSD ksh ksh: ...: not found 561# bash 5.0.18 bash: ...: command not found 562# bash 5.1.0 bash: line 1: ...: command not found 563# dash dash: 1: ...: not found 564# 565# $shell -c '< /nonexistent' 566# NetBSD sh sh: cannot open /nonexistent: no such file 567# NetBSD ksh ksh: cannot open /nonexistent: No such file or directory 568# bash 5.0.18 bash: /nonexistent: No such file or directory 569# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 570# dash dash: 1: cannot open /nonexistent: No such file 571# 572# echo '< /nonexistent' | $shell 573# NetBSD sh sh: cannot open /nonexistent: no such file 574# NetBSD ksh ksh: <stdin>[1]: cannot open /nonexistent: No such file or directory 575# bash 5.0.18 bash: line 1: /nonexistent: No such file or directory 576# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 577# dash dash: 1: cannot open /nonexistent: No such file 578# 579STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,' 580STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,' 581STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,' 582 583# End of the configuration helpers section. 584 585.MAIN: all 586 587UNIT_TESTS:= ${.PARSEDIR} 588.PATH: ${UNIT_TESTS} 589 590.if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes 591OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@} 592.else 593OUTFILES= ${TESTS:=.out} 594.endif 595 596all: ${OUTFILES} 597 598CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp 599CLEANFILES+= obj*.[och] lib*.a # posix1.mk 600CLEANFILES+= issue* .[ab]* # suffixes.mk 601CLEANDIRS= dir dummy # posix1.mk 602 603clean: 604 rm -f ${CLEANFILES} 605 rm -rf ${CLEANDIRS} 606 607TEST_MAKE?= ${.MAKE} 608TOOL_SED?= sed 609 610# ensure consistent results from sort(1) 611LC_ALL= C 612LANG= C 613.export LANG LC_ALL 614 615MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc 616 617.if ${.MAKE.OS} == "NetBSD" 618LIMIT_RESOURCES?= ulimit -v 200000 619.endif 620LIMIT_RESOURCES?= : 621 622# Each test is run in a sub-make, to keep the tests for interfering with 623# each other, and because they use different environment variables and 624# command line options. 625.SUFFIXES: .mk .rawout .out 626.mk.rawout: 627 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX} 628 @set -eu; \ 629 ${LIMIT_RESOURCES}; \ 630 cd ${.OBJDIR}; \ 631 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \ 632 ${TEST_MAKE} \ 633 -r -C ${.CURDIR} -f ${.IMPSRC} \ 634 ${FLAGS.${.PREFIX:T}:U-k} \ 635 > ${.TARGET}.tmp 2>&1 \ 636 && status=$$? || status=$$?; \ 637 echo $$status > ${.TARGET:R}.status 638 @mv ${.TARGET}.tmp ${.TARGET} 639 640# Postprocess the test output so that the results can be compared. 641# 642# always pretend .MAKE was called 'make' 643_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' 644_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' 645_SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}[][0-9]* warning,make warning,' 646_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' 647# replace anything after 'stopped in' with unit-tests 648_SED_CMDS+= -e '/stopped/s, /.*, unit-tests,' 649# strip ${.CURDIR}/ from the output 650_SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g' 651_SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g' 652 653.rawout.out: 654 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \ 655 < ${.IMPSRC} > ${.TARGET}.tmp1 656 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2 657 @rm ${.TARGET}.tmp1 658 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2 659 @mv ${.TARGET}.tmp2 ${.TARGET} 660 661# Compare all output files 662test: ${OUTFILES} .PHONY 663 @failed= ; \ 664 for test in ${TESTS}; do \ 665 diff -u ${UNIT_TESTS}/$${test}.exp $${test}.out \ 666 || failed="$${failed}$${failed:+ }$${test}" ; \ 667 done ; \ 668 if [ -n "$${failed}" ]; then \ 669 echo "Failed tests: $${failed}" ; false ; \ 670 else \ 671 echo "All tests passed" ; \ 672 fi 673 674accept: 675 @for test in ${TESTS}; do \ 676 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 677 || { echo "Replacing $${test}.exp" ; \ 678 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 679 done 680 681# Note: only works for adding tests. 682# To remove a test, the $$mi file must be edited manually. 683sync-mi: 684 @set -eu; \ 685 cd "${MAKEFILE:tA:H}/../../.."; \ 686 mi="distrib/sets/lists/tests/mi"; \ 687 cvs update "$$mi"; \ 688 testsdir="usr.bin/make/unit-tests"; \ 689 fmt="./usr/tests/$$testsdir/%s\ttests-usr.bin-tests\tcompattestfile,atf\\n"; \ 690 cat "$$mi" > "$$mi.tmp"; \ 691 (cd "$$testsdir" && ls *.exp *.mk) | xargs printf "$$fmt" >> "$$mi.tmp"; \ 692 distrib/sets/fmt-list "$$mi.tmp"; \ 693 mv "$$mi.tmp" "$$mi"; \ 694 cvs diff "$$mi" || true 695 696.if exists(${TEST_MAKE}) 697${TESTS:=.rawout}: ${TEST_MAKE} 698# in meta mode, we *know* if a target script is impacted 699# by a makefile change. 700.if ${.MAKE.MODE:Unormal:Mmeta} == "" 701${TESTS:=.rawout}: ${.PARSEDIR}/Makefile 702.endif 703.endif 704 705.-include <bsd.obj.mk> 706