summaryrefslogtreecommitdiffstats
path: root/tools/build/make_check
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-08-04 07:40:58 +0000
committerharti <harti@FreeBSD.org>2004-08-04 07:40:58 +0000
commit310a4a288df50ff92edfc5fd8c22c4de0745cc75 (patch)
tree8c90b33a88bdf2afee53b25496461865f0de4b8d /tools/build/make_check
parentb1d0efad03579e28e6605c36d4b21cd14e3c6978 (diff)
downloadFreeBSD-src-310a4a288df50ff92edfc5fd8c22c4de0745cc75.zip
FreeBSD-src-310a4a288df50ff92edfc5fd8c22c4de0745cc75.tar.gz
Add a regression test for the passing of command line
variable assignments via the MAKEFLAGS environment variable.
Diffstat (limited to 'tools/build/make_check')
-rw-r--r--tools/build/make_check/Makefile87
1 files changed, 87 insertions, 0 deletions
diff --git a/tools/build/make_check/Makefile b/tools/build/make_check/Makefile
index fcee42e..348e9dd 100644
--- a/tools/build/make_check/Makefile
+++ b/tools/build/make_check/Makefile
@@ -53,6 +53,9 @@ all:
@echo "Running test double_quotes2"
@! ${MAKE} double_quotes2 >/dev/null 2>&1 && true || ${MAKE} failure
@echo "PASS: Test double_quotes2 detected no regression."
+ @echo "Running test pass_cmd_vars "
+ @${MAKE} pass_cmd_vars || ${MAKE} failure
+ @echo "PASS: Test pass_cmd_vars detected no regression."
.if make(double)
# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
@@ -132,6 +135,90 @@ double_quotes2:
@cat /dev/null ""
.endif
+#
+# Check passing of variable via MAKEFLAGS
+#
+.if make(pass_cmd_vars)
+pass_cmd_vars:
+ @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
+ @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
+ @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
+ @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
+.endif
+
+.if make(pass_cmd_vars_1)
+# Check that the variable definition arrived from the calling make
+pass_cmd_vars_1:
+ @:
+
+.if ${CMD1} != cmd1 || ${CMD2} != cmd2
+.error "variables not passed through MAKEFLAGS"
+.endif
+
+# Check that the variable definition is in MAKEFLAGS
+.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2"
+.error "variable assignment not found in $${MAKEFLAGS}"
+.endif
+
+# Check that the variable definition is not in MFLAGS
+.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != ""
+.error "variable assignment found in $${MFLAGS}"
+.endif
+.endif
+
+.if make(pass_cmd_vars_2)
+# Check that we cannot override the passed variables
+CMD1=foo1
+CMD2=foo2
+
+.if ${CMD1} != cmd1 || ${CMD2} != cmd2
+.error "MAKEFLAGS-passed variables overridden"
+.endif
+
+pass_cmd_vars_2:
+ @:
+.endif
+
+.if make(pass_cmd_vars_3)
+# Check that we can override the passed variables on the next sub-make's
+# command line
+
+pass_cmd_vars_3:
+ @${MAKE} CMD1=foo1 pass_cmd_vars_3_1
+.endif
+
+.if make(pass_cmd_vars_3_1)
+.if ${CMD1} != foo1 || ${CMD2} != cmd2
+.error "MAKEFLAGS-passed variables not overridden on command line"
+.endif
+pass_cmd_vars_3_1:
+ @:
+.endif
+
+.if make(pass_cmd_vars_4)
+# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
+# by evaluating the .MAKEFLAGS target.
+
+.MAKEFLAGS: CMD1=baz1
+
+pass_cmd_vars_4:
+ @:
+# The following does not yet work (see standards/57295)
+# ${MAKE} pass_cmd_vars_4_1
+
+.if ${CMD1} != baz1 || ${CMD2} != cmd2
+.error "MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target"
+.endif
+
+.endif
+.if make(pass_cmd_vars_4_1)
+.if ${CMD1} != baz1 || ${CMD2} != cmd2
+.error "MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)"
+.endif
+pass_cmd_vars_4_1:
+ @:
+.endif
+
failure:
@echo "FAIL: Test failed: regression detected. See above."
@false
OpenPOWER on IntegriCloud