SHA256
1
0
forked from pool/coreutils
coreutils/coreutils-fix-gnulib-time_r-tests.patch

96 lines
3.2 KiB
Diff

2 upstream gnulib commits for coreutils-9.5 to skip localtime_r tests
when the timezone 'Europe/Paris' does not work.
Commit 1:
http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=f130f5426ecd4edd559
From f130f5426ecd4edd5596797e0a5721b927f80126 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 30 Mar 2024 13:28:01 -0600
Subject: [PATCH 1/2] time_r-tests: skip French tests if no Europe/Paris
* tests/test-localtime_r.c (main):
* tests/test-localtime_r-mt.c (main):
If TZ='Europe/Paris' does not work, skip these tests.
Commit 2:
http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=2c04db80e2c52b8f05b
From 2c04db80e2c52b8f05b4136af955510e7d370470 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 30 Mar 2024 22:50:39 +0100
Subject: [PATCH 2/2] time_r tests: Avoid misleading skip message on native
Windows.
* tests/test-localtime_r.c (main): Use the macro FRENCH_TZ.
* tests/test-localtime_r-mt.c (main): Likewise.
---
gnulib-tests/test-localtime_r-mt.c | 21 +++++++++++++++++++++
gnulib-tests/test-localtime_r.c | 21 +++++++++++++++++++++
2 files changed, 42 insertions(+)
Index: gnulib-tests/test-localtime_r-mt.c
===================================================================
--- gnulib-tests/test-localtime_r-mt.c.orig
+++ gnulib-tests/test-localtime_r-mt.c
@@ -107,6 +107,27 @@ main (int argc, char *argv[])
{
setenv ("TZ", FRENCH_TZ, 1);
+ /* Check that this TZ works. */
+ {
+ time_t t = 0; /* 1970-01-01 01:00:00 */
+ struct tm *result = localtime (&t);
+ if (! (result
+ && result->tm_sec == 0
+ && result->tm_min == 0
+ && result->tm_hour == 1
+ && result->tm_mday == 1
+ && result->tm_mon == 1 - 1
+ && result->tm_year == 1970 - 1900
+ && result->tm_wday == 4
+ && result->tm_yday == 0
+ && result->tm_isdst == 0))
+ {
+ fputs ("Skipping test: TZ='" FRENCH_TZ "' is not Paris time\n",
+ stderr);
+ return 77;
+ }
+ }
+
/* Create the threads. */
gl_thread_create (thread1_func, NULL);
gl_thread_create (thread2_func, NULL);
Index: gnulib-tests/test-localtime_r.c
===================================================================
--- gnulib-tests/test-localtime_r.c.orig
+++ gnulib-tests/test-localtime_r.c
@@ -43,6 +43,27 @@ main (void)
{
setenv ("TZ", FRENCH_TZ, 1);
+ /* Check that this TZ works. */
+ {
+ time_t t = 0; /* 1970-01-01 01:00:00 */
+ struct tm *result = localtime (&t);
+ if (! (result
+ && result->tm_sec == 0
+ && result->tm_min == 0
+ && result->tm_hour == 1
+ && result->tm_mday == 1
+ && result->tm_mon == 1 - 1
+ && result->tm_year == 1970 - 1900
+ && result->tm_wday == 4
+ && result->tm_yday == 0
+ && result->tm_isdst == 0))
+ {
+ fputs ("Skipping test: TZ='" FRENCH_TZ "' is not Paris time\n",
+ stderr);
+ return 77;
+ }
+ }
+
/* Note: The result->tm_gmtoff values and the result->tm_zone values are the
same (3600, "CET" or 7200, "CEST") across all tested platforms:
glibc, musl, macOS, FreeBSD, NetBSD, OpenBSD, Minix, Cygwin, Android. */