tests/make: demonstrate parse bug in :gmtime and :localtime modifiers

This commit is contained in:
rillig 2023-05-09 08:26:14 +00:00
parent ebc1b23201
commit 6b94bf57da
4 changed files with 48 additions and 24 deletions

View File

@ -1,13 +1,13 @@
make: "varmod-gmtime.mk" line 57: Invalid time value at "${:U1593536400}} != "mtime=11593536400}""
make: "varmod-gmtime.mk" line 57: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
make: "varmod-gmtime.mk" line 67: Invalid time value at "-1} != """
make: "varmod-gmtime.mk" line 67: Malformed conditional (${:L:gmtime=-1} != "")
make: "varmod-gmtime.mk" line 76: Invalid time value at " 1} != """
make: "varmod-gmtime.mk" line 76: Malformed conditional (${:L:gmtime= 1} != "")
make: "varmod-gmtime.mk" line 119: Invalid time value at "10000000000000000000000000000000} != """
make: "varmod-gmtime.mk" line 119: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "")
make: "varmod-gmtime.mk" line 130: Invalid time value at "error} != """
make: "varmod-gmtime.mk" line 130: Malformed conditional (${:L:gmtime=error} != "")
make: "varmod-gmtime.mk" line 60: Invalid time value at "${:U1593536400}} != "mtime=11593536400}""
make: "varmod-gmtime.mk" line 60: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
make: "varmod-gmtime.mk" line 70: Invalid time value at "-1} != """
make: "varmod-gmtime.mk" line 70: Malformed conditional (${:L:gmtime=-1} != "")
make: "varmod-gmtime.mk" line 79: Invalid time value at " 1} != """
make: "varmod-gmtime.mk" line 79: Malformed conditional (${:L:gmtime= 1} != "")
make: "varmod-gmtime.mk" line 125: Invalid time value at "10000000000000000000000000000000} != """
make: "varmod-gmtime.mk" line 125: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "")
make: "varmod-gmtime.mk" line 136: Invalid time value at "error} != """
make: "varmod-gmtime.mk" line 136: Malformed conditional (${:L:gmtime=error} != "")
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1

View File

@ -1,7 +1,10 @@
# $NetBSD: varmod-gmtime.mk,v 1.10 2021/01/19 05:26:34 rillig Exp $
# $NetBSD: varmod-gmtime.mk,v 1.11 2023/05/09 08:26:14 rillig Exp $
#
# Tests for the :gmtime variable modifier, which formats a timestamp
# using strftime(3) in UTC.
#
# See also:
# varmod-localtime.mk
.if ${TZ:Uundefined} != "undefined" # see unit-tests/Makefile
. error
@ -75,6 +78,8 @@
# because it would make sense but just as a side-effect from using strtoul.
.if ${:L:gmtime= 1} != ""
. error
.else
. error
.endif
@ -115,7 +120,8 @@
# ULONG_MAX, which got converted to -1. This resulted in a time stamp of
# the second before 1970.
#
# Since var.c 1.631, the overflow is detected and produces a parse error.
# Since var.c 1.631 from 2020-10-31, the overflow is detected and produces a
# parse error.
.if ${:L:gmtime=10000000000000000000000000000000} != ""
. error
.else
@ -133,5 +139,11 @@
. error
.endif
# Before var.c 1.TODO from XXXX-XX-XX, the timestamp could be directly
# followed by the next modifier, without a ':' separator. This is the same
# bug as for the ':L' and ':P' modifiers.
.if ${%Y:L:gmtime=100000S,1970,bad,} != "bad"
. error
.endif
all:

View File

@ -1,13 +1,13 @@
make: "varmod-localtime.mk" line 57: Invalid time value at "${:U1593536400}} != "mtime=11593536400}""
make: "varmod-localtime.mk" line 57: Malformed conditional (${%Y:L:localtime=${:U1593536400}} != "mtime=11593536400}")
make: "varmod-localtime.mk" line 67: Invalid time value at "-1} != """
make: "varmod-localtime.mk" line 67: Malformed conditional (${:L:localtime=-1} != "")
make: "varmod-localtime.mk" line 76: Invalid time value at " 1} != """
make: "varmod-localtime.mk" line 76: Malformed conditional (${:L:localtime= 1} != "")
make: "varmod-localtime.mk" line 119: Invalid time value at "10000000000000000000000000000000} != """
make: "varmod-localtime.mk" line 119: Malformed conditional (${:L:localtime=10000000000000000000000000000000} != "")
make: "varmod-localtime.mk" line 130: Invalid time value at "error} != """
make: "varmod-localtime.mk" line 130: Malformed conditional (${:L:localtime=error} != "")
make: "varmod-localtime.mk" line 60: Invalid time value at "${:U1593536400}} != "mtime=11593536400}""
make: "varmod-localtime.mk" line 60: Malformed conditional (${%Y:L:localtime=${:U1593536400}} != "mtime=11593536400}")
make: "varmod-localtime.mk" line 70: Invalid time value at "-1} != """
make: "varmod-localtime.mk" line 70: Malformed conditional (${:L:localtime=-1} != "")
make: "varmod-localtime.mk" line 79: Invalid time value at " 1} != """
make: "varmod-localtime.mk" line 79: Malformed conditional (${:L:localtime= 1} != "")
make: "varmod-localtime.mk" line 125: Invalid time value at "10000000000000000000000000000000} != """
make: "varmod-localtime.mk" line 125: Malformed conditional (${:L:localtime=10000000000000000000000000000000} != "")
make: "varmod-localtime.mk" line 136: Invalid time value at "error} != """
make: "varmod-localtime.mk" line 136: Malformed conditional (${:L:localtime=error} != "")
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1

View File

@ -1,7 +1,10 @@
# $NetBSD: varmod-localtime.mk,v 1.8 2021/01/19 05:26:34 rillig Exp $
# $NetBSD: varmod-localtime.mk,v 1.9 2023/05/09 08:26:14 rillig Exp $
#
# Tests for the :localtime variable modifier, which formats a timestamp
# using strftime(3) in local time.
#
# See also:
# varmod-gmtime.mk
.if ${TZ} != "Europe/Berlin" # see unit-tests/Makefile
. error
@ -75,6 +78,8 @@
# because it would make sense but just as a side-effect from using strtoul.
.if ${:L:localtime= 1} != ""
. error
.else
. error
.endif
@ -115,7 +120,8 @@
# ULONG_MAX, which got converted to -1. This resulted in a time stamp of
# the second before 1970.
#
# Since var.c 1.631, the overflow is detected and produces a parse error.
# Since var.c 1.631 from 2020-10-31, the overflow is detected and produces a
# parse error.
.if ${:L:localtime=10000000000000000000000000000000} != ""
. error
.else
@ -133,5 +139,11 @@
. error
.endif
# Before var.c 1.TODO from XXXX-XX-XX, the timestamp could be directly
# followed by the next modifier, without a ':' separator. This is the same
# bug as for the ':L' and ':P' modifiers.
.if ${%Y:L:localtime=100000S,1970,bad,} != "bad"
. error
.endif
all: