bug#70070: FAIL: test-localtime_r

2024-03-30 Thread Paul Eggert

On 3/29/24 08:15, Andreas Schwab wrote:

On Mär 29 2024, Bruno Haible wrote:


Yes. And make sure that it has a time zone database installed at all.


Why? That doesn't make any sense.


Although Andreas is not clear, perhaps he is alluding to the fact that 
Gnulib's localtime_r tests assume that TZ='Europe/Paris' stands for 
Paris time. POSIX doesn't guarantee this, so the implication is that the 
tests should be skipped when Europe/Paris does not work.


I installed the attached to do that. I don't know whether this will fix 
Andreas's problem, whatever it is.From f130f5426ecd4edd5596797e0a5721b927f80126 Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Sat, 30 Mar 2024 13:28:01 -0600
Subject: [PATCH] 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.
---
 ChangeLog   |  7 +++
 tests/test-localtime_r-mt.c | 21 +
 tests/test-localtime_r.c| 21 +
 3 files changed, 49 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index eab98607a2..ecb4632196 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-30  Paul Eggert  
+
+	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  
 
 	intprops: pacify GCC < 10 -Wsign-compare
diff --git a/tests/test-localtime_r-mt.c b/tests/test-localtime_r-mt.c
index ae371a8946..b09e86854f 100644
--- a/tests/test-localtime_r-mt.c
+++ b/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 ();
+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);
diff --git a/tests/test-localtime_r.c b/tests/test-localtime_r.c
index 70ec3b5d4f..6b3da1af19 100644
--- a/tests/test-localtime_r.c
+++ b/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 ();
+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.  */
-- 
2.44.0



bug#70070: FAIL: test-localtime_r

2024-03-29 Thread Bruno Haible
Andreas Schwab wrote:
> > Yes. And make sure that it has a time zone database installed at all.
> 
> Why? That doesn't make any sense.

You can leave the consideration of which test case makes sense or not
on my side.

What we need from you, as a reporter, is a statement on which
platform (distro and version) you saw the test failure.
If we don't have this, there is no good way for us to reproduce the issue,
and we'll have to close the ticket.

Bruno








bug#70070: FAIL: test-localtime_r

2024-03-29 Thread Andreas Schwab
On Mär 29 2024, Bruno Haible wrote:

> Yes. And make sure that it has a time zone database installed at all.

Why? That doesn't make any sense.





bug#70070: FAIL: test-localtime_r

2024-03-29 Thread Bruno Haible
Andreas Schwab wrote:
> > FAIL: test-localtime_r
> > ==
> > 
> > test-localtime_r.c:58: assertion 'result->tm_hour == 18' failed
> > FAIL test-localtime_r (exit status: 134)
> > 
> > FAIL: test-localtime_r-mt
> > =
> > 
> > thread2 disturbed by thread1!
> > thread1 disturbed by thread2!
> > FAIL test-localtime_r-mt (exit status: 134)

The second failure is a consequence of the first one. So, there is no MT-safety
problem, "just" that localtime_r produces wrong results.

I've seen this happen on OSes with a time zone database that is older than
5 or 10 years.

Pádraig Brady wrote:
> It may help to detail your platform.

Yes. And make sure that it has a time zone database installed at all.

Bruno








bug#70070: FAIL: test-localtime_r

2024-03-29 Thread Pádraig Brady

On 29/03/2024 12:40, Andreas Schwab wrote:

FAIL: test-localtime_r
==

test-localtime_r.c:58: assertion 'result->tm_hour == 18' failed
FAIL test-localtime_r (exit status: 134)

FAIL: test-localtime_r-mt
=

thread2 disturbed by thread1!
thread1 disturbed by thread2!
FAIL test-localtime_r-mt (exit status: 134)



CC'ing gnulib as those tests are from gnulib.
It may help to detail your platform.

thanks,
Pádraig.





bug#70070: FAIL: test-localtime_r

2024-03-29 Thread Andreas Schwab
FAIL: test-localtime_r
==

test-localtime_r.c:58: assertion 'result->tm_hour == 18' failed
FAIL test-localtime_r (exit status: 134)

FAIL: test-localtime_r-mt
=

thread2 disturbed by thread1!
thread1 disturbed by thread2!
FAIL test-localtime_r-mt (exit status: 134)

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."