Sun Sep 12 10:26:49 2021 UTC ()
tests/make: make output of test job-output-null clearer

Having 5 times the word 'hello' in the output doesn't help at
understanding the test and how the output was produced.

Bash 5 sometimes makes this test fail by adding '2b' and '2c' to the
output.


(rillig)
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/job-output-null.exp
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/job-output-null.mk

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/job-output-null.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/job-output-null.exp 2021/07/03 22:39:40 1.2
+++ src/usr.bin/make/unit-tests/job-output-null.exp 2021/09/12 10:26:49 1.3
@@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
1hello 11
2hello 22a
3hello without newline, hello without newline. 33a without newline, 3b without newline.
4exit status 0 4exit status 0

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/job-output-null.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/job-output-null.mk 2021/07/03 22:39:40 1.2
+++ src/usr.bin/make/unit-tests/job-output-null.mk 2021/09/12 10:26:49 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: job-output-null.mk,v 1.2 2021/07/03 22:39:40 rillig Exp $ 1# $NetBSD: job-output-null.mk,v 1.3 2021/09/12 10:26:49 rillig Exp $
2# 2#
3# Test how null bytes in the output of a command are handled. Make processes 3# Test how null bytes in the output of a command are handled. Make processes
4# them using null-terminated strings, which may cut off some of the output. 4# them using null-terminated strings, which may cut off some of the output.
5# 5#
6# As of 2021-04-15, make handles null bytes from the child process 6# As of 2021-04-15, make handles null bytes from the child process
7# inconsistently. It's an edge case though since typically the child 7# inconsistently. It's an edge case though since typically the child
8# processes output text. 8# processes output text.
9 9
10# Note: The printf commands used in this test must only use a single format 10# Note: The printf commands used in this test must only use a single format
11# string, without parameters. This is because it is implementation-dependent 11# string, without parameters. This is because it is implementation-dependent
12# how many times the command 'printf "fmt%s" "" "" ""' calls write(2). 12# how many times the command 'printf "fmt%s" "" "" ""' calls write(2).
13# 13#
14# NetBSD /bin/sh 1 x write("fmtfmtfmt") 14# NetBSD /bin/sh 1 x write("fmtfmtfmt")
@@ -16,30 +16,30 @@ @@ -16,30 +16,30 @@
16# NetBSD /bin/ksh 3 x write("fmt") (via /bin/printf) 16# NetBSD /bin/ksh 3 x write("fmt") (via /bin/printf)
17# Bash 5 3 x write("fmt") 17# Bash 5 3 x write("fmt")
18# 18#
19# In the latter case the output may arrive in parts, which in this test makes 19# In the latter case the output may arrive in parts, which in this test makes
20# a crucial difference since the outcome of the test depends on whether there 20# a crucial difference since the outcome of the test depends on whether there
21# is a '\n' in each of the blocks from the output. 21# is a '\n' in each of the blocks from the output.
22 22
23.MAKEFLAGS: -j1 # force jobs mode 23.MAKEFLAGS: -j1 # force jobs mode
24 24
25all: .PHONY 25all: .PHONY
26 # The null byte from the command output is kept as-is. 26 # The null byte from the command output is kept as-is.
27 # See CollectOutput, which looks like it intended to replace these 27 # See CollectOutput, which looks like it intended to replace these
28 # null bytes with simple spaces. 28 # null bytes with simple spaces.
29 @printf 'hello\0world\n' 29 @printf '1\0trailing\n'
30 30
31 # Give the parent process a chance to see the above output, but not 31 # Give the parent process a chance to see the above output, but not
32 # yet the output from the next printf command. 32 # yet the output from the next printf command.
33 @sleep 1 33 @sleep 1
34 34
35 # All null bytes from the command output are kept as-is. 35 # All null bytes from the command output are kept as-is.
36 @printf 'hello\0world\n''hello\0world\n''hello\0world\n' 36 @printf '2a\0trailing\n''2b\0trailing\n''2c\0trailing\n'
37 37
38 @sleep 1 38 @sleep 1
39 39
40 # The null bytes are replaced with spaces since they are not followed 40 # The null bytes are replaced with spaces since they are not followed
41 # by a newline. 41 # by a newline.
42 # 42 #
43 # The three null bytes in a row test whether this output is 43 # The three null bytes in a row test whether this output is
44 # compressed to a single space like in DebugFailedTarget. It isn't. 44 # compressed to a single space like in DebugFailedTarget. It isn't.
45 @printf 'hello\0without\0\0\0newline, hello\0without\0\0\0newline.' 45 @printf '3a\0without\0\0\0newline, 3b\0without\0\0\0newline.'