Module Name: src Committed By: rillig Date: Thu Apr 15 19:02:29 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: job-output-null.exp job-output-null.mk Log Message: tests/make: demonstrate handling of null bytes To generate a diff of this commit: cvs rdiff -u -r1.1040 -r1.1041 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.275 -r1.276 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/job-output-null.exp \ src/usr.bin/make/unit-tests/job-output-null.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1040 src/distrib/sets/lists/tests/mi:1.1041 --- src/distrib/sets/lists/tests/mi:1.1040 Wed Apr 14 18:27:11 2021 +++ src/distrib/sets/lists/tests/mi Thu Apr 15 19:02:29 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1040 2021/04/14 18:27:11 rillig Exp $ +# $NetBSD: mi,v 1.1041 2021/04/15 19:02:29 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5487,6 +5487,8 @@ ./usr/tests/usr.bin/make/unit-tests/job-flags.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/job-output-long-lines.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/job-output-long-lines.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/job-output-null.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/job-output-null.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/jobs-empty-commands.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/jobs-empty-commands.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/jobs-error-indirect.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.275 src/usr.bin/make/unit-tests/Makefile:1.276 --- src/usr.bin/make/unit-tests/Makefile:1.275 Sun Apr 4 13:20:52 2021 +++ src/usr.bin/make/unit-tests/Makefile Thu Apr 15 19:02:29 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.275 2021/04/04 13:20:52 rillig Exp $ +# $NetBSD: Makefile,v 1.276 2021/04/15 19:02:29 rillig Exp $ # # Unit tests for make(1) # @@ -204,6 +204,7 @@ TESTS+= impsrc TESTS+= include-main TESTS+= job-flags TESTS+= job-output-long-lines +TESTS+= job-output-null TESTS+= jobs-empty-commands TESTS+= jobs-error-indirect TESTS+= jobs-error-nested Added files: Index: src/usr.bin/make/unit-tests/job-output-null.exp diff -u /dev/null src/usr.bin/make/unit-tests/job-output-null.exp:1.1 --- /dev/null Thu Apr 15 19:02:29 2021 +++ src/usr.bin/make/unit-tests/job-output-null.exp Thu Apr 15 19:02:29 2021 @@ -0,0 +1,4 @@ +hello +hello +hello world without newline, hello world without newline, hello world without newline. +exit status 0 Index: src/usr.bin/make/unit-tests/job-output-null.mk diff -u /dev/null src/usr.bin/make/unit-tests/job-output-null.mk:1.1 --- /dev/null Thu Apr 15 19:02:29 2021 +++ src/usr.bin/make/unit-tests/job-output-null.mk Thu Apr 15 19:02:29 2021 @@ -0,0 +1,32 @@ +# $NetBSD: job-output-null.mk,v 1.1 2021/04/15 19:02:29 rillig Exp $ +# +# Test how null bytes in the output of a command are handled. Make processes +# them using null-terminated strings, which may cut off some of the output. +# +# As of 2021-04-15, make handles null bytes from the child process +# inconsistently. It's an edge case though since typically the child +# processes output text. + +.MAKEFLAGS: -j1 # force jobs mode + +all: .PHONY + # The null byte from the command output is kept as-is. + # See CollectOutput, which looks like it intended to replace these + # null bytes with simple spaces. + @printf 'hello\0world%s\n' '' + + # Give the parent process a chance to see the above output, but not + # yet the output from the next printf command. + @sleep 1 + + # All null bytes from the command output are kept as-is. + @printf 'hello\0world%s\n' '' '' '' '' '' '' + + @sleep 1 + + # The null bytes are replaced with spaces since they are not followed + # by a newline. + # + # The three null bytes in a row test whether this output is + # compressed to a single space like in DebugFailedTarget. It isn't. + @printf 'hello\0world\0without\0\0\0newline%s' ', ' ', ' '.'