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 missing input ...



details:   https://anonhg.NetBSD.org/src/rev/60a6b086a6d1
branches:  trunk
changeset: 936393:60a6b086a6d1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 26 14:16:45 2020 +0000

description:
make(1): add test for missing input validation in :[123] modifier

diffstat:

 usr.bin/make/unit-tests/moderrs.exp |   9 ++++++++-
 usr.bin/make/unit-tests/moderrs.mk  |  26 ++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 3 deletions(-)

diffs (69 lines):

diff -r 3f5cbf7e8107 -r 60a6b086a6d1 usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp       Sun Jul 26 14:01:14 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp       Sun Jul 26 14:16:45 2020 +0000
@@ -13,10 +13,17 @@
 Expect: Unclosed substitution for VAR (, missing)
 make: Unclosed substitution for VAR (, missing)
 VAR:S,V,v=
-Expect: errors about missing @ delimiter
+Expect: 2 errors about missing @ delimiter
 make: Unclosed substitution for UNDEF (@ missing)
 
 make: Unclosed substitution for UNDEF (@ missing)
 
 1 2 3
+Expect: 2 errors about missing ] delimiter
+make: Unclosed substitution for UNDEF (] missing)
+
+make: Unclosed substitution for UNDEF (] missing)
+
+13=
+12345=ok
 exit status 0
diff -r 3f5cbf7e8107 -r 60a6b086a6d1 usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk        Sun Jul 26 14:01:14 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk        Sun Jul 26 14:16:45 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: moderrs.mk,v 1.2 2020/07/26 10:04:06 rillig Exp $
+# $Id: moderrs.mk,v 1.3 2020/07/26 14:16:45 rillig Exp $
 #
 # various modifier error tests
 
@@ -9,6 +9,7 @@
 MOD_S:= ${MOD_TERM},
 
 all:   modunkn modunknV varterm vartermV modtermV modloop
+all:   modwords
 
 modunkn:
        @echo "Expect: Unknown modifier 'Z'"
@@ -31,7 +32,28 @@
        -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"
 
 modloop:
-       @echo "Expect: errors about missing @ delimiter"
+       @echo "Expect: 2 errors about missing @ delimiter"
        @echo ${UNDEF:U1 2 3:@var}
        @echo ${UNDEF:U1 2 3:@var@...}
        @echo ${UNDEF:U1 2 3:@var@${var}@}
+
+modwords:
+       @echo "Expect: 2 errors about missing ] delimiter"
+       @echo ${UNDEF:U1 2 3:[}
+       @echo ${UNDEF:U1 2 3:[#}
+
+       # out of bounds => empty
+       @echo 13=${UNDEF:U1 2 3:[13]}
+
+       # Word index out of bounds.
+       #
+       # On LP64I32, strtol returns LONG_MAX,
+       # which is then truncated to int (undefined behavior),
+       # typically resulting in -1.
+       # This -1 is interpreted as "the last word".
+       #
+       # On ILP32, strtol returns LONG_MAX,
+       # which is a large number.
+       # This results in a range from LONG_MAX - 1 to 3,
+       # which is empty.
+       @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}



Home | Main Index | Thread Index | Old Index