From 61bc216ff9e1d0a8a7fafce57ba916018cd6ac6d Mon Sep 17 00:00:00 2001
From: Vladislav Vaintroub <vvaintroub@gmail.com>
Date: Wed, 19 Nov 2025 13:01:56 +0100
Subject: [PATCH] MDEV-38029 my_tzinfo-t fails for certain TZ values on musl

From: Vladislav Vaintroub <vvaintroub@gmail.com>

The test fails for TZ values such as `PST8PDT` (present but outdated in
tzdb) and custom forms like `GST-1GDT`. On musl, these values do not
trigger the expected DST transitions, leading to incorrect DST offsets
or abbreviations.

This appears to be a musl libc bug; the same TZ values behave correctly
elsewhere, including Windows. We work around it by skipping the
affected tests when musl is detected.

Upstream-Status: Submitted [https://github.com/MariaDB/server/pull/4452]
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 unittest/mysys/my_tzinfo-t.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/unittest/mysys/my_tzinfo-t.c b/unittest/mysys/my_tzinfo-t.c
index b38ebd37..585d52f8 100644
--- a/unittest/mysys/my_tzinfo-t.c
+++ b/unittest/mysys/my_tzinfo-t.c
@@ -112,6 +112,20 @@ void test_timezone(const char *tz_env, const char **expected_tznames,
     }
   }
   ok(found, "%s: timezone_name = %s", tz_env, timezone_name);
+
+#if defined __linux__ && !defined __GLIBC__ && !defined __UCLIBC__
+  /*
+    MUSL incorrectly calculates UTC offsets and abbreviations
+    for certain values of TZ (DST related). See MDEV-38029
+    Skip tests in this case.
+  */
+  if (!strcmp(tz_env, "PST8PDT") || !strcmp(tz_env, "GST-1GDT"))
+  {
+    skip(6, "musl UTC offset/abbreviation bug, tzname %s, see MDEV-38029", tz_env);
+    return;
+  }
+#endif
+
   my_tzinfo(SUMMER_TIMESTAMP, &tz);
   ok(summer_gmt_off == tz.seconds_offset, "%s: Summer GMT offset %ld", tz_env, tz.seconds_offset);
   check_utc_offset(SUMMER_TIMESTAMP,tz.seconds_offset, tz_env);
