Module Name: src Committed By: rillig Date: Fri Sep 25 23:24:49 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile dep-wildcards.exp Added Files: src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.exp dep-colon-bug-cross-file.mk Log Message: make(1): add test for harmless bug in Parse_File When there is a dependency group at the end of a top-level makefile, this dependency group is not finished properly. This allows to add further commands to the targets of this dependency group, which was not intended. To generate a diff of this commit: cvs rdiff -u -r1.929 -r1.930 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.151 -r1.152 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 \ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp \ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-wildcards.exp 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.929 src/distrib/sets/lists/tests/mi:1.930 --- src/distrib/sets/lists/tests/mi:1.929 Fri Sep 25 18:18:25 2020 +++ src/distrib/sets/lists/tests/mi Fri Sep 25 23:24:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.929 2020/09/25 18:18:25 rillig Exp $ +# $NetBSD: mi,v 1.930 2020/09/25 23:24:49 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4614,6 +4614,8 @@ ./usr/tests/usr.bin/make/unit-tests/counter-append.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/counter.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/counter.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-colon.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-colon.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-double-colon.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.151 src/usr.bin/make/unit-tests/Makefile:1.152 --- src/usr.bin/make/unit-tests/Makefile:1.151 Fri Sep 25 20:11:06 2020 +++ src/usr.bin/make/unit-tests/Makefile Fri Sep 25 23:24:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.151 2020/09/25 20:11:06 rillig Exp $ +# $NetBSD: Makefile,v 1.152 2020/09/25 23:24:49 rillig Exp $ # # Unit tests for make(1) # @@ -74,6 +74,7 @@ TESTS+= counter TESTS+= counter-append TESTS+= dep TESTS+= dep-colon +TESTS+= dep-colon-bug-cross-file TESTS+= dep-double-colon TESTS+= dep-exclam TESTS+= dep-none Index: src/usr.bin/make/unit-tests/dep-wildcards.exp diff -u src/usr.bin/make/unit-tests/dep-wildcards.exp:1.2 src/usr.bin/make/unit-tests/dep-wildcards.exp:1.3 --- src/usr.bin/make/unit-tests/dep-wildcards.exp:1.2 Tue Sep 8 05:33:05 2020 +++ src/usr.bin/make/unit-tests/dep-wildcards.exp Fri Sep 25 23:24:49 2020 @@ -1,3 +1,4 @@ +dep-colon-bug-cross-file.mk dep-colon.mk dep-double-colon.mk dep-exclam.mk Added files: Index: src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp diff -u /dev/null src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp:1.1 --- /dev/null Fri Sep 25 23:24:49 2020 +++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp Fri Sep 25 23:24:49 2020 @@ -0,0 +1,3 @@ +: pass 1 +: pass 2 +exit status 0 Index: src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk diff -u /dev/null src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.1 --- /dev/null Fri Sep 25 23:24:49 2020 +++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk Fri Sep 25 23:24:49 2020 @@ -0,0 +1,43 @@ +# $NetBSD: dep-colon-bug-cross-file.mk,v 1.1 2020/09/25 23:24:49 rillig Exp $ +# +# Until 2020-09-25, the very last dependency group of a top-level makefile +# was not finished properly. This made it possible to add further commands +# to that target. +# +# In pass 1, there is a dependency group at the bottom of the file. +# This dependency group is not finished properly. Finishing the dependency +# group would add the OP_HAS_COMMANDS flag to the "all" target, thereby +# preventing any commands from being added later. +# +# After the file has been parsed completely, it is parsed again in pass 2. +# In this pass, another command is added to the "current dependency group", +# which is still the one from pass 1, which means it is possible to even +# cross file boundaries. +# +# TODO: Finish the file properly in Parse_File. +# +# Oops, even worse. Running this test in a make from 2020-09-25 or earlier +# on NetBSD 8.0 x86_64 with MALLOC_OPTIONS=JA produces this or a similar +# output: +# +# make: cannot open ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ. +# +# The 'Z' means access to already freed memory; see jemalloc(3). The cause +# for this is that in MainParseArgs, the command line arguments were not +# properly copied before storing them with global variables. + +PASS?= 1 + +.if ${PASS} == 2 +all: + : pass 2 +.endif + +.if ${PASS} == 1 + +PASS= 2 +.MAKEFLAGS: -f ${.PARSEDIR:q}/${.PARSEFILE:q} + +all: + : pass 1 +.endif