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 makefile conta...



details:   https://anonhg.NetBSD.org/src/rev/ba0d185aeac9
branches:  trunk
changeset: 946722:ba0d185aeac9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 06 19:18:26 2020 +0000

description:
make(1): add test for makefile containing null bytes

diffstat:

 usr.bin/make/unit-tests/opt-file.exp |   3 +++
 usr.bin/make/unit-tests/opt-file.mk  |  18 +++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r b7b2a7a24101 -r ba0d185aeac9 usr.bin/make/unit-tests/opt-file.exp
--- a/usr.bin/make/unit-tests/opt-file.exp      Sun Dec 06 19:00:48 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-file.exp      Sun Dec 06 19:18:26 2020 +0000
@@ -1,2 +1,5 @@
 value
+make: "(stdin)" line 1: warning: Zero byte read from file, skipping rest of line.
+va
+VALUE2
 exit status 0
diff -r b7b2a7a24101 -r ba0d185aeac9 usr.bin/make/unit-tests/opt-file.mk
--- a/usr.bin/make/unit-tests/opt-file.mk       Sun Dec 06 19:00:48 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-file.mk       Sun Dec 06 19:18:26 2020 +0000
@@ -1,17 +1,29 @@
-# $NetBSD: opt-file.mk,v 1.3 2020/12/06 19:00:48 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.4 2020/12/06 19:18:26 rillig Exp $
 #
 # Tests for the -f command line option.
 
 # TODO: Implementation
 
-all: .PHONY file-ending-in-backslash
+all: .PHONY
+all: file-ending-in-backslash
+all: file-containing-null-byte
 
 # Passing '-' as the filename reads from stdin.  This is unusual but possible.
 #
 # In the unlikely case where a file ends in a backslash instead of a newline,
 # that backslash is trimmed.  See ParseGetLine.
 file-ending-in-backslash: .PHONY
-       @printf '%s' 'VAR=value\' | ${MAKE} -r -f - -v VAR
+       @printf '%s' 'VAR=value\' \
+       | ${MAKE} -r -f - -v VAR
+
+# If a file contains null bytes, the rest of the line is skipped, and parsing
+# continues in the next line.
+#
+# XXX: It would be safer to just quit parsing in such a situation.
+file-containing-null-byte: .PHONY
+       @printf '%s\n' 'VAR=value' 'VAR2=VALUE2' \
+       | tr 'l' '\0' \
+       | ${MAKE} -r -f - -v VAR -v VAR2
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index