Module Name: src Committed By: rillig Date: Mon Dec 21 20:47:29 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: Makefile varmod-gmtime.exp varmod-gmtime.mk varmod-localtime.exp varmod-localtime.mk Log Message: make(1): align tests for :localtime with those for :gmtime These tests had been almost the same before, now they are as similar as possible again. To generate a diff of this commit: cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-gmtime.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-localtime.exp \ src/usr.bin/make/unit-tests/varmod-localtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.255 src/usr.bin/make/unit-tests/Makefile:1.256 --- src/usr.bin/make/unit-tests/Makefile:1.255 Mon Dec 21 20:35:17 2020 +++ src/usr.bin/make/unit-tests/Makefile Mon Dec 21 20:47:29 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.255 2020/12/21 20:35:17 rillig Exp $ +# $NetBSD: Makefile,v 1.256 2020/12/21 20:47:29 rillig Exp $ # # Unit tests for make(1) # @@ -503,9 +503,6 @@ SED_CMDS.var-op-shell+= \ -e 's,^${.SHELL:T}: [ 0-9:]*,,' \ -e '/command/s,No such.*,not found,' SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,' -SED_CMDS.varmod-localtime+= -e 's,Tue Jan 19 04:14:08 2038,<normalized>,' -SED_CMDS.varmod-localtime+= ${:D FreeBSD i386 still has 32-bit time_t. } -SED_CMDS.varmod-localtime+= -e 's,Fri Dec 13 21:45:52 1901,<normalized>,' SED_CMDS.varmod-subst-regex+= \ -e 's,\(Regex compilation error:\).*,\1 (details omitted),' SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' Index: src/usr.bin/make/unit-tests/varmod-gmtime.exp diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.8 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.9 --- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.8 Mon Dec 21 20:35:17 2020 +++ src/usr.bin/make/unit-tests/varmod-gmtime.exp Mon Dec 21 20:47:29 2020 @@ -1,18 +1,18 @@ -make: "varmod-gmtime.mk" line 57: Invalid time value: ${:U1593536400}} != "mtime=11593536400}" +make: "varmod-gmtime.mk" line 60: Invalid time value: ${: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: -1} != "" +make: "varmod-gmtime.mk" line 60: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}") +make: "varmod-gmtime.mk" line 70: Invalid time value: -1} != "" -make: "varmod-gmtime.mk" line 67: Malformed conditional (${:L:gmtime=-1} != "") -make: "varmod-gmtime.mk" line 76: Invalid time value: 1} != "" +make: "varmod-gmtime.mk" line 70: Malformed conditional (${:L:gmtime=-1} != "") +make: "varmod-gmtime.mk" line 79: Invalid time value: 1} != "" -make: "varmod-gmtime.mk" line 76: Malformed conditional (${:L:gmtime= 1} != "") -make: "varmod-gmtime.mk" line 115: Invalid time value: 10000000000000000000000000000000} != "" +make: "varmod-gmtime.mk" line 79: Malformed conditional (${:L:gmtime= 1} != "") +make: "varmod-gmtime.mk" line 118: Invalid time value: 10000000000000000000000000000000} != "" -make: "varmod-gmtime.mk" line 115: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "") -make: "varmod-gmtime.mk" line 126: Invalid time value: error} != "" +make: "varmod-gmtime.mk" line 118: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "") +make: "varmod-gmtime.mk" line 129: Invalid time value: error} != "" -make: "varmod-gmtime.mk" line 126: Malformed conditional (${:L:gmtime=error} != "") +make: "varmod-gmtime.mk" line 129: Malformed conditional (${:L:gmtime=error} != "") make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.7 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.8 --- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.7 Mon Dec 21 20:35:17 2020 +++ src/usr.bin/make/unit-tests/varmod-gmtime.mk Mon Dec 21 20:47:29 2020 @@ -1,8 +1,11 @@ -# $NetBSD: varmod-gmtime.mk,v 1.7 2020/12/21 20:35:17 rillig Exp $ +# $NetBSD: varmod-gmtime.mk,v 1.8 2020/12/21 20:47:29 rillig Exp $ # # Tests for the :gmtime variable modifier, which formats a timestamp # using strftime(3) in UTC. +.if ${TZ:Uundefined} != "undefined" # see unit-tests/Makefile +. error +.endif # Test for the default time format, %c. Since the time always varies, it's # only possible to check for the general format here. The names of the Index: src/usr.bin/make/unit-tests/varmod-localtime.exp diff -u src/usr.bin/make/unit-tests/varmod-localtime.exp:1.5 src/usr.bin/make/unit-tests/varmod-localtime.exp:1.6 --- src/usr.bin/make/unit-tests/varmod-localtime.exp:1.5 Mon Nov 30 21:10:15 2020 +++ src/usr.bin/make/unit-tests/varmod-localtime.exp Mon Dec 21 20:47:29 2020 @@ -1,27 +1,18 @@ -mod-localtime -%Y -2020 -%Y -gmtime == gmtime -mod-localtime-indirect: -make: Invalid time value: ${:U1593536400}} +make: "varmod-localtime.mk" line 60: Invalid time value: ${:U1593536400}} != "mtime=11593536400}" -ocaltime=1593536400} -parse-errors: -make: Invalid time value: -1}. +make: "varmod-localtime.mk" line 60: Malformed conditional (${%Y:L:localtime=${:U1593536400}} != "mtime=11593536400}") +make: "varmod-localtime.mk" line 70: Invalid time value: -1} != "" -: -1 becomes ocaltime=-1}. -make: Invalid time value: 1}. +make: "varmod-localtime.mk" line 70: Malformed conditional (${:L:localtime=-1} != "") +make: "varmod-localtime.mk" line 79: Invalid time value: 1} != "" -: space 1 becomes ocaltime= 1}. -: 0 becomes ok. -: 1 becomes Thu Jan 1 01:00:01 1970. -: INT32_MAX becomes Tue Jan 19 04:14:07 2038. -: INT32_MAX + 1 becomes <normalized>. -make: Invalid time value: 10000000000000000000000000000000}. +make: "varmod-localtime.mk" line 79: Malformed conditional (${:L:localtime= 1} != "") +make: "varmod-localtime.mk" line 118: Invalid time value: 10000000000000000000000000000000} != "" -: overflow becomes ocaltime=10000000000000000000000000000000}. -make: Invalid time value: error}. +make: "varmod-localtime.mk" line 118: Malformed conditional (${:L:localtime=10000000000000000000000000000000} != "") +make: "varmod-localtime.mk" line 129: Invalid time value: error} != "" -: letter becomes ocaltime=error}. -exit status 0 +make: "varmod-localtime.mk" line 129: Malformed conditional (${:L:localtime=error} != "") +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/varmod-localtime.mk diff -u src/usr.bin/make/unit-tests/varmod-localtime.mk:1.5 src/usr.bin/make/unit-tests/varmod-localtime.mk:1.6 --- src/usr.bin/make/unit-tests/varmod-localtime.mk:1.5 Sat Oct 31 20:30:06 2020 +++ src/usr.bin/make/unit-tests/varmod-localtime.mk Mon Dec 21 20:47:29 2020 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-localtime.mk,v 1.5 2020/10/31 20:30:06 rillig Exp $ +# $NetBSD: varmod-localtime.mk,v 1.6 2020/12/21 20:47:29 rillig Exp $ # # Tests for the :localtime variable modifier, which formats a timestamp # using strftime(3) in local time. @@ -7,10 +7,6 @@ . error .endif -all: mod-localtime -all: mod-localtime-indirect -all: parse-errors - # Test for the default time format, %c. Since the time always varies, it's # only possible to check for the general format here. The names of the # month and weekday are always in English, independent from the locale. @@ -19,74 +15,122 @@ all: parse-errors . error .endif -mod-localtime: - @echo $@ - # modifier name too short - @echo ${%Y:L:localtim=1593536400} +# modifier name too short, falling back to the SysV modifier. +.if ${%Y:L:localtim=1593536400} != "%Y" +. error +.endif + + +# 2020-07-01T00:00:00Z +.if ${%Y:L:localtime=1593536400} != "2020" +. error +.endif + + +# modifier name too long, falling back to the SysV modifier. +.if ${%Y:L:localtimer=1593536400} != "%Y" +. error +.endif + + +# If the modifier name is not matched exactly, fall back to the +# :from=to modifier. +.if ${gmtime:L:gm%=local%} != "localtime" +. error +.endif + + +# As of 2020-08-16, it is not possible to pass the seconds via a +# variable expression. This is because parsing of the :localtime +# modifier stops at the '$' and returns to ApplyModifiers. +# +# There, a colon would be skipped but not a dollar. +# Parsing therefore continues at the '$' of the ${:U159...}, looking +# for an ordinary variable modifier. +# +# At this point, the ${:U} is expanded and interpreted as a variable +# modifier, which results in the error message "Unknown modifier '1'". +# +# If ApplyModifier_Localtime were to pass its argument through +# ParseModifierPart, this would work. +# +# XXX: Where does the empty line 4 in varmod-localtime.exp come from? +# TODO: Remove the \n from "Invalid time value: %s\n" in var.c. +.if ${%Y:L:localtime=${:U1593536400}} != "mtime=11593536400}" +. error +.endif + + +# Before var.c 1.631 from 2020-10-31 21:40:20, it was possible to pass +# negative time stamps to the :localtime modifier, resulting in dates before +# 1970. Going back 50 years in the past is not a practical use case for +# make. Therefore, since var.c 1.631, negative time stamps produce a +# parse error. +.if ${:L:localtime=-1} != "" +. error +.else +. error +.endif + + +# Spaces were allowed before var.c 1.631, not because it would make sense +# but just as a side-effect from using strtoul. +.if ${:L:localtime= 1} != "" +. error +.endif + + +# 0 means now; this differs from GNode.mtime, where a 0 means nonexistent. +# Since "now" constantly changes, the strongest possible test is to match the +# resulting pattern. +.if !${:L:localtime=0:tW:M??? ??? ?? ??\:??\:?? 20??} +. error +.endif + + +.if ${:L:localtime=1} != "Thu Jan 1 01:00:01 1970" +. error +.endif + + +# INT32_MAX +.if ${:L:localtime=2147483647} != "Tue Jan 19 04:14:07 2038" +. error +.endif + + +.if ${:L:localtime=2147483648} == "Tue Jan 19 04:14:08 2038" +# All systems that have unsigned time_t or 64-bit time_t. +.elif ${:L:localtime=2147483648} != "Fri Dec 13 21:45:52 1901" +# FreeBSD-12.0-i386 still has 32-bit signed time_t. +.else +. error +.endif + + +# Integer overflow, at least before var.c 1.631 from 2020-10-31. +# Because this modifier is implemented using strtoul, the parsed time was +# ULONG_MAX, which got converted to -1. This resulted in a time stamp of +# the second before 1970. +# +# Since var.c 1.613, the overflow is detected and produces a parse error. +.if ${:L:localtime=10000000000000000000000000000000} != "" +. error +.else +. error +.endif + +# Before var.c 1.613 from 2020-10-31, there was no error handling while +# parsing the :localtime modifier, thus no error message is printed. Parsing +# stopped after the '=', and the remaining string was parsed for more variable +# modifiers. Because of the unknown modifier 'e' from the 'error', the whole +# variable value was discarded and thus not printed. +.if ${:L:localtime=error} != "" +. error +.else +. error +.endif - # 2020-07-01T00:00:00Z - @echo ${%Y:L:localtime=1593536400} - # modifier name too long - @echo ${%Y:L:localtimer=1593536400} - - # If the modifier name is not matched exactly, fall back to the - # :from=to modifier. - @echo ${localtime:L:local%=gm%} == gmtime - -mod-localtime-indirect: - @echo $@: - - # As of 2020-08-16, it is not possible to pass the seconds via a - # variable expression. This is because parsing of the :localtime - # modifier stops at the '$' and returns to ApplyModifiers. - # - # There, a colon would be skipped but not a dollar. - # Parsing therefore continues at the '$' of the ${:U159...}, looking - # for an ordinary variable modifier. - # - # At this point, the ${:U} is expanded and interpreted as a variable - # modifier, which results in the error message "Unknown modifier '1'". - # - # If ApplyModifier_Localtime were to pass its argument through - # ParseModifierPart, this would work. - @echo ${%Y:L:localtime=${:U1593536400}} - -parse-errors: - @echo $@: - - # As of 2020-10-31, it is possible to pass negative time stamps - # to the :localtime modifier, resulting in dates before 1970. - # Going back 50 years in the past is not a practical use case for - # make. - : -1 becomes ${:L:localtime=-1}. - - # Spaces are allowed, not because it would make sense but just as - # a side-effect from using strtoul. - : space 1 becomes ${:L:localtime= 1}. - - # 0 means now; to get consistent test results, the actual value has - # to be normalized. - : 0 becomes ${:L:localtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}. - - : 1 becomes ${:L:localtime=1}. - - : INT32_MAX becomes ${:L:localtime=2147483647}. - - # This may be different if time_t is still a 32-bit signed integer. - : INT32_MAX + 1 becomes ${:L:localtime=2147483648}. - - # Integer overflow. - # Because this modifier is implemented using strtoul, the parsed - # time is ULONG_MAX, which gets converted to -1. This results - # in a time stamp of the second before 1970 (in UTC) or 3599 seconds - # after New Year's Day in Europe/Berlin. - : overflow becomes ${:L:localtime=10000000000000000000000000000000}. - - # As of 2020-10-31, there is no error handling while parsing the - # :localtime modifier, thus no error message is printed. Parsing - # stops after the '=', and the remaining string is parsed for - # more variable modifiers. Because of the unknown modifier 'e', - # the whole variable value is discarded and thus not printed. - : letter becomes ${:L:localtime=error}. +all: