All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing: TestNoTimezone: fix the test case for Glibc
@ 2023-08-01 13:21 Romain Naour
  2023-08-01 21:15 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Romain Naour @ 2023-08-01 13:21 UTC (permalink / raw)
  To: buildroot; +Cc: Romain Naour

We have changed to a Glibc based toolchain recently [1] but the
behavior of TZ handling is not the same between libc implementation
when no Zone Database is installed.

musl and uClibc-ng return "UTC" when the data file of the requested
time zone is missing or when TZ is not set.

 # TZ=America/Los_Angeles date +%Z
 UTC

 # TZ= date +%Z
 UTC

Glibc return all or part of TZ content or "Universal" if TZ is empty.

 # TZ=America/Los_Angeles date +%Z
 America

 # TZ= date +%Z
 Universal

As demonstrated by TestAllTimezone, Glibc return "PDT" when the
America/Los_Angeles time zone data file is installed:

 # TZ=America/Los_Angeles date +%Z
 PDT

Since the Glibc behavior seems weird (not a bug [2]) when TZ is
set but the time zone data file is missing, update our test
to check against a string defined in the Glibc code [3].

[1] f89f52168fcb667a3e8e43f6f44d5b1ca3961a8c
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=30710
[3] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c;h=78c18f8147415c92dc6eb735be672fa7e0b8f76e;hb=47b76f6d1d3a5ad13e585dbcc616aaea62b8bb20#l380

Ref:
https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

Fixe:
https://gitlab.com/buildroot.org/buildroot/-/jobs/4768561117

Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
 support/testing/tests/core/test_timezone.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/support/testing/tests/core/test_timezone.py b/support/testing/tests/core/test_timezone.py
index 0e5009494d..bf4a47fcde 100644
--- a/support/testing/tests/core/test_timezone.py
+++ b/support/testing/tests/core/test_timezone.py
@@ -22,8 +22,11 @@ class TestNoTimezone(infra.basetest.BRTest):
         boot_armv5_cpio(self.emulator, self.builddir)
         tz, _ = self.emulator.run("TZ=UTC date +%Z")
         self.assertEqual(tz[0].strip(), "UTC")
-        tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
-        self.assertEqual(tz[0].strip(), "UTC")
+        # This test is Glibc specific since there is no Time Zone Database installed
+        # and other C libraries use their own rule for returning time zone name or
+        # abbreviation when TZ is empty or set with a not installed time zone data file.
+        tz, _ = self.emulator.run("TZ= date +%Z")
+        self.assertEqual(tz[0].strip(), "Universal")
 
 
 class TestAllTimezone(infra.basetest.BRTest):
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH] support/testing: TestNoTimezone: fix the test case for Glibc
  2023-08-01 13:21 [Buildroot] [PATCH] support/testing: TestNoTimezone: fix the test case for Glibc Romain Naour
@ 2023-08-01 21:15 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-08-01 21:15 UTC (permalink / raw)
  To: Romain Naour; +Cc: buildroot

On Tue,  1 Aug 2023 15:21:13 +0200
Romain Naour <romain.naour@gmail.com> wrote:

> We have changed to a Glibc based toolchain recently [1] but the
> behavior of TZ handling is not the same between libc implementation
> when no Zone Database is installed.
> 
> musl and uClibc-ng return "UTC" when the data file of the requested
> time zone is missing or when TZ is not set.
> 
>  # TZ=America/Los_Angeles date +%Z
>  UTC
> 
>  # TZ= date +%Z
>  UTC
> 
> Glibc return all or part of TZ content or "Universal" if TZ is empty.
> 
>  # TZ=America/Los_Angeles date +%Z
>  America
> 
>  # TZ= date +%Z
>  Universal
> 
> As demonstrated by TestAllTimezone, Glibc return "PDT" when the
> America/Los_Angeles time zone data file is installed:
> 
>  # TZ=America/Los_Angeles date +%Z
>  PDT
> 
> Since the Glibc behavior seems weird (not a bug [2]) when TZ is
> set but the time zone data file is missing, update our test
> to check against a string defined in the Glibc code [3].
> 
> [1] f89f52168fcb667a3e8e43f6f44d5b1ca3961a8c
> [2] https://sourceware.org/bugzilla/show_bug.cgi?id=30710
> [3] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c;h=78c18f8147415c92dc6eb735be672fa7e0b8f76e;hb=47b76f6d1d3a5ad13e585dbcc616aaea62b8bb20#l380
> 
> Ref:
> https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
> 
> Fixe:
> https://gitlab.com/buildroot.org/buildroot/-/jobs/4768561117
> 
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> ---
>  support/testing/tests/core/test_timezone.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-01 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01 13:21 [Buildroot] [PATCH] support/testing: TestNoTimezone: fix the test case for Glibc Romain Naour
2023-08-01 21:15 ` Thomas Petazzoni via buildroot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.