Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for null byte in ....



details:   https://anonhg.NetBSD.org/src/rev/f1a7a08c0004
branches:  trunk
changeset: 947882:f1a7a08c0004
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 19 16:00:17 2020 +0000

description:
make(1): add test for null byte in .for loop body

diffstat:

 distrib/sets/lists/tests/mi                    |   4 +++-
 usr.bin/make/unit-tests/Makefile               |   3 ++-
 usr.bin/make/unit-tests/directive-for-null.exp |  10 ++++++++++
 usr.bin/make/unit-tests/directive-for-null.mk  |  19 +++++++++++++++++++
 4 files changed, 34 insertions(+), 2 deletions(-)

diffs (72 lines):

diff -r fafd2603a5cf -r f1a7a08c0004 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Dec 19 15:29:28 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Dec 19 16:00:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.995 2020/12/19 12:14:59 rillig Exp $
+# $NetBSD: mi,v 1.996 2020/12/19 16:00:17 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5056,6 +5056,8 @@
 ./usr/tests/usr.bin/make/unit-tests/directive-for-generating-endif.mk          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directive-for-lines.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directive-for-lines.mk                     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directive-for-null.exp                     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directive-for-null.mk                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directive-for.exp                          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directive-for.mk                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directive-hyphen-include.exp               tests-usr.bin-tests     compattestfile,atf
diff -r fafd2603a5cf -r f1a7a08c0004 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Dec 19 15:29:28 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Dec 19 16:00:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.251 2020/12/19 12:14:59 rillig Exp $
+# $NetBSD: Makefile,v 1.252 2020/12/19 16:00:17 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -160,6 +160,7 @@
 TESTS+=                directive-for
 TESTS+=                directive-for-generating-endif
 TESTS+=                directive-for-lines
+TESTS+=                directive-for-null
 TESTS+=                directive-hyphen-include
 TESTS+=                directive-if
 TESTS+=                directive-if-nested
diff -r fafd2603a5cf -r f1a7a08c0004 usr.bin/make/unit-tests/directive-for-null.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/directive-for-null.exp    Sat Dec 19 16:00:17 2020 +0000
@@ -0,0 +1,10 @@
+make: "(stdin)" line 2: Zero byte read from file
+make: "(stdin)" line 2: Unexpected end of file in for loop.
+make: "(stdin)" line 3: Zero byte read from file
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1
diff -r fafd2603a5cf -r f1a7a08c0004 usr.bin/make/unit-tests/directive-for-null.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/directive-for-null.mk     Sat Dec 19 16:00:17 2020 +0000
@@ -0,0 +1,19 @@
+# $NetBSD: directive-for-null.mk,v 1.1 2020/12/19 16:00:17 rillig Exp $
+#
+# Test for parsing a .for loop that accidentally contains a null byte.
+#
+# As of 2020-12-19, there are 3 error messages:
+#
+#      make: "(stdin)" line 2: Zero byte read from file
+#      make: "(stdin)" line 2: Unexpected end of file in for loop.
+#      make: "(stdin)" line 3: Zero byte read from file
+#
+# The one about "end of file" might be misleading but is due to the
+# implementation.  On both errors and EOF, ParseGetLine returns NULL.
+#
+# The one about the "zero byte" in line 3 is surprising since the only
+# line that contains a null byte is line 2.
+
+all: .PHONY
+       @printf '%s\n' '.for i in 1 2 3' 'VAR=value' '.endfor' | tr 'l' '\0' \
+       | ${MAKE} -f -



Home | Main Index | Thread Index | Old Index