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