diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:21:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:21:29 +0000 |
commit | 29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc (patch) | |
tree | 63ef546b10a81d461e5cf5ed9e98a68cd7dee1aa /src/kmk/tests/scripts/variables/MAKE | |
parent | Initial commit. (diff) | |
download | kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.tar.xz kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.zip |
Adding upstream version 1:0.1.9998svn3589+dfsg.upstream/1%0.1.9998svn3589+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKE | 24 | ||||
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKECMDGOALS | 52 | ||||
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKEFILES | 53 | ||||
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKEFILE_LIST | 30 | ||||
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKEFLAGS | 45 | ||||
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKELEVEL | 45 | ||||
-rw-r--r-- | src/kmk/tests/scripts/variables/MAKE_RESTARTS | 61 |
7 files changed, 310 insertions, 0 deletions
diff --git a/src/kmk/tests/scripts/variables/MAKE b/src/kmk/tests/scripts/variables/MAKE new file mode 100644 index 0000000..dc62160 --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKE @@ -0,0 +1,24 @@ +# -*-perl-*- + +$description = "Test proper behavior of the MAKE variable"; + +$details = "DETAILS"; + +run_make_test(q! +TMP := $(MAKE) +MAKE := $(subst X=$(X),,$(MAKE)) +all: + @echo $(TMP) + $(MAKE) -f #MAKEFILE# foo + +foo: + @echo $(MAKE) +!, + '', + "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n" + . "#MAKE#[1]: Entering directory '#PWD#'\n" + . "#MAKEPATH#\n#MAKE#[1]: Leaving directory '#PWD#'\n"); + +rmfiles("foo"); + +1; diff --git a/src/kmk/tests/scripts/variables/MAKECMDGOALS b/src/kmk/tests/scripts/variables/MAKECMDGOALS new file mode 100644 index 0000000..879283b --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKECMDGOALS @@ -0,0 +1,52 @@ +# -*-perl-*- + +$description = "Test the MAKECMDGOALS variable."; + +$details = "\ +We construct a makefile with various targets, all of which print out +\$(MAKECMDGOALS), then call it different ways."; + +open(MAKEFILE,"> $makefile"); +print MAKEFILE "\ +.DEFAULT all: + \@echo \$(MAKECMDGOALS) +"; +close(MAKEFILE); + +# TEST #1 + +&run_make_with_options($makefile, + "", + &get_logfile, + 0); +$answer = "\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #2 + +&run_make_with_options($makefile, + "all", + &get_logfile, + 0); +$answer = "all\n"; +&compare_output($answer,&get_logfile(1)); + + +# TEST #3 + +&run_make_with_options($makefile, + "foo bar baz yaz", + &get_logfile, + 0); +$answer = "foo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\n"; +&compare_output($answer,&get_logfile(1)); + + +# This tells the test driver that the perl test script executed properly. +1; + + + + + + diff --git a/src/kmk/tests/scripts/variables/MAKEFILES b/src/kmk/tests/scripts/variables/MAKEFILES new file mode 100644 index 0000000..b23da8e --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKEFILES @@ -0,0 +1,53 @@ +# -*-perl-*- + +$description = "Test the MAKEFILES variable."; + +$makefile2 = &get_tmpfile; +$makefile3 = &get_tmpfile; + +open(MAKEFILE,"> $makefile"); +print MAKEFILE 'all: ; @echo DEFAULT RULE: M2=$(M2) M3=$(M3)', "\n"; +close(MAKEFILE); + + +open(MAKEFILE,"> $makefile2"); +print MAKEFILE <<EOF; +M2 = m2 +NDEF: ; \@echo RULE FROM MAKEFILE 2 +EOF +close(MAKEFILE); + + +open(MAKEFILE,"> $makefile3"); +print MAKEFILE <<EOF; +M3 = m3 +NDEF3: ; \@echo RULE FROM MAKEFILE 3 +EOF +close(MAKEFILE); + + +&run_make_with_options($makefile, "MAKEFILES='$makefile2 $makefile3'", + &get_logfile); +$answer = "DEFAULT RULE: M2=m2 M3=m3\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST 2: Verify that included makefiles don't set the default goal. +# See Savannah bug #13401. + +create_file('xx-inc.mk', ' +include_goal: ; @echo $@ +include xx-ind.mk +'); + +create_file('xx-ind.mk', ' +indirect_goal: ; @echo $@ +'); + +run_make_test(q! +top: ; @echo $@ +!, + 'MAKEFILES=xx-inc.mk', "top\n"); + +unlink(qw(xx-inc.mk xx-ind.mk)); + +1; diff --git a/src/kmk/tests/scripts/variables/MAKEFILE_LIST b/src/kmk/tests/scripts/variables/MAKEFILE_LIST new file mode 100644 index 0000000..076e42d --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKEFILE_LIST @@ -0,0 +1,30 @@ +# -*-perl-*- + +$description = "Test the MAKEFILE_LIST variable."; + +$makefile2 = &get_tmpfile; + +open(MAKEFILE,"> $makefile"); +print MAKEFILE <<EOF; +m1 := \$(MAKEFILE_LIST) +include $makefile2 +m3 := \$(MAKEFILE_LIST) + +all: +\t\@echo \$(m1) +\t\@echo \$(m2) +\t\@echo \$(m3) +EOF +close(MAKEFILE); + + +open(MAKEFILE,"> $makefile2"); +print MAKEFILE "m2 := \$(MAKEFILE_LIST)\n"; +close(MAKEFILE); + + +&run_make_with_options($makefile, "", &get_logfile); +$answer = "$makefile\n$makefile $makefile2\n$makefile $makefile2\n"; +&compare_output($answer,&get_logfile(1)); + +1; diff --git a/src/kmk/tests/scripts/variables/MAKEFLAGS b/src/kmk/tests/scripts/variables/MAKEFLAGS new file mode 100644 index 0000000..0fac74a --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKEFLAGS @@ -0,0 +1,45 @@ +# -*-perl-*- + +$description = "Test proper behavior of MAKEFLAGS"; + +$details = "DETAILS"; + +# Normal flags aren't prefixed with "-" +run_make_test(q! +all: ; @echo $(MAKEFLAGS) +!, + '-e -r -R', 'erR'); + +# Long arguments mean everything is prefixed with "-" +run_make_test(q! +all: ; @echo $(MAKEFLAGS) +!, + '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: target 'all' does not exist +echo erR --trace --no-print-directory +erR --trace --no-print-directory"); + + +# Recursive invocations of make should accumulate MAKEFLAGS values. +# Savannah bug #2216 +run_make_test(q! +MSG = Fails +all: + @echo '$@: MAKEFLAGS=$(MAKEFLAGS)' + @MSG=Works $(MAKE) -e -f #MAKEFILE# jump +jump: + @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)' + @$(MAKE) -f #MAKEFILE# print +print: + @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)' +.PHONY: all jump print +!, + '--no-print-directory', + 'all: MAKEFLAGS= --no-print-directory +jump Works: MAKEFLAGS=e --no-print-directory +print Works: MAKEFLAGS=e --no-print-directory'); + +1; + +### Local Variables: +### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) +### End: diff --git a/src/kmk/tests/scripts/variables/MAKELEVEL b/src/kmk/tests/scripts/variables/MAKELEVEL new file mode 100644 index 0000000..0db3a68 --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKELEVEL @@ -0,0 +1,45 @@ +# -*-perl-*- + +$description = "The following test creates a makefile to test +makelevels in Make. It prints \$(MAKELEVEL) and then +prints the environment variable MAKELEVEL"; + +open(MAKEFILE,"> $makefile"); + +# The Contents of the MAKEFILE ... + +if (!$is_kmk) { + print MAKEFILE <<EOF; +all: +\t\@echo MAKELEVEL is \$(MAKELEVEL) +\techo \$\$MAKELEVEL +EOF +} else { + print MAKEFILE <<EOF; +all: +\t\@echo KMK_LEVEL is \$(KMK_LEVEL) +\techo \$\$KMK_LEVEL +EOF +} + +# END of Contents of MAKEFILE + +close(MAKEFILE); + +# RUN MAKE + +&run_make_with_options($makefile,"",&get_logfile); + +# SET ANSWER + +if (!$is_kmk) { + $answer = "MAKELEVEL is 0\necho \$MAKELEVEL\n1\n"; +} else { + $answer = "KMK_LEVEL is 0\necho \$KMK_LEVEL\n1\n"; +} + +# COMPARE RESULTS + +&compare_output($answer,&get_logfile(1)); + +1; diff --git a/src/kmk/tests/scripts/variables/MAKE_RESTARTS b/src/kmk/tests/scripts/variables/MAKE_RESTARTS new file mode 100644 index 0000000..01bf55e --- /dev/null +++ b/src/kmk/tests/scripts/variables/MAKE_RESTARTS @@ -0,0 +1,61 @@ +# -*-perl-*- + +$description = "Test the MAKE_RESTARTS variable."; + +# Test basic capability + +run_make_test(' +all: ; @: +$(info MAKE_RESTARTS=$(MAKE_RESTARTS)) +include foo.x +foo.x: ; @touch $@ +', + '', 'MAKE_RESTARTS= +MAKE_RESTARTS=1'); + +rmfiles('foo.x'); + +# Test multiple restarts + +run_make_test(' +all: ; @: +$(info MAKE_RESTARTS=$(MAKE_RESTARTS)) +include foo.x +foo.x: ; @echo "include bar.x" > $@ +bar.x: ; @touch $@ +', + '', 'MAKE_RESTARTS= +MAKE_RESTARTS=1 +MAKE_RESTARTS=2'); + +rmfiles('foo.x', 'bar.x'); + +# Test multiple restarts and make sure the variable is cleaned up + +run_make_test(' +recurse: + @echo recurse MAKE_RESTARTS=$$MAKE_RESTARTS + @$(MAKE) -f #MAKEFILE# all +all: + @echo all MAKE_RESTARTS=$$MAKE_RESTARTS +$(info MAKE_RESTARTS=$(MAKE_RESTARTS)) +include foo.x +foo.x: ; @echo "include bar.x" > $@ +bar.x: ; @touch $@ +', + '', "MAKE_RESTARTS= +MAKE_RESTARTS=1 +MAKE_RESTARTS=2 +recurse MAKE_RESTARTS= +#MAKE#[1]: Entering directory '#PWD#' +MAKE_RESTARTS= +all MAKE_RESTARTS= +#MAKE#[1]: Leaving directory '#PWD#'"); + +rmfiles('foo.x', 'bar.x'); + +1; + +### Local Variables: +### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) +### End: |