1# This is a generated file, do NOT edit! 2# See contrib/bmake/bsd.after-import.mk 3# 4# $Id: Makefile,v 1.224 2024/07/13 05:27:35 sjg Exp $ 5# 6# $NetBSD: Makefile,v 1.350 2024/07/07 09:37:00 rillig Exp $ 7# 8# Unit tests for make(1) 9# 10# The main targets are: 11# 12# all: 13# run all the tests 14# test: 15# run 'all', and compare to expected results 16# accept: 17# move generated output to expected results 18# 19# Settable variables 20# 21# TEST_MAKE 22# The make program to be tested. 23# 24# 25# Adding a test case 26# 27# Each feature should get its own set of tests in its own suitably 28# named makefile (*.mk), with its own set of expected results (*.exp), 29# and it should be added to the TESTS list. 30# 31 32.MAIN: all 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# for many tests we need a TMPDIR that will not collide 39# with other users. 40.if ${.OBJDIR} != ${.CURDIR} 41# easy 42TMPDIR:= ${.OBJDIR}/tmp 43.elif defined(TMPDIR) 44TMPDIR:= ${TMPDIR}/uid${.MAKE.UID} 45.else 46TMPDIR:= /tmp/uid${.MAKE.UID} 47.endif 48# make sure it exists 49.if !exist(${TMPDIR}) 50_!= mkdir -p ${TMPDIR} 51.endif 52 53# Each test is in a sub-makefile. 54# Keep the list sorted. 55# Any test that is commented out must be ignored in 56# src/tests/usr.bin/make/t_make.sh as well. 57#TESTS+= archive 58#TESTS+= archive-suffix 59TESTS+= cmd-errors 60TESTS+= cmd-errors-jobs 61TESTS+= cmd-errors-lint 62TESTS+= cmd-interrupt 63TESTS+= cmdline 64TESTS+= cmdline-redirect-stdin 65TESTS+= cmdline-undefined 66TESTS+= comment 67TESTS+= compat-error 68TESTS+= cond-cmp-numeric 69TESTS+= cond-cmp-numeric-eq 70TESTS+= cond-cmp-numeric-ge 71TESTS+= cond-cmp-numeric-gt 72TESTS+= cond-cmp-numeric-le 73TESTS+= cond-cmp-numeric-lt 74TESTS+= cond-cmp-numeric-ne 75TESTS+= cond-cmp-string 76TESTS+= cond-cmp-unary 77TESTS+= cond-eof 78TESTS+= cond-func 79TESTS+= cond-func-commands 80TESTS+= cond-func-defined 81TESTS+= cond-func-empty 82TESTS+= cond-func-exists 83TESTS+= cond-func-make 84TESTS+= cond-func-make-main 85TESTS+= cond-func-target 86TESTS+= cond-late 87TESTS+= cond-op 88TESTS+= cond-op-and 89TESTS+= cond-op-and-lint 90TESTS+= cond-op-not 91TESTS+= cond-op-or 92TESTS+= cond-op-or-lint 93TESTS+= cond-op-parentheses 94TESTS+= cond-short 95TESTS+= cond-token-number 96TESTS+= cond-token-plain 97TESTS+= cond-token-string 98TESTS+= cond-token-var 99TESTS+= cond-undef-lint 100TESTS+= counter 101TESTS+= counter-append 102TESTS+= dep 103TESTS+= dep-colon 104TESTS+= dep-colon-bug-cross-file 105TESTS+= dep-double-colon 106TESTS+= dep-double-colon-indep 107TESTS+= dep-duplicate 108TESTS+= dep-exclam 109TESTS+= dep-none 110TESTS+= dep-op-missing 111TESTS+= dep-percent 112TESTS+= dep-var 113TESTS+= dep-wildcards 114TESTS+= depsrc 115TESTS+= depsrc-end 116TESTS+= depsrc-exec 117TESTS+= depsrc-ignore 118TESTS+= depsrc-made 119TESTS+= depsrc-make 120TESTS+= depsrc-meta 121TESTS+= depsrc-nometa 122TESTS+= depsrc-nometa_cmp 123TESTS+= depsrc-nopath 124TESTS+= depsrc-notmain 125TESTS+= depsrc-optional 126TESTS+= depsrc-phony 127TESTS+= depsrc-precious 128TESTS+= depsrc-recursive 129TESTS+= depsrc-silent 130TESTS+= depsrc-use 131TESTS+= depsrc-usebefore 132TESTS+= depsrc-usebefore-double-colon 133TESTS+= depsrc-wait 134TESTS+= deptgt 135TESTS+= deptgt-begin 136TESTS+= deptgt-begin-fail 137TESTS+= deptgt-begin-fail-indirect 138TESTS+= deptgt-default 139TESTS+= deptgt-delete_on_error 140TESTS+= deptgt-end 141TESTS+= deptgt-end-fail 142TESTS+= deptgt-end-fail-all 143TESTS+= deptgt-end-fail-indirect 144TESTS+= deptgt-end-jobs 145TESTS+= deptgt-error 146TESTS+= deptgt-ignore 147TESTS+= deptgt-interrupt 148TESTS+= deptgt-main 149TESTS+= deptgt-makeflags 150TESTS+= deptgt-no_parallel 151TESTS+= deptgt-nopath 152TESTS+= deptgt-notparallel 153TESTS+= deptgt-objdir 154TESTS+= deptgt-order 155TESTS+= deptgt-path 156TESTS+= deptgt-path-suffix 157TESTS+= deptgt-phony 158TESTS+= deptgt-posix 159TESTS+= deptgt-precious 160TESTS+= deptgt-shell 161TESTS+= deptgt-silent 162TESTS+= deptgt-silent-jobs 163TESTS+= deptgt-stale 164TESTS+= deptgt-suffixes 165TESTS+= dir 166TESTS+= dir-expand-path 167TESTS+= directive 168TESTS+= directive-dinclude 169TESTS+= directive-elif 170TESTS+= directive-elifdef 171TESTS+= directive-elifmake 172TESTS+= directive-elifndef 173TESTS+= directive-elifnmake 174TESTS+= directive-else 175TESTS+= directive-endfor 176TESTS+= directive-endif 177TESTS+= directive-error 178TESTS+= directive-export 179TESTS+= directive-export-env 180TESTS+= directive-export-impl 181TESTS+= directive-export-gmake 182TESTS+= directive-export-literal 183TESTS+= directive-for 184TESTS+= directive-for-break 185TESTS+= directive-for-empty 186TESTS+= directive-for-errors 187TESTS+= directive-for-escape 188TESTS+= directive-for-generating-endif 189TESTS+= directive-for-if 190TESTS+= directive-for-lines 191TESTS+= directive-for-null 192TESTS+= directive-hyphen-include 193TESTS+= directive-if 194TESTS+= directive-if-nested 195TESTS+= directive-ifdef 196TESTS+= directive-ifmake 197TESTS+= directive-ifndef 198TESTS+= directive-ifnmake 199TESTS+= directive-include 200TESTS+= directive-include-fatal 201TESTS+= directive-include-guard 202TESTS+= directive-info 203TESTS+= directive-misspellings 204TESTS+= directive-sinclude 205TESTS+= directive-undef 206TESTS+= directive-unexport 207TESTS+= directive-unexport-env 208TESTS+= directive-warning 209TESTS+= dollar 210TESTS+= doterror 211TESTS+= dotwait 212TESTS+= error 213TESTS+= # escape # broken by reverting POSIX changes 214TESTS+= export 215TESTS+= export-all 216TESTS+= export-env 217TESTS+= export-variants 218TESTS+= gnode-submake 219TESTS+= hanoi-include 220TESTS+= impsrc 221TESTS+= include-main 222TESTS+= job-flags 223TESTS+= job-output-long-lines 224TESTS+= job-output-null 225TESTS+= jobs-empty-commands 226TESTS+= jobs-empty-commands-error 227TESTS+= jobs-error-indirect 228TESTS+= jobs-error-nested 229TESTS+= jobs-error-nested-make 230TESTS+= lint 231TESTS+= make-exported 232TESTS+= meta-cmd-cmp 233TESTS+= moderrs 234TESTS+= modmisc 235.if ${.MAKE.UID} > 0 236TESTS+= objdir-writable 237.endif 238TESTS+= opt 239TESTS+= opt-backwards 240TESTS+= opt-chdir 241TESTS+= opt-debug 242TESTS+= opt-debug-all 243TESTS+= opt-debug-archive 244TESTS+= opt-debug-curdir 245TESTS+= opt-debug-cond 246TESTS+= opt-debug-dir 247TESTS+= opt-debug-errors 248TESTS+= opt-debug-errors-jobs 249TESTS+= opt-debug-file 250TESTS+= opt-debug-for 251TESTS+= opt-debug-graph1 252TESTS+= opt-debug-graph2 253TESTS+= opt-debug-graph3 254TESTS+= opt-debug-hash 255TESTS+= opt-debug-jobs 256TESTS+= opt-debug-lint 257TESTS+= opt-debug-loud 258TESTS+= opt-debug-meta 259TESTS+= opt-debug-making 260TESTS+= opt-debug-no-rm 261TESTS+= opt-debug-parse 262TESTS+= opt-debug-suff 263TESTS+= opt-debug-targets 264TESTS+= opt-debug-varraw 265TESTS+= opt-debug-var 266TESTS+= opt-debug-x-trace 267TESTS+= opt-define 268TESTS+= opt-env 269TESTS+= opt-file 270TESTS+= opt-ignore 271TESTS+= opt-include-dir 272TESTS+= opt-jobs 273TESTS+= opt-jobs-internal 274TESTS+= opt-jobs-no-action 275TESTS+= opt-keep-going 276TESTS+= opt-keep-going-indirect 277TESTS+= opt-keep-going-multiple 278TESTS+= opt-m-include-dir 279TESTS+= opt-no-action 280TESTS+= opt-no-action-at-all 281TESTS+= opt-no-action-runflags 282TESTS+= opt-no-action-touch 283TESTS+= opt-query 284TESTS+= opt-raw 285TESTS+= opt-silent 286TESTS+= opt-touch 287TESTS+= opt-touch-jobs 288TESTS+= opt-tracefile 289TESTS+= opt-var-expanded 290TESTS+= opt-var-literal 291TESTS+= opt-version 292TESTS+= opt-warnings-as-errors 293TESTS+= opt-where-am-i 294TESTS+= opt-x-reduce-exported 295TESTS+= order 296TESTS+= parse 297TESTS+= parse-var 298TESTS+= phony-end 299TESTS+= posix 300TESTS+= # posix1 # broken by reverting POSIX changes 301TESTS+= recursive 302TESTS+= sh 303TESTS+= sh-dots 304TESTS+= sh-errctl 305TESTS+= sh-flags 306TESTS+= sh-jobs 307TESTS+= sh-jobs-error 308TESTS+= sh-leading-at 309TESTS+= sh-leading-hyphen 310TESTS+= sh-leading-plus 311TESTS+= sh-meta-chars 312TESTS+= sh-multi-line 313TESTS+= sh-single-line 314TESTS+= shell-csh 315TESTS+= shell-custom 316.if exists(/bin/ksh) 317TESTS+= shell-ksh 318.endif 319TESTS+= shell-sh 320TESTS+= suff-add-later 321TESTS+= suff-clear-regular 322TESTS+= suff-clear-single 323TESTS+= suff-incomplete 324TESTS+= suff-lookup 325TESTS+= suff-main 326TESTS+= suff-main-several 327TESTS+= suff-phony 328TESTS+= suff-rebuild 329TESTS+= suff-self 330TESTS+= suff-transform-debug 331TESTS+= suff-transform-endless 332TESTS+= suff-transform-expand 333TESTS+= suff-transform-select 334TESTS+= suff-use 335TESTS+= sunshcmd 336TESTS+= ternary 337TESTS+= unexport 338TESTS+= unexport-env 339TESTS+= use-inference 340TESTS+= var-readonly 341TESTS+= var-scope 342TESTS+= var-scope-cmdline 343TESTS+= var-scope-env 344TESTS+= var-scope-global 345TESTS+= var-scope-local 346TESTS+= var-scope-local-legacy 347TESTS+= var-eval-short 348TESTS+= var-op 349TESTS+= var-op-append 350TESTS+= var-op-assign 351TESTS+= var-op-default 352TESTS+= var-op-expand 353TESTS+= var-op-shell 354TESTS+= var-op-sunsh 355TESTS+= var-recursive 356TESTS+= varcmd 357TESTS+= vardebug 358TESTS+= varfind 359TESTS+= varmisc 360TESTS+= varmod 361TESTS+= varmod-assign 362TESTS+= varmod-assign-shell 363TESTS+= varmod-defined 364TESTS+= varmod-edge 365TESTS+= varmod-exclam-shell 366TESTS+= varmod-extension 367TESTS+= varmod-gmtime 368TESTS+= varmod-hash 369TESTS+= varmod-head 370TESTS+= varmod-ifelse 371TESTS+= varmod-indirect 372TESTS+= varmod-l-name-to-value 373TESTS+= varmod-localtime 374TESTS+= varmod-loop 375TESTS+= varmod-loop-delete 376TESTS+= varmod-loop-varname 377TESTS+= varmod-match 378TESTS+= varmod-match-escape 379TESTS+= varmod-mtime 380TESTS+= varmod-no-match 381TESTS+= varmod-order 382TESTS+= varmod-order-numeric 383TESTS+= varmod-order-reverse 384TESTS+= varmod-order-shuffle 385TESTS+= varmod-order-string 386TESTS+= varmod-path 387TESTS+= varmod-quote 388TESTS+= varmod-quote-dollar 389TESTS+= varmod-range 390TESTS+= varmod-remember 391TESTS+= varmod-root 392TESTS+= varmod-select-words 393TESTS+= varmod-shell 394TESTS+= varmod-subst 395TESTS+= varmod-subst-regex 396TESTS+= varmod-sun-shell 397TESTS+= varmod-sysv 398TESTS+= varmod-tail 399TESTS+= varmod-to-abs 400TESTS+= varmod-to-lower 401TESTS+= varmod-to-many-words 402TESTS+= varmod-to-one-word 403TESTS+= varmod-to-separator 404TESTS+= varmod-to-title 405TESTS+= varmod-to-upper 406TESTS+= varmod-undefined 407TESTS+= varmod-unique 408TESTS+= varname 409TESTS+= varname-dollar 410TESTS+= varname-dot-alltargets 411TESTS+= varname-dot-curdir 412TESTS+= varname-dot-includes 413TESTS+= varname-dot-includedfromdir 414TESTS+= varname-dot-includedfromfile 415TESTS+= varname-dot-libs 416TESTS+= varname-dot-make-dependfile 417TESTS+= varname-dot-make-expand_variables 418TESTS+= varname-dot-make-exported 419TESTS+= varname-dot-make-jobs 420TESTS+= varname-dot-make-jobs-prefix 421TESTS+= varname-dot-make-level 422TESTS+= varname-dot-make-makefile_preference 423TESTS+= varname-dot-make-makefiles 424TESTS+= varname-dot-make-meta-bailiwick 425TESTS+= varname-dot-make-meta-created 426TESTS+= varname-dot-make-meta-files 427.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" && ${TMPDIR:N/tmp*:N/var/tmp*} != "" 428# these tests will not work if TMPDIR is or is a subdir of 429# /tmp or /var/tmp 430.if ${.MAKE.PATH_FILEMON:N/dev/*} != "" || exists(${.MAKE.PATH_FILEMON}) 431TESTS+= varname-dot-make-meta-ignore_filter 432TESTS+= varname-dot-make-meta-ignore_paths 433TESTS+= varname-dot-make-meta-ignore_patterns 434TESTS+= varname-dot-make-path_filemon 435.else 436.warning Skipping tests that require ${.MAKE.PATH_FILEMON} 437.endif 438.endif 439TESTS+= varname-dot-make-meta-prefix 440TESTS+= varname-dot-make-mode 441TESTS+= varname-dot-make-pid 442TESTS+= varname-dot-make-ppid 443TESTS+= varname-dot-make-save_dollars 444TESTS+= varname-dot-makeflags 445TESTS+= varname-dot-makeoverrides 446TESTS+= varname-dot-newline 447TESTS+= varname-dot-objdir 448TESTS+= varname-dot-parsedir 449TESTS+= varname-dot-parsefile 450TESTS+= varname-dot-path 451TESTS+= varname-dot-shell 452TESTS+= varname-dot-suffixes 453TESTS+= varname-dot-targets 454TESTS+= varname-empty 455TESTS+= varname-make 456TESTS+= varname-make_print_var_on_error 457TESTS+= varname-make_print_var_on_error-jobs 458TESTS+= varname-makefile 459TESTS+= varname-makeflags 460TESTS+= varname-pwd 461TESTS+= varname-vpath 462TESTS+= varparse-dynamic 463TESTS+= varparse-errors 464TESTS+= varparse-mod 465TESTS+= varparse-undef-partial 466 467# some shells have quirks 468_shell := ${.SHELL:tA:T} 469.if ${_shell} == "dash" 470# dash fails -x output 471BROKEN_TESTS+= opt-debug-x-trace 472.elif ${_shell:N*ksh*} == "" 473BROKEN_TESTS+= \ 474 deptgt-silent-jobs \ 475 job-flags \ 476 job-output-long-lines \ 477 opt-debug-x-trace \ 478 sh-flags \ 479 var-op-shell \ 480 481.if ${_shell:Nmksh} == "" 482# more broken that pdksh 483BROKEN_TESTS+= \ 484 opt-jobs-no-action \ 485 sh-errctl \ 486 sh-leading-hyphen \ 487 488.endif 489.endif 490 491.if ${UTC_1:Uno} == "" 492# this will not work if UTC_1 is set empty 493BROKEN_TESTS+= varmod-localtime 494.endif 495 496.if ${.MAKE.OS:NDarwin} == "" 497BROKEN_TESTS+= shell-ksh 498.endif 499 500.if ${.MAKE.OS:NIRIX*} == "" 501BROKEN_TESTS+= \ 502 cmd-interrupt \ 503 deptgt-interrupt \ 504 job-output-null \ 505 opt-chdir \ 506 opt-debug-x-trace \ 507 sh-leading-hyphen \ 508 509.endif 510 511.if ${.MAKE.OS} == "SCO_SV" 512BROKEN_TESTS+= \ 513 opt-debug-graph[23] \ 514 varmod-localtime \ 515 varmod-to-separator \ 516 517.if ${_shell} == "bash" 518BROKEN_TESTS+= job-output-null 519.else 520BROKEN_TESTS+= \ 521 cmd-interrupt \ 522 job-flags \ 523 524.endif 525.endif 526 527# Some tests just do not work on some platforms or environments 528# so allow for some filtering. 529.if !empty(BROKEN_TESTS) 530.warning Skipping broken tests: ${BROKEN_TESTS:O:u} 531TESTS:= ${TESTS:${BROKEN_TESTS:S,^,N,:ts:}} 532.endif 533 534# Ideas for more tests: 535# char-0020-space.mk 536# char-005C-backslash.mk 537# escape-cond-str.mk 538# escape-cond-func-arg.mk 539# escape-varmod.mk 540# escape-varmod-define.mk 541# escape-varmod-match.mk 542# escape-varname.mk 543# escape-varassign-varname.mk 544# escape-varassign-varname-cmdline.mk 545# escape-varassign-value.mk 546# escape-varassign-value-cmdline.mk 547# escape-dependency-source.mk 548# escape-dependency-target.mk 549# escape-for-varname.mk 550# escape-for-item.mk 551# posix-*.mk (see posix.mk and posix1.mk) 552 553# Additional environment variables for some of the tests. 554# The base environment is -i PATH="$PATH". 555ENV.depsrc-optional+= TZ=UTC 556ENV.deptgt-phony+= MAKESYSPATH=. 557ENV.directive-undef= ENV_VAR=env-value 558ENV.opt-env= FROM_ENV=value-from-env 559ENV.opt-m-include-dir= ${MAKEOBJDIR:DMAKEOBJDIR=${MAKEOBJDIR}} 560ENV.varmisc= FROM_ENV=env 561ENV.varmisc+= FROM_ENV_BEFORE=env 562ENV.varmisc+= FROM_ENV_AFTER=env 563ENV.varmod-localtime+= TZ=${UTC_1:UEurope/Berlin} 564ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2 565 566# Override make flags for some of the tests; default is -k. 567# If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of 568# settings FLAGS.test=-dv here, since that is closer to the test code. 569FLAGS.cond-func-make= via-cmdline 570FLAGS.doterror= # none, especially not -k 571FLAGS.jobs-error-indirect= # none, especially not -k 572FLAGS.jobs-error-nested= # none, especially not -k 573FLAGS.jobs-error-nested-make= # none, especially not -k 574FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain' 575 576# Some tests need extra postprocessing. 577SED_CMDS.deptgt-phony= ${STD_SED_CMDS.dd} 578SED_CMDS.dir= ${STD_SED_CMDS.dd} 579SED_CMDS.directive-include-guard= \ 580 -e '/\.MAKEFLAGS/d' \ 581 -e '/^Parsing line/d' \ 582 -e '/^SetFilenameVars:/d' \ 583 -e '/^ParseDependency/d' \ 584 -e '/^ParseEOF:/d' 585SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d' 586.if ${.MAKE.OS:NCygwin} == "" 587SED_CMDS.export+= -e '/^WINDIR=/d' -e '/^SYSTEMROOT=/d' 588.endif 589SED_CMDS.export-all= ${SED_CMDS.export} 590SED_CMDS.export-env= ${SED_CMDS.export} 591SED_CMDS.cmdline= -e 's,uid${.MAKE.UID}/,,' 592SED_CMDS.job-output-long-lines= \ 593 ${:D Job separators on their own line are ok. } \ 594 -e '/^--- job-[ab] ---$$/d' \ 595 ${:D Plain output lines are ok as well. } \ 596 ${:D They may come in multiples of 1024 or as 10000. } \ 597 -e '/^aa*$$/d' \ 598 -e '/^bb*$$/d' \ 599 ${:D The following lines should rather not occur since the job } \ 600 ${:D marker should always be at the beginning of the line. } \ 601 -e '/^aa*--- job-b ---$$/d' \ 602 -e '/^bb*--- job-a ---$$/d' 603SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' \ 604 -e '/name/s,file,File,' \ 605 -e 's,no such,No such,' \ 606 -e 's,Filename,File name,' 607 608# meta line numbers can vary based on filemon implementation 609SED_CMDS.meta-ignore= -e 's,\(\.meta:\) [1-9][0-9]*:,\1 <line>:,' 610SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} 611SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2} 612SED_CMDS.opt-debug-graph3= ${STD_SED_CMDS.dg3} 613SED_CMDS.opt-debug-hash= -e 's,\(entries\)=[1-9][0-9],\1=<entries>,' 614SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),' 615SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,' 616SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,' 617SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,' 618SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,' 619# The "-q" may be there or not, see jobs.c, variable shells. 620SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,' 621SED_CMDS.opt-debug-lint+= ${STD_SED_CMDS.regex} 622SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output} 623SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output} 624SED_CMDS.opt-where-am-i= -e '/usr.obj/d' 625# For Compat_RunCommand, useShell == false. 626SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,' 627# For Compat_RunCommand, useShell == true. 628SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,' 629SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,' 630SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj} 631SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output} 632SED_CMDS.shell-csh= ${STD_SED_CMDS.white-space} 633SED_CMDS.sh-leading-hyphen= ${STD_SED_CMDS.shell} 634SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1} 635SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1} 636SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1} 637SED_CMDS.var-op-shell+= ${STD_SED_CMDS.shell} 638SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,' 639SED_CMDS.var-op-shell+= ${STD_SED_CMDS.white-space} 640SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,' 641SED_CMDS.varmod-mtime+= -e "s,\(.*\)': .*,\1': <ENOENT>," 642SED_CMDS.varmod-subst-regex+= ${STD_SED_CMDS.regex} 643SED_CMDS.varparse-errors+= ${STD_SED_CMDS.timestamp} 644SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore} 645SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore} 646SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore} 647SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 648SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 649SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' 650SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g' 651SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g' 652SED_CMDS.varname-empty= ${.OBJDIR .PARSEDIR .PATH .SHELL .SYSPATH:L:@v@-e '/\\$v/d'@} 653 654# Some tests need an additional round of postprocessing. 655POSTPROC.depsrc-wait= sed -e '/^---/d' -e 's,^\(: Making 3[abc]\)[123]$$,\1,' 656POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/' 657POSTPROC.gnode-submake= awk '/Input graph/, /^$$/' 658POSTPROC.varname-dot-make-mode= sed 's,^\(: Making [abc]\)[123]$$,\1,' 659 660# Some tests reuse other tests, which makes them unnecessarily fragile. 661export-all.rawout: export.mk 662unexport.rawout: export.mk 663unexport-env.rawout: export.mk 664 665# End of the configuration section. 666 667# Some standard sed commands, to be used in the SED_CMDS above. 668 669# In tests that use the debugging option -dd, ignore debugging output that is 670# only logged in -DCLEANUP mode. 671STD_SED_CMDS.dd= -e '/^OpenDirs_Done:/d' 672STD_SED_CMDS.dd+= -e '/^CachedDir /d' 673STD_SED_CMDS.dd+= -e 's, ${DEFSYSPATH:U/usr/share/mk} , <defsyspath> ,' 674 675# Omit details such as process IDs from the output of the -dg1 option. 676STD_SED_CMDS.dg1= -e '/\#.* \.$$/d' 677STD_SED_CMDS.dg1+= -e '/\.MAKE.PATH_FILEMON/d' 678STD_SED_CMDS.dg1+= -e '/^\#.*\/mk/d' 679STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,' 680STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,' 681STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,' 682STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.JOBS\.C *=\) .*,\1 <details omitted>,' 683STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,' 684STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,' 685STD_SED_CMDS.dg1+= -e 's,^\(\.SHELL *=\) .*,\1 <details omitted>,' 686STD_SED_CMDS.dg1+= -e '/\.SYSPATH/d' 687 688STD_SED_CMDS.dg2= ${STD_SED_CMDS.dg1} 689STD_SED_CMDS.dg2+= -e 's,\(last modified\) ..:..:.. ... ..\, ....,\1 <timestamp>,' 690STD_SED_CMDS.dg3= ${STD_SED_CMDS.dg2} 691 692# Omit details such as process IDs from the output of the -dj option. 693STD_SED_CMDS.dj= \ 694 -e '/Process/d;/JobFinish:/d' \ 695 -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \ 696 -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \ 697 -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \ 698 -e 's,^\( Command:\) .*,\1 <shell>,' 699 700# Reduce the noise for tests running with the -n option, since there is no 701# other way to suppress the echoing of the commands. 702STD_SED_CMDS.hide-from-output= \ 703 -e '/^echo hide-from-output/d' \ 704 -e 's,hide-from-output ,,' \ 705 -e 's,hide-from-output,,' 706 707# Normalize the output for error messages from the shell. 708# 709# $shell -c '...' 710# NetBSD sh ...: not found 711# NetBSD ksh ksh: ...: not found 712# bash 5.0.18 bash: ...: command not found 713# bash 5.1.0 bash: line 1: ...: command not found 714# dash dash: 1: ...: not found 715# 716# $shell -c '< /nonexistent' 717# NetBSD sh sh: cannot open /nonexistent: no such file 718# NetBSD ksh ksh: cannot open /nonexistent: No such file or directory 719# bash 5.0.18 bash: /nonexistent: No such file or directory 720# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 721# dash dash: 1: cannot open /nonexistent: No such file 722# 723# echo '< /nonexistent' | $shell 724# NetBSD sh sh: cannot open /nonexistent: no such file 725# NetBSD ksh ksh: <stdin>[1]: cannot open /nonexistent: No such file or directory 726# bash 5.0.18 bash: line 1: /nonexistent: No such file or directory 727# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 728# dash dash: 1: cannot open /nonexistent: No such file 729# 730STD_SED_CMDS.shell+= -e 's,^${.SHELL},${.SHELL:T},' 731STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,' 732STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,' 733STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,' 734STD_SED_CMDS.shell+= -e 's,: command not found,: not found,' 735 736STD_SED_CMDS.white-space= -e 's, *, ,g' -e 's, *$$,,' 737 738# The actual error messages for a failed regcomp or regexec differ between the 739# implementations. 740STD_SED_CMDS.regex= \ 741 -e 's,\(Regex compilation error:\).*,\1 (details omitted),' 742 743# Normalize timestamps from ':gmtime' or ':localtime' to '<timestamp>'. 744# See STD_SED_CMDS.dg2 for timestamps from the debug log. 745STD_SED_CMDS.timestamp= \ 746 -e 's,[A-Z][a-z][a-z] [A-Z][a-z][a-z] [ 0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [12][0-9][0-9][0-9],<timestamp>,' 747 748# End of the configuration helpers section. 749 750.sinclude "Makefile.inc" 751.sinclude "Makefile.config" 752 753UNIT_TESTS:= ${srcdir} 754.PATH: ${UNIT_TESTS} 755 756.if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes 757OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@} 758.else 759OUTFILES= ${TESTS:=.out} 760.endif 761 762all: ${OUTFILES} 763 764CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp 765CLEANFILES+= obj*.[och] lib*.a # posix1.mk 766CLEANFILES+= issue* .[ab]* # suffixes.mk 767CLEANDIRS= dir dummy *.tmp # posix1.mk 768 769clean: 770 rm -rf ${CLEANDIRS} 771 rm -f ${CLEANFILES} 772 773TEST_MAKE?= ${.MAKE} 774TOOL_SED?= sed 775TOOL_TR?= tr 776TOOL_DIFF?= diff 777DIFF_FLAGS?= -u 778 779# ensure consistent results from sort(1) 780LC_ALL= C 781LANG= C 782.export LANG LC_ALL 783 784.if ${.MAKE.MODE:Unormal:Mmeta} != "" 785# we don't need the noise 786_MKMSG_TEST= : 787.endif 788 789# Some Linux systems such as Fedora have deprecated egrep in favor of grep -E. 790.if ${.MAKE.OS:NLinux} == "" 791EGREP= grep -E 792.endif 793# Keep the classical definition for all other systems. Just as the bmake code 794# is kept compatible with C90, the tests are kept compatible with systems that 795# are several decades old and don't follow modern POSIX standards. 796EGREP?= egrep 797 798MAKE_TEST_ENV= EGREP="${EGREP}" 799MAKE_TEST_ENV+= MALLOC_OPTIONS="JA" # for jemalloc 100 800MAKE_TEST_ENV+= MALLOC_CONF="junk:true" # for jemalloc 510 801MAKE_TEST_ENV+= TMPDIR=${TMPDIR} 802 803.if ${.MAKE.OS} == "NetBSD" 804LIMIT_RESOURCES?= ulimit -v 300000 805.endif 806LIMIT_RESOURCES?= : 807 808# Each test is run in a sub-make, to keep the tests from interfering with 809# each other, and because they use different environment variables and 810# command line options. 811.SUFFIXES: .mk .rawout .out 812.mk.rawout: 813 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX} 814 @set -eu; \ 815 ${LIMIT_RESOURCES}; \ 816 cd ${.OBJDIR}; \ 817 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \ 818 ${TEST_MAKE} \ 819 -r -C ${.CURDIR} -f ${.IMPSRC} \ 820 ${FLAGS.${.PREFIX:T}:U-k} \ 821 > ${.TARGET}.tmp 2>&1 \ 822 && status=$$? || status=$$?; \ 823 echo $$status > ${.TARGET:R}.status 824 @mv ${.TARGET}.tmp ${.TARGET} 825 826# Postprocess the test output to make the output platform-independent. 827# 828# Replace anything after 'stopped in' with unit-tests 829_SED_CMDS+= -e '/stopped/s, in /.*, in unit-tests,' 830# Allow the test files to be placed anywhere. 831_SED_CMDS+= -e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = <some-dir>,' 832_SED_CMDS+= -e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = <some-dir>,' 833_SED_CMDS+= -e 's,${TMPDIR},<tmpdir>,g' -e 's,${TMPDIR:tA},<tmpdir>,g' 834# canonicalize ${.OBJDIR} and ${.CURDIR} 835_SED_CMDS+= -e 's,${.CURDIR},<curdir>,g' 836.if ${.OBJDIR} != ${.CURDIR} 837# yes this is inaccurate but none of the tests expect <objdir> anywhere 838# which we get depending on how MAKEOBJDIR is set. 839_SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g' -e 's,${.OBJDIR:tA},<curdir>,g' 840.endif 841# always pretend .MAKE was called 'make' 842_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' 843_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' 844_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' 845_SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}\(\[[1-9][0-9]*\]:\),make\1,' 846_SED_CMDS+= -e 's,<curdir>/,,g' 847_SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g' 848_SED_CMDS+= -e '/MAKE_VERSION/d' 849_SED_CMDS+= -e '/EGREP=/d' 850 851# on AT&T derived systems: false exits 255 not 1 852.if ${.MAKE.OS:N*BSD} != "" 853_SED_CMDS+= -e 's,\(Error code\) 255,\1 1,' 854.endif 855.if ${_shell:N*ksh*} == "" 856_SED_CMDS+= -e '/^set [+-]v/d' 857SED_CMDS.opt-debug-jobs+= -e 's,Command: ksh -v,Command: <shell>,' 858SED_CMDS.opt-debug-jobs+= -e 's,Command: <shell> -v,Command: <shell>,' 859.endif 860 861.rawout.out: 862 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \ 863 < ${.IMPSRC} > ${.TARGET}.tmp1 864 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2 865 @rm ${.TARGET}.tmp1 866 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2 867 @mv ${.TARGET}.tmp2 ${.TARGET} 868 869.if empty(DIFF_FLAGS) 870DIFF_ECHO= echo 871.else 872DIFF_ECHO= : 873.endif 874 875# Compare all output files 876test: ${OUTFILES} .PHONY 877 @failed= ; \ 878 for test in ${TESTS}; do \ 879 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out && continue || \ 880 ${DIFF_ECHO} diff ${UNIT_TESTS}/$${test}.exp $${test}.out; \ 881 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ 882 || failed="$${failed}$${failed:+ }$${test}" ; \ 883 done ; \ 884 if [ -n "$${failed}" ]; then \ 885 echo "Failed tests: $${failed}" ; false ; \ 886 else \ 887 echo "All tests passed" ; \ 888 lua=${LUA:Ulua} ; \ 889 have_lua=$$("$$lua" -e 'print "yes"' 2>&1) ; \ 890 if [ "$$have_lua" = "yes" -a -s ${.CURDIR}/check-expect.lua ]; then \ 891 (cd ${.CURDIR} && "$$lua" ./check-expect.lua *.mk); \ 892 fi; \ 893 fi 894 895accept: 896 @for test in ${TESTS}; do \ 897 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 898 || { echo "Replacing $${test}.exp" ; \ 899 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 900 done 901 902.if exists(${TEST_MAKE}) 903${TESTS:=.rawout}: ${TEST_MAKE} 904# in meta mode, we *know* if a target script is impacted 905# by a makefile change. 906.if ${.MAKE.MODE:Unormal:Mmeta} == "" 907${TESTS:=.rawout}: ${.PARSEDIR}/Makefile 908.endif 909.endif 910 911.sinclude <bsd.obj.mk> 912