From 29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:21:29 +0200 Subject: Adding upstream version 1:0.1.9998svn3589+dfsg. Signed-off-by: Daniel Baumann --- src/kmk/tests/scripts/misc/bs-nl | 227 +++++++++++++++++++++++ src/kmk/tests/scripts/misc/close_stdout | 9 + src/kmk/tests/scripts/misc/fopen-fail | 18 ++ src/kmk/tests/scripts/misc/general1 | 51 ++++++ src/kmk/tests/scripts/misc/general2 | 50 +++++ src/kmk/tests/scripts/misc/general3 | 315 ++++++++++++++++++++++++++++++++ src/kmk/tests/scripts/misc/general4 | 85 +++++++++ src/kmk/tests/scripts/misc/utf8 | 14 ++ 8 files changed, 769 insertions(+) create mode 100644 src/kmk/tests/scripts/misc/bs-nl create mode 100644 src/kmk/tests/scripts/misc/close_stdout create mode 100644 src/kmk/tests/scripts/misc/fopen-fail create mode 100644 src/kmk/tests/scripts/misc/general1 create mode 100644 src/kmk/tests/scripts/misc/general2 create mode 100644 src/kmk/tests/scripts/misc/general3 create mode 100644 src/kmk/tests/scripts/misc/general4 create mode 100644 src/kmk/tests/scripts/misc/utf8 (limited to 'src/kmk/tests/scripts/misc') diff --git a/src/kmk/tests/scripts/misc/bs-nl b/src/kmk/tests/scripts/misc/bs-nl new file mode 100644 index 0000000..fc323ce --- /dev/null +++ b/src/kmk/tests/scripts/misc/bs-nl @@ -0,0 +1,227 @@ +# -*-perl-*- +$description = "Test backslash-newline handling."; + +$details = ""; + +# TEST #1 +# ------- + +# Backslash-newlines in recipes + +# These are basic backslash-newlines with no tricks +run_make_test("fast:;\@echo fa\\\nst\n", + '', 'fast'); + +run_make_test("slow:;\@: no-op; echo sl\\\now\n", + '', 'slow'); + +run_make_test("dquote:;\@echo \"dqu\\\note\"\n", + '', 'dquote'); + +run_make_test("squote:;\@echo 'squ\\\note'\n", + '', "squ\\\note"); + +# Ensure that a leading prefix character is omitted +run_make_test("fast:;\@echo fa\\\n\tst\n", + '', 'fast'); + +run_make_test("slow:;\@: no-op; echo sl\\\n\tow\n", + '', 'slow'); + +run_make_test("dquote:;\@echo \"dqu\\\n\tote\"\n", + '', 'dquote'); + +run_make_test("squote:;\@echo 'squ\\\n\tote'\n", + '', "squ\\\note"); + +# Ensure that ONLY the leading prefix character is omitted +run_make_test("fast:;\@echo fa\\\n\t st\n", + '', 'fa st'); + +run_make_test("slow:;\@: no-op; echo sl\\\n\t\tow\n", + '', "sl ow"); + +run_make_test("dquote:;\@echo \"dqu\\\n\t ote\"\n", + '', 'dqu ote'); + +run_make_test("squote:;\@echo 'squ\\\n\t\t ote'\n", + '', "squ\\\n\t ote"); + +# Backslash-newlines in variable values + +# Simple +run_make_test(q! +var = he\ +llo +var:;@echo '|$(var)|'!, + '', "|he llo|"); + +# Condense trailing space +run_make_test(q! +var = he \ +llo +var:;@echo '|$(var)|'!, + '', "|he llo|"); + +# Remove leading space +run_make_test(q! +var = he\ + llo +var:;@echo '|$(var)|'!, + '', "|he llo|"); + +# Multiple bs/nl condensed +run_make_test(q! +var = he\ +\ +\ + llo +var:;@echo '|$(var)|'!, + '', "|he llo|"); + +# POSIX: Preserve trailing space +run_make_test(q! +.POSIX: +x = y +var = he \ +llo +var:;@echo '|$(var)|'!, + '', "|he llo|"); + +# POSIX: One space per bs-nl +run_make_test(q! +.POSIX: +x = y +var = he\ +\ +\ + llo +var:;@echo '|$(var)|'!, + '', "|he llo|"); + +# Savannah #39035: handle whitespace in call +run_make_test(q! +f = echo $(1) +t:; @$(call f,"a \ + b"); \ + $(call f,"a \ + b") +!, + '', "a b\na b\n"); + +# Savannah #38945: handle backslash CRLF +# We need our own makefile so we can set binmode +my $m1 = get_tmpfile(); +open(MAKEFILE, "> $m1"); +binmode(MAKEFILE); +print MAKEFILE "FOO = foo \\\r\n"; +close(MAKEFILE); + +my $m2 = get_tmpfile(); +open(MAKEFILE, "> $m2"); +print MAKEFILE "include $m1\ndefine BAR\nall: ; \@echo \$(FOO) bar\nendef\n\$(eval \$(BAR))\n"; +close(MAKEFILE); + +run_make_with_options($m2, '', get_logfile()); +compare_output("foo bar\n", get_logfile(1)); + +# Test different types of whitespace, and bsnl inside functions + +sub xlate +{ + $_ = $_[0]; + s/\\r/\r/g; + s/\\t/\t/g; + s/\\f/\f/g; + s/\\v/\v/g; + s/\\n/\n/g; + return $_; +} + +run_make_test(xlate(q! +$(foreach\r a \t , b\t c \r ,$(info $a \r ) ) +all:;@: +!), + '', "b \r \nc \r \n"); + +run_make_test(xlate(q! +all:;@:$(foreach\r a \t , b\t c \r ,$(info $a \r ) ) +!), + '', "b \r \nc \r \n"); + +run_make_test(xlate(q! +$(foreach \ +\r a \t\ + , b\t \ + c \r ,$(info \ + $a \r ) \ + ) +all:;@: +!), + '', "b \r \nc \r \n"); + +run_make_test(xlate(q! +all:;@:$(foreach \ +\r a \t\ + , b\t \ + c \r ,$(info \ + $a \r ) \ + ) +!), + '', "b \r \nc \r \n"); + +run_make_test(xlate(q! +define FOO +$(foreach +\r a \t + , b\t + c \r ,$(info + $a \r ) + ) +endef +$(FOO) +all:;@: +!), + '', "b \r \nc \r \n"); + +run_make_test(xlate(q! +define FOO +$(foreach +\r a \t + , b\t + c \r ,$(info + $a \r ) + ) +endef +all:;@:$(FOO) +!), + '', "b \r \nc \r \n"); + +# Test variables in recipes that expand to multiple lines + +run_make_test(q! +define var + +echo foo + + +echo bar +endef +all:;$(var) +!, + '', "echo foo\nfoo\necho bar\nbar\n"); + +run_make_test(q! +define var + +echo foo + +@ + +echo bar +endef +all:;$(var) +!, + '', "echo foo\nfoo\necho bar\nbar\n"); + +1; diff --git a/src/kmk/tests/scripts/misc/close_stdout b/src/kmk/tests/scripts/misc/close_stdout new file mode 100644 index 0000000..18606c3 --- /dev/null +++ b/src/kmk/tests/scripts/misc/close_stdout @@ -0,0 +1,9 @@ +# -*-perl-*- + +$description = "Make sure make exits with an error if stdout is full."; + +if (-e '/dev/full') { + run_make_test('', '-v > /dev/full', '/^#MAKE#: write error/', 256); +} + +1; diff --git a/src/kmk/tests/scripts/misc/fopen-fail b/src/kmk/tests/scripts/misc/fopen-fail new file mode 100644 index 0000000..2ec9810 --- /dev/null +++ b/src/kmk/tests/scripts/misc/fopen-fail @@ -0,0 +1,18 @@ +# -*-perl-*- + +$description = "Make sure make exits with an error if fopen fails."; + +# Recurse infinitely until we run out of open files, and ensure we +# fail with a non-zero exit code. Don't bother to test the output +# since it's hard to know what it will be, exactly. +# See Savannah bug #27374. + +# Use a longer-than-normal timeout: some systems have more FDs available? +# We also set ulimit -n 512 in check-regression in Makefile.am, which see. +# See Savannah bug #42390. +run_make_test(q! +include $(lastword $(MAKEFILE_LIST)) +!, + '', undef, 512, 300); + +1; diff --git a/src/kmk/tests/scripts/misc/general1 b/src/kmk/tests/scripts/misc/general1 new file mode 100644 index 0000000..352fc6a --- /dev/null +++ b/src/kmk/tests/scripts/misc/general1 @@ -0,0 +1,51 @@ +# -*-perl-*- + +$description = "The following test creates a makefile to test the +simple functionality of make. It mimics the +rebuilding of a product with dependencies. +It also tests the simple definition of VPATH."; + +open(MAKEFILE,"> $makefile"); + +print MAKEFILE < $makefile"); + +# The contents of the Makefile ... + +print MAKEFILE < $makefile2"); +print MAKEFILE "all:;\@echo FOO = \$(FOO)\nFOO = foo"; +close(MAKEFILE); + +&run_make_with_options($makefile2,"",&get_logfile); +$answer = "FOO = foo\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST 3 + +# Check semicolons in variable references + +run_make_test(' +$(if true,$(info true; true)) +all: ; @: +', + '', 'true; true'); + +# TEST 4 + +# Check that backslashes in command scripts are handled according to POSIX. +# Checks Savannah bug # 1332. + +# Test the fastpath / no quotes +run_make_test(' +all: + @echo foo\ +bar + @echo foo\ + bar + @echo foo\ + bar + @echo foo\ + bar + @echo foo \ +bar + @echo foo \ + bar + @echo foo \ + bar + @echo foo \ + bar +', + '', 'foobar +foobar +foo bar +foo bar +foo bar +foo bar +foo bar +foo bar'); + +# Test the fastpath / single quotes +run_make_test(" +all: + \@echo 'foo\\ +bar' + \@echo 'foo\\ + bar' + \@echo 'foo\\ + bar' + \@echo 'foo\\ + bar' + \@echo 'foo \\ +bar' + \@echo 'foo \\ + bar' + \@echo 'foo \\ + bar' + \@echo 'foo \\ + bar' +", + '', 'foo\ +bar +foo\ +bar +foo\ + bar +foo\ + bar +foo \ +bar +foo \ +bar +foo \ + bar +foo \ + bar'); + +# Test the fastpath / double quotes +run_make_test(' +all: + @echo "foo\ +bar" + @echo "foo\ + bar" + @echo "foo\ + bar" + @echo "foo\ + bar" + @echo "foo \ +bar" + @echo "foo \ + bar" + @echo "foo \ + bar" + @echo "foo \ + bar" +', + '', 'foobar +foobar +foo bar +foo bar +foo bar +foo bar +foo bar +foo bar'); + +# Test the slow path / no quotes +run_make_test(' +all: + @echo hi; echo foo\ +bar + @echo hi; echo foo\ + bar + @echo hi; echo foo\ + bar + @echo hi; echo foo\ + bar + @echo hi; echo foo \ +bar + @echo hi; echo foo \ + bar + @echo hi; echo foo \ + bar + @echo hi; echo foo \ + bar +', + '', 'hi +foobar +hi +foobar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar'); + +# Test the slow path / no quotes. This time we put the slow path +# determination _after_ the backslash-newline handling. +run_make_test(' +all: + @echo foo\ +bar; echo hi + @echo foo\ + bar; echo hi + @echo foo\ + bar; echo hi + @echo foo\ + bar; echo hi + @echo foo \ +bar; echo hi + @echo foo \ + bar; echo hi + @echo foo \ + bar; echo hi + @echo foo \ + bar; echo hi +', + '', 'foobar +hi +foobar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi'); + +# Test the slow path / single quotes +run_make_test(" +all: + \@echo hi; echo 'foo\\ +bar' + \@echo hi; echo 'foo\\ + bar' + \@echo hi; echo 'foo\\ + bar' + \@echo hi; echo 'foo\\ + bar' + \@echo hi; echo 'foo \\ +bar' + \@echo hi; echo 'foo \\ + bar' + \@echo hi; echo 'foo \\ + bar' + \@echo hi; echo 'foo \\ + bar' +", + '', 'hi +foo\ +bar +hi +foo\ +bar +hi +foo\ + bar +hi +foo\ + bar +hi +foo \ +bar +hi +foo \ +bar +hi +foo \ + bar +hi +foo \ + bar'); + +# Test the slow path / double quotes +run_make_test(' +all: + @echo hi; echo "foo\ +bar" + @echo hi; echo "foo\ + bar" + @echo hi; echo "foo\ + bar" + @echo hi; echo "foo\ + bar" + @echo hi; echo "foo \ +bar" + @echo hi; echo "foo \ + bar" + @echo hi; echo "foo \ + bar" + @echo hi; echo "foo \ + bar" +', + '', 'hi +foobar +hi +foobar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar +hi +foo bar'); + +run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#:1: x] Error 1 (ignored)\n"); + +1; diff --git a/src/kmk/tests/scripts/misc/general4 b/src/kmk/tests/scripts/misc/general4 new file mode 100644 index 0000000..dd9475c --- /dev/null +++ b/src/kmk/tests/scripts/misc/general4 @@ -0,0 +1,85 @@ +# -*-perl-*- + +$description = "\ +This tests random features of make's algorithms, often somewhat obscure, +which have either broken at some point in the past or seem likely to +break."; + +run_make_test(' +# Make sure that subdirectories built as prerequisites are actually handled +# properly. + +all: dir/subdir/file.a + +dir/subdir: ; @echo mkdir -p dir/subdir + +dir/subdir/file.b: dir/subdir ; @echo touch dir/subdir/file.b + +dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@', + '', "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n"); + +# Test implicit rules +# kmk: No default implicit rules. + +&touch('foo.c'); +run_make_test('foo: foo.o', + 'CC="@echo cc" OUTPUT_OPTION=', + !$is_kmk ? 'cc -c foo.c +cc foo.o -o foo' : +"#MAKE#: *** No rule to make target `foo.o', needed by `foo'. Stop.", +!$is_kmk ? 0 : 512); +unlink('foo.c'); + + +# Test implicit rules with '$' in the name (see se_implicit) + +run_make_test(q! +%.foo : baz$$bar ; @echo 'done $<' +%.foo : bar$$baz ; @echo 'done $<' +test.foo: +baz$$bar bar$$baz: ; @echo '$@' +!, + '', + "baz\$bar\ndone baz\$bar"); + + +# Test implicit rules with '$' in the name (see se_implicit) +# Use the '$' in the pattern. + +run_make_test(q! +%.foo : %$$bar ; @echo 'done $<' +test.foo: +test$$bar: ; @echo '$@' +!, + '', + "test\$bar\ndone test\$bar"); + +# Make sure that subdirectories built as prerequisites are actually handled +# properly... this time with '$' + +run_make_test(q! + +all: dir/subdir/file.$$a + +dir/subdir: ; @echo mkdir -p '$@' + +dir/subdir/file.$$b: dir/subdir ; @echo touch '$@' + +dir/subdir/%.$$a: dir/subdir/%.$$b ; @echo 'cp $< $@' +!, + '', "mkdir -p dir/subdir\ntouch dir/subdir/file.\$b\ncp dir/subdir/file.\$b dir/subdir/file.\$a\n"); + +# Test odd whitespace at the beginning of a line + +run_make_test(" +all: + \f + + \\ + \f \\ + \013 \\ +all: ; \@echo hi +", + '', "hi\n"); + +1; diff --git a/src/kmk/tests/scripts/misc/utf8 b/src/kmk/tests/scripts/misc/utf8 new file mode 100644 index 0000000..2adcd07 --- /dev/null +++ b/src/kmk/tests/scripts/misc/utf8 @@ -0,0 +1,14 @@ +# -*-perl-*- +$description = "Test utf8 handling."; + +$details = ""; + +# Variable names containing UTF8 characters +run_make_test(" +\xe2\x96\xaa := hello +\$(info \$(\xe2\x96\xaa)) +all: +", + '', "hello\n#MAKE#: Nothing to be done for 'all'."); + +1; -- cgit v1.2.3