]> Savannah Git Hosting - gnulib.git/commitdiff
time_r-tests: skip French tests if no Europe/Paris
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 30 Mar 2024 19:28:01 +0000 (13:28 -0600)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 30 Mar 2024 19:28:47 +0000 (13:28 -0600)
* tests/test-localtime_r.c (main):
* tests/test-localtime_r-mt.c (main):
If TZ='Europe/Paris' does not work, skip these tests.

ChangeLog
tests/test-localtime_r-mt.c
tests/test-localtime_r.c

index eab98607a2a2b891e4fd9619cd060d66bf42812c..ecb46321962c6b876a4b63b430503f8b60189d19 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-30  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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.
+
 2024-03-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        intprops: pacify GCC < 10 -Wsign-compare
index ae371a89464e1f14f26e92784af4a1a51bcb69ff..b09e86854f953e6f5b0f8016b3a7a453c616ab2e 100644 (file)
@@ -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='Europe/Paris' is not Paris time\n",
+               stderr);
+        return 77;
+      }
+  }
+
   /* Create the threads.  */
   gl_thread_create (thread1_func, NULL);
   gl_thread_create (thread2_func, NULL);
index 70ec3b5d4f2208ab5ed7bdc5e97e082dd2bcd97f..6b3da1af1997f2944dd27d4bf1c6be9cd955b524 100644 (file)
@@ -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='Europe/Paris' 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.  */