Module Name: src Committed By: rillig Date: Sat Aug 19 08:19:25 UTC 2023
Modified Files: src/usr.bin/make/unit-tests: varmod-gmtime.mk varmod-mtime.mk Log Message: tests/make: document bug in ':gmtime' with '%s' To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.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/varmod-gmtime.mk diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.15 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.16 --- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.15 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/varmod-gmtime.mk Sat Aug 19 08:19:25 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-gmtime.mk,v 1.15 2023/06/01 20:56:35 rillig Exp $ +# $NetBSD: varmod-gmtime.mk,v 1.16 2023/08/19 08:19:25 rillig Exp $ # # Tests for the :gmtime variable modifier, which formats a timestamp # using strftime(3) in UTC. @@ -145,4 +145,54 @@ . error .endif + +# As of 2023-08-19, ':gmtime' but not ':localtime' reports wrong values for +# '%s', depending on the operating system and the timezone, as demonstrated by +# the following test program: +# +# for mod in gmtime localtime; do +# for tz in UTC Europe/Berlin America/Los_Angeles; do +# TZ=$tz bmake -r -v "\${%F %T %z %s $mod $tz:L:$mod}" +# done +# done +# +# Cygwin: +# 2023-08-19 07:34:06 +0000 1692430446 gmtime UTC +# 2023-08-19 07:34:06 +0000 1692430446 gmtime Europe/Berlin +# 2023-08-19 07:34:06 +0000 1692430446 gmtime America/Los_Angeles +# 2023-08-19 07:34:06 +0000 1692430446 localtime UTC +# 2023-08-19 09:34:07 +0200 1692430447 localtime Europe/Berlin +# 2023-08-19 00:34:07 -0700 1692430447 localtime America/Los_Angeles +# +# Looks good: +# * ':gmtime' consistently reports timezone offset '+0000'. +# * '%s' is independent of the timezone. +# +# NetBSD 10.99: +# 2023-08-19 07:34:37 +0000 1692430477 gmtime UTC +# 2023-08-19 07:34:37 +0100 1692426877 gmtime Europe/Berlin +# 2023-08-19 07:34:37 -0800 1692459277 gmtime America/Los_Angeles +# 2023-08-19 07:34:37 +0000 1692430477 localtime UTC +# 2023-08-19 09:34:37 +0200 1692430477 localtime Europe/Berlin +# 2023-08-19 00:34:37 -0700 1692430477 localtime America/Los_Angeles +# +# Looks bad: +# * ':gmtime' reports different timezone offsets. +# * ':gmtime' reports different seconds since the Epoch. +# * ':gmtime' reports the timezone offset '+0100' for Europe/Berlin, +# even though at 2023-08-19, DST with offset '+0200' was in place. +# +# Debian: +# 2023-08-19 07:29:10 +0000 1692430150 gmtime UTC +# 2023-08-19 07:29:10 +0000 1692426550 gmtime Europe/Berlin +# 2023-08-19 07:29:10 +0000 1692458950 gmtime America/Los_Angeles +# 2023-08-19 07:29:10 +0000 1692430150 localtime UTC +# 2023-08-19 09:29:10 +0200 1692430150 localtime Europe/Berlin +# 2023-08-19 00:29:10 -0700 1692430150 localtime America/Los_Angeles +# +# Looks mixed: +# * ':gmtime' reports the correct timezone offset '+0000'. +# * ':gmtime' reports different seconds since the Epoch, and the '%s' +# value cannot be derived from the '%F %T %z' values. + all: Index: src/usr.bin/make/unit-tests/varmod-mtime.mk diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.4 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.5 --- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.4 Sat Aug 19 01:34:21 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.mk Sat Aug 19 08:19:25 2023 @@ -1,11 +1,11 @@ -# $NetBSD: varmod-mtime.mk,v 1.4 2023/08/19 01:34:21 sjg Exp $ +# $NetBSD: varmod-mtime.mk,v 1.5 2023/08/19 08:19:25 rillig Exp $ # # Tests for the ':mtime' variable modifier, which maps each word of the # expression to that file's modification time. # Note: strftime() uses mktime() for %s and mktime() assumes localtime # so this should match time() -start:= ${%s:L:localtime} +start:= ${%s:L:localtime} # see varmod-gmtime.mk, keyword '%s' # Ensure that this makefile exists and has a modification time. If the file