tests/make: document bug in ':gmtime' with '%s'

This commit is contained in:
rillig 2023-08-19 08:19:25 +00:00
parent 14ae945a05
commit 9fec43bd63
2 changed files with 53 additions and 3 deletions

View File

@ -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:

View File

@ -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