| @@ -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 | |
25 | all: .PHONY | | 25 | all: .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.' |