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 harmless bug i...



details:   https://anonhg.NetBSD.org/src/rev/1ae611057213
branches:  trunk
changeset: 939344:1ae611057213
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 25 23:24:49 2020 +0000

description:
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.

diffstat:

 distrib/sets/lists/tests/mi                          |   4 +-
 usr.bin/make/unit-tests/Makefile                     |   3 +-
 usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp |   3 +
 usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk  |  43 ++++++++++++++++++++
 usr.bin/make/unit-tests/dep-wildcards.exp            |   1 +
 5 files changed, 52 insertions(+), 2 deletions(-)

diffs (97 lines):

diff -r 3040f5c298ca -r 1ae611057213 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Sep 25 23:18:59 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Sep 25 23:24:49 2020 +0000
@@ -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
diff -r 3040f5c298ca -r 1ae611057213 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Sep 25 23:18:59 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Sep 25 23:24:49 2020 +0000
@@ -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-append
 TESTS+=                dep
 TESTS+=                dep-colon
+TESTS+=                dep-colon-bug-cross-file
 TESTS+=                dep-double-colon
 TESTS+=                dep-exclam
 TESTS+=                dep-none
diff -r 3040f5c298ca -r 1ae611057213 usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp      Fri Sep 25 23:24:49 2020 +0000
@@ -0,0 +1,3 @@
+: pass 1
+: pass 2
+exit status 0
diff -r 3040f5c298ca -r 1ae611057213 usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk       Fri Sep 25 23:24:49 2020 +0000
@@ -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
diff -r 3040f5c298ca -r 1ae611057213 usr.bin/make/unit-tests/dep-wildcards.exp
--- a/usr.bin/make/unit-tests/dep-wildcards.exp Fri Sep 25 23:18:59 2020 +0000
+++ b/usr.bin/make/unit-tests/dep-wildcards.exp Fri Sep 25 23:24:49 2020 +0000
@@ -1,3 +1,4 @@
+dep-colon-bug-cross-file.mk
 dep-colon.mk
 dep-double-colon.mk
 dep-exclam.mk



Home | Main Index | Thread Index | Old Index