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 more tests for the vari...
details: https://anonhg.NetBSD.org/src/rev/69c654da2d39
branches: trunk
changeset: 941894:69c654da2d39
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 01 13:10:22 2020 +0000
description:
make(1): add more tests for the variable modifier :range, edge cases
diffstat:
usr.bin/make/unit-tests/varmod-range.exp | 15 +++++--
usr.bin/make/unit-tests/varmod-range.mk | 63 +++++++++++++++++++++++++++++--
2 files changed, 68 insertions(+), 10 deletions(-)
diffs (97 lines):
diff -r 052cb42ff0fc -r 69c654da2d39 usr.bin/make/unit-tests/varmod-range.exp
--- a/usr.bin/make/unit-tests/varmod-range.exp Sun Nov 01 12:34:45 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-range.exp Sun Nov 01 13:10:22 2020 +0000
@@ -1,8 +1,13 @@
+make: Unknown modifier 'x'
+make: "varmod-range.mk" line 46: Malformed conditional ("${:U:range=x}Rest" != "Rest")
+make: Unknown modifier 'x'
+make: "varmod-range.mk" line 55: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
make: Unknown modifier 'r'
-
-1 2 3
+make: "varmod-range.mk" line 71: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
make: Unknown modifier 'r'
-
+make: "varmod-range.mk" line 78: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
make: Unknown modifier 'r'
-
-exit status 0
+make: "varmod-range.mk" line 85: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 052cb42ff0fc -r 69c654da2d39 usr.bin/make/unit-tests/varmod-range.mk
--- a/usr.bin/make/unit-tests/varmod-range.mk Sun Nov 01 12:34:45 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-range.mk Sun Nov 01 13:10:22 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-range.mk,v 1.4 2020/09/27 18:11:31 rillig Exp $
+# $NetBSD: varmod-range.mk,v 1.5 2020/11/01 13:10:22 rillig Exp $
#
# Tests for the :range variable modifier, which generates sequences
# of integers from the given range.
@@ -31,8 +31,61 @@
. error
.endif
+# Negative ranges don't make sense.
+# As of 2020-11-01, they are accepted though, using up all available memory.
+#.if "${:range=-1}"
+#. error
+#.else
+#. error
+#.endif
+
+# The :range modifier requires a number as parameter.
+# As of 2020-11-01, the parser tries to read the 'x' as a number, fails and
+# stops there. It then tries to parse the next modifier at that point,
+# which fails with the message "Unknown modifier".
+.if "${:U:range=x}Rest" != "Rest"
+. error
+.else
+. error
+.endif
+
+# The upper limit of the range must always be given in decimal.
+# This parse error stops at the 'x', trying to parse it as a variable
+# modifier.
+.if "${:U:range=0x0}Rest" != "Rest"
+. error
+.else
+. error
+.endif
+
+# As of 2020-11-01, numeric overflow is not detected.
+# Since strtoul returns ULONG_MAX in such a case, it is interpreted as a
+# very large number, consuming all available memory.
+#.if "${:U:range=18446744073709551619}Rest" != "Rest"
+#. error
+#.else
+#. error
+#.endif
+
+# modifier name too short
+.if "${a b c:L:rang}Rest" != "Rest"
+. error
+.else
+. error
+.endif
+
+# misspelled modifier name
+.if "${a b c:L:rango}Rest" != "Rest"
+. error
+.else
+. error
+.endif
+
+# modifier name too long
+.if "${a b c:L:ranger}Rest" != "Rest"
+. error
+.else
+. error
+.endif
+
all:
- @echo ${a b c:L:rang} # modifier name too short
- @echo ${a b c:L:range} # ok
- @echo ${a b c:L:rango} # misspelled
- @echo ${a b c:L:ranger} # modifier name too long
Home |
Main Index |
Thread Index |
Old Index