1# This is a generated file, do NOT edit! 2# See contrib/bmake/bsd.after-import.mk 3# 4# $Id: Makefile,v 1.207 2023/09/09 16:44:03 sjg Exp $ 5# 6# $NetBSD: Makefile,v 1.341 2023/09/09 16:41:04 sjg 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 223#TESTS+= 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 255#TESTS+= 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-upper 405TESTS+= varmod-undefined 406TESTS+= varmod-unique 407TESTS+= varname 408TESTS+= varname-dollar 409TESTS+= varname-dot-alltargets 410TESTS+= varname-dot-curdir 411TESTS+= varname-dot-includes 412TESTS+= varname-dot-includedfromdir 413TESTS+= varname-dot-includedfromfile 414TESTS+= varname-dot-libs 415TESTS+= varname-dot-make-dependfile 416TESTS+= varname-dot-make-expand_variables 417TESTS+= varname-dot-make-exported 418TESTS+= varname-dot-make-jobs 419TESTS+= varname-dot-make-jobs-prefix 420TESTS+= varname-dot-make-level 421TESTS+= varname-dot-make-makefile_preference 422TESTS+= varname-dot-make-makefiles 423TESTS+= varname-dot-make-meta-bailiwick 424TESTS+= varname-dot-make-meta-created 425TESTS+= varname-dot-make-meta-files 426.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" && ${TMPDIR:N/tmp*:N/var/tmp*} != "" 427# these tests will not work if TMPDIR is or is a subdir of 428# /tmp or /var/tmp 429.if ${.MAKE.PATH_FILEMON:N/dev/*} != "" || exists(${.MAKE.PATH_FILEMON}) 430TESTS+= varname-dot-make-meta-ignore_filter 431TESTS+= varname-dot-make-meta-ignore_paths 432TESTS+= varname-dot-make-meta-ignore_patterns 433TESTS+= varname-dot-make-path_filemon 434.else 435.warning Skipping tests that require ${.MAKE.PATH_FILEMON} 436.endif 437.endif 438TESTS+= varname-dot-make-meta-prefix 439TESTS+= varname-dot-make-mode 440TESTS+= varname-dot-make-pid 441TESTS+= varname-dot-make-ppid 442TESTS+= varname-dot-make-save_dollars 443TESTS+= varname-dot-makeflags 444TESTS+= varname-dot-makeoverrides 445TESTS+= varname-dot-newline 446TESTS+= varname-dot-objdir 447TESTS+= varname-dot-parsedir 448TESTS+= varname-dot-parsefile 449TESTS+= varname-dot-path 450TESTS+= varname-dot-shell 451TESTS+= varname-dot-suffixes 452TESTS+= varname-dot-targets 453TESTS+= varname-empty 454TESTS+= varname-make 455TESTS+= varname-make_print_var_on_error 456TESTS+= varname-make_print_var_on_error-jobs 457TESTS+= varname-makefile 458TESTS+= varname-makeflags 459TESTS+= varname-pwd 460TESTS+= varname-vpath 461TESTS+= varparse-dynamic 462TESTS+= varparse-errors 463TESTS+= varparse-mod 464TESTS+= varparse-undef-partial 465 466# some shells have quirks 467_shell := ${.SHELL:tA:T} 468.if ${_shell} == "dash" 469# dash fails -x output 470BROKEN_TESTS+= opt-debug-x-trace 471.elif ${_shell} == "ksh" 472BROKEN_TESTS+= sh-flags 473.endif 474 475.if ${UTC_1:Uno} == "" 476# this will not work if UTC_1 is set empty 477BROKEN_TESTS+= varmod-localtime 478.endif 479 480.if ${.MAKE.OS:NDarwin} == "" 481BROKEN_TESTS+= shell-ksh 482.endif 483 484.if ${.MAKE.OS:MIRIX*} != "" 485BROKEN_TESTS+= \ 486 cmd-interrupt \ 487 deptgt-interrupt \ 488 job-output-null \ 489 opt-chdir \ 490 opt-debug-x-trace \ 491 sh-leading-hyphen \ 492 493.endif 494 495.if ${.MAKE.OS} == "SCO_SV" 496BROKEN_TESTS+= \ 497 opt-debug-graph[23] \ 498 varmod-localtime \ 499 varmod-to-separator \ 500 501.if ${_shell} == "bash" 502BROKEN_TESTS+= job-output-null 503.else 504BROKEN_TESTS+= \ 505 cmd-interrupt \ 506 job-flags \ 507 508.endif 509.endif 510 511# Some tests just do not work on some platforms or environments 512# so allow for some filtering. 513.if !empty(BROKEN_TESTS) 514.warning Skipping broken tests: ${BROKEN_TESTS:O:u} 515TESTS:= ${TESTS:${BROKEN_TESTS:S,^,N,:ts:}} 516.endif 517 518# Ideas for more tests: 519# char-0020-space.mk 520# char-005C-backslash.mk 521# escape-cond-str.mk 522# escape-cond-func-arg.mk 523# escape-varmod.mk 524# escape-varmod-define.mk 525# escape-varmod-match.mk 526# escape-varname.mk 527# escape-varassign-varname.mk 528# escape-varassign-varname-cmdline.mk 529# escape-varassign-value.mk 530# escape-varassign-value-cmdline.mk 531# escape-dependency-source.mk 532# escape-dependency-target.mk 533# escape-for-varname.mk 534# escape-for-item.mk 535# posix-*.mk (see posix.mk and posix1.mk) 536 537# Additional environment variables for some of the tests. 538# The base environment is -i PATH="$PATH". 539ENV.depsrc-optional+= TZ=UTC 540ENV.deptgt-phony+= MAKESYSPATH=. 541ENV.directive-undef= ENV_VAR=env-value 542ENV.opt-env= FROM_ENV=value-from-env 543ENV.opt-m-include-dir= ${MAKEOBJDIR:DMAKEOBJDIR=${MAKEOBJDIR}} 544ENV.varmisc= FROM_ENV=env 545ENV.varmisc+= FROM_ENV_BEFORE=env 546ENV.varmisc+= FROM_ENV_AFTER=env 547ENV.varmod-localtime+= TZ=${UTC_1:UEurope/Berlin} 548ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2 549 550# Override make flags for some of the tests; default is -k. 551# If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of 552# settings FLAGS.test=-dv here, since that is closer to the test code. 553FLAGS.cond-func-make= via-cmdline 554FLAGS.doterror= # none, especially not -k 555FLAGS.jobs-error-indirect= # none, especially not -k 556FLAGS.jobs-error-nested= # none, especially not -k 557FLAGS.jobs-error-nested-make= # none, especially not -k 558FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain' 559 560# Some tests need extra postprocessing. 561SED_CMDS.deptgt-phony= ${STD_SED_CMDS.dd} 562SED_CMDS.dir= ${STD_SED_CMDS.dd} 563SED_CMDS.directive-include-guard= \ 564 -e '/\.MAKEFLAGS/d' \ 565 -e '/^Parsing line/d' \ 566 -e '/^SetFilenameVars:/d' \ 567 -e '/^ParseDependency/d' \ 568 -e '/^ParseEOF:/d' 569SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d' 570SED_CMDS.export-all= ${SED_CMDS.export} 571SED_CMDS.export-env= ${SED_CMDS.export} 572SED_CMDS.cmdline= -e 's,uid${.MAKE.UID}/,,' 573SED_CMDS.job-output-long-lines= \ 574 ${:D Job separators on their own line are ok. } \ 575 -e '/^--- job-[ab] ---$$/d' \ 576 ${:D Plain output lines are ok as well. } \ 577 ${:D They may come in multiples of 1024 or as 10000. } \ 578 -e '/^aa*$$/d' \ 579 -e '/^bb*$$/d' \ 580 ${:D The following lines should rather not occur since the job } \ 581 ${:D marker should always be at the beginning of the line. } \ 582 -e '/^aa*--- job-b ---$$/d' \ 583 -e '/^bb*--- job-a ---$$/d' 584SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' \ 585 -e '/name/s,file,File,' \ 586 -e 's,no such,No such,' \ 587 -e 's,Filename,File name,' 588 589# meta line numbers can vary based on filemon implementation 590SED_CMDS.meta-ignore= -e 's,\(\.meta:\) [1-9][0-9]*:,\1 <line>:,' 591SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} 592SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2} 593SED_CMDS.opt-debug-graph3= ${STD_SED_CMDS.dg3} 594SED_CMDS.opt-debug-hash= -e 's,\(numEntries\)=[1-9][0-9],\1=<entries>,' 595SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),' 596SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,' 597SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,' 598SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,' 599SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,' 600# The "-q" may be there or not, see jobs.c, variable shells. 601SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,' 602SED_CMDS.opt-debug-lint+= ${STD_SED_CMDS.regex} 603SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output} 604SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output} 605SED_CMDS.opt-where-am-i= -e '/usr.obj/d' 606# For Compat_RunCommand, useShell == false. 607SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,' 608# For Compat_RunCommand, useShell == true. 609SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,' 610SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,' 611SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj} 612SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output} 613SED_CMDS.shell-csh= ${STD_SED_CMDS.white-space} 614SED_CMDS.sh-leading-hyphen= ${STD_SED_CMDS.shell} 615SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1} 616SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1} 617SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1} 618SED_CMDS.var-op-shell+= ${STD_SED_CMDS.shell} 619SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,' 620SED_CMDS.var-op-shell+= ${STD_SED_CMDS.white-space} 621SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,' 622SED_CMDS.varmod-mtime+= -e "s,': .*,': <ENOENT>," 623SED_CMDS.varmod-subst-regex+= ${STD_SED_CMDS.regex} 624SED_CMDS.varparse-errors+= ${STD_SED_CMDS.timestamp} 625SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore} 626SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore} 627SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore} 628SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 629SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' 630SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' 631SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g' 632SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g' 633SED_CMDS.varname-empty= ${.OBJDIR .PARSEDIR .PATH .SHELL .SYSPATH:L:@v@-e '/\\$v/d'@} 634 635# Some tests need an additional round of postprocessing. 636POSTPROC.depsrc-wait= sed -e '/^---/d' -e 's,^\(: Making 3[abc]\)[123]$$,\1,' 637POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/' 638POSTPROC.gnode-submake= awk '/Input graph/, /^$$/' 639POSTPROC.varname-dot-make-mode= sed 's,^\(: Making [abc]\)[123]$$,\1,' 640 641# Some tests reuse other tests, which makes them unnecessarily fragile. 642export-all.rawout: export.mk 643unexport.rawout: export.mk 644unexport-env.rawout: export.mk 645 646# End of the configuration section. 647 648# Some standard sed commands, to be used in the SED_CMDS above. 649 650# In tests that use the debugging option -dd, ignore debugging output that is 651# only logged in -DCLEANUP mode. 652STD_SED_CMDS.dd= -e '/^OpenDirs_Done:/d' 653STD_SED_CMDS.dd+= -e '/^CachedDir /d' 654 655# Omit details such as process IDs from the output of the -dg1 option. 656STD_SED_CMDS.dg1= -e '/\#.* \.$$/d' 657STD_SED_CMDS.dg1+= -e '/\.MAKE.PATH_FILEMON/d' 658STD_SED_CMDS.dg1+= -e '/^\#.*\/mk/d' 659STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,' 660STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,' 661STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,' 662STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.JOBS\.C *=\) .*,\1 <details omitted>,' 663STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,' 664STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,' 665STD_SED_CMDS.dg1+= -e 's,^\(\.SHELL *=\) .*,\1 <details omitted>,' 666STD_SED_CMDS.dg1+= -e '/\.SYSPATH/d' 667 668STD_SED_CMDS.dg2= ${STD_SED_CMDS.dg1} 669STD_SED_CMDS.dg2+= -e 's,\(last modified\) ..:..:.. ... ..\, ....,\1 <timestamp>,' 670STD_SED_CMDS.dg3= ${STD_SED_CMDS.dg2} 671 672# Omit details such as process IDs from the output of the -dj option. 673STD_SED_CMDS.dj= \ 674 -e '/Process/d;/JobFinish:/d' \ 675 -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \ 676 -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \ 677 -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \ 678 -e 's,^\( Command:\) .*,\1 <shell>,' 679 680# Reduce the noise for tests running with the -n option, since there is no 681# other way to suppress the echoing of the commands. 682STD_SED_CMDS.hide-from-output= \ 683 -e '/^echo hide-from-output/d' \ 684 -e 's,hide-from-output ,,' \ 685 -e 's,hide-from-output,,' 686 687# Normalize the output for error messages from the shell. 688# 689# $shell -c '...' 690# NetBSD sh ...: not found 691# NetBSD ksh ksh: ...: not found 692# bash 5.0.18 bash: ...: command not found 693# bash 5.1.0 bash: line 1: ...: command not found 694# dash dash: 1: ...: not found 695# 696# $shell -c '< /nonexistent' 697# NetBSD sh sh: cannot open /nonexistent: no such file 698# NetBSD ksh ksh: cannot open /nonexistent: No such file or directory 699# bash 5.0.18 bash: /nonexistent: No such file or directory 700# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 701# dash dash: 1: cannot open /nonexistent: No such file 702# 703# echo '< /nonexistent' | $shell 704# NetBSD sh sh: cannot open /nonexistent: no such file 705# NetBSD ksh ksh: <stdin>[1]: cannot open /nonexistent: No such file or directory 706# bash 5.0.18 bash: line 1: /nonexistent: No such file or directory 707# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory 708# dash dash: 1: cannot open /nonexistent: No such file 709# 710STD_SED_CMDS.shell+= -e 's,^${.SHELL},${.SHELL:T},' 711STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,' 712STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,' 713STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,' 714STD_SED_CMDS.shell+= -e 's,: command not found,: not found,' 715 716STD_SED_CMDS.white-space= -e 's, *, ,g' -e 's, *$$,,' 717 718# The actual error messages for a failed regcomp or regexec differ between the 719# implementations. 720STD_SED_CMDS.regex= \ 721 -e 's,\(Regex compilation error:\).*,\1 (details omitted),' 722 723# Normalize timestamps from ':gmtime' or ':localtime' to '<timestamp>'. 724# See STD_SED_CMDS.dg2 for timestamps from the debug log. 725STD_SED_CMDS.timestamp= \ 726 -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>,' 727 728# End of the configuration helpers section. 729 730.sinclude "Makefile.inc" 731.sinclude "Makefile.config" 732 733UNIT_TESTS:= ${srcdir} 734.PATH: ${UNIT_TESTS} 735 736.if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes 737OUTFILES= ${TESTS:@test@${.CURDIR:tA}/${test}.out@} 738.else 739OUTFILES= ${TESTS:=.out} 740.endif 741 742all: ${OUTFILES} 743 744CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp 745CLEANFILES+= obj*.[och] lib*.a # posix1.mk 746CLEANFILES+= issue* .[ab]* # suffixes.mk 747CLEANDIRS= dir dummy # posix1.mk 748 749clean: 750 rm -f ${CLEANFILES} 751 rm -rf ${CLEANDIRS} 752 753TEST_MAKE?= ${.MAKE} 754TOOL_SED?= sed 755TOOL_TR?= tr 756TOOL_DIFF?= diff 757DIFF_FLAGS?= -u 758 759.if defined(.PARSEDIR) 760# ensure consistent results from sort(1) 761LC_ALL= C 762LANG= C 763.export LANG LC_ALL 764.endif 765 766.if ${.MAKE.MODE:Unormal:Mmeta} != "" 767# we don't need the noise 768_MKMSG_TEST= : 769.endif 770 771# Some Linux systems such as Fedora have deprecated egrep in favor of grep -E. 772.if ${.MAKE.OS:NLinux} == "" 773EGREP= grep -E 774.endif 775# Keep the classical definition for all other systems. Just as the bmake code 776# is kept compatible with C90, the tests are kept compatible with systems that 777# are several decades old and don't follow modern POSIX standards. 778EGREP?= egrep 779 780MAKE_TEST_ENV= EGREP="${EGREP}" 781MAKE_TEST_ENV+= MALLOC_OPTIONS="JA" # for jemalloc 100 782MAKE_TEST_ENV+= MALLOC_CONF="junk:true" # for jemalloc 510 783MAKE_TEST_ENV+= TMPDIR=${TMPDIR} 784 785.if ${.MAKE.OS} == "NetBSD" 786LIMIT_RESOURCES?= ulimit -v 300000 787.endif 788LIMIT_RESOURCES?= : 789 790# Each test is run in a sub-make, to keep the tests from interfering with 791# each other, and because they use different environment variables and 792# command line options. 793.SUFFIXES: .mk .rawout .out 794.mk.rawout: 795 @${_MKMSG_TEST:Uecho '# test '} ${.PREFIX} 796 @set -eu; \ 797 ${LIMIT_RESOURCES}; \ 798 cd ${.OBJDIR}; \ 799 env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \ 800 ${TEST_MAKE} \ 801 -r -C ${.CURDIR} -f ${.IMPSRC} \ 802 ${FLAGS.${.PREFIX:T}:U-k} \ 803 > ${.TARGET}.tmp 2>&1 \ 804 && status=$$? || status=$$?; \ 805 echo $$status > ${.TARGET:R}.status 806 @mv ${.TARGET}.tmp ${.TARGET} 807 808# Postprocess the test output to make the output platform-independent. 809# 810# Replace anything after 'stopped in' with unit-tests 811_SED_CMDS+= -e '/stopped/s, /.*, unit-tests,' 812# Allow the test files to be placed anywhere. 813_SED_CMDS+= -e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = <some-dir>,' 814_SED_CMDS+= -e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = <some-dir>,' 815_SED_CMDS+= -e 's,${TMPDIR},<tmpdir>,g' -e 's,${TMPDIR:tA},<tmpdir>,g' 816# canonicalize ${.OBJDIR} and ${.CURDIR} 817_SED_CMDS+= -e 's,${.CURDIR},<curdir>,g' 818.if ${.OBJDIR} != ${.CURDIR} 819# yes this is inaccurate but none of the tests expect <objdir> anywhere 820# which we get depending on how MAKEOBJDIR is set. 821_SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g' -e 's,${.OBJDIR:tA},<curdir>,g' 822.endif 823# always pretend .MAKE was called 'make' 824_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' 825_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' 826_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' 827_SED_CMDS+= -e 's,<curdir>/,,g' 828_SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g' 829_SED_CMDS+= -e '/MAKE_VERSION/d' 830_SED_CMDS+= -e '/EGREP=/d' 831 832# on AT&T derived systems: false exits 255 not 1 833.if ${.MAKE.OS:N*BSD} != "" 834_SED_CMDS+= -e 's,\(Error code\) 255,\1 1,' 835.endif 836.if ${.SHELL:T} == "ksh" 837_SED_CMDS+= -e '/^set [+-]v/d' 838.endif 839 840.rawout.out: 841 @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \ 842 < ${.IMPSRC} > ${.TARGET}.tmp1 843 @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2 844 @rm ${.TARGET}.tmp1 845 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2 846 @mv ${.TARGET}.tmp2 ${.TARGET} 847 848.if empty(DIFF_FLAGS) 849DIFF_ECHO= echo 850.else 851DIFF_ECHO= : 852.endif 853 854# Compare all output files 855test: ${OUTFILES} .PHONY 856 @failed= ; \ 857 for test in ${TESTS}; do \ 858 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out && continue || \ 859 ${DIFF_ECHO} diff ${UNIT_TESTS}/$${test}.exp $${test}.out; \ 860 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ 861 || failed="$${failed}$${failed:+ }$${test}" ; \ 862 done ; \ 863 if [ -n "$${failed}" ]; then \ 864 echo "Failed tests: $${failed}" ; false ; \ 865 else \ 866 echo "All tests passed" ; \ 867 fi 868 869accept: 870 @for test in ${TESTS}; do \ 871 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 872 || { echo "Replacing $${test}.exp" ; \ 873 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 874 done 875 876.if exists(${TEST_MAKE}) 877${TESTS:=.rawout}: ${TEST_MAKE} 878# in meta mode, we *know* if a target script is impacted 879# by a makefile change. 880.if ${.MAKE.MODE:Unormal:Mmeta} == "" 881${TESTS:=.rawout}: ${.PARSEDIR}/Makefile 882.endif 883.endif 884 885.sinclude <bsd.obj.mk> 886