[committed] libstdc++: Ensure ./tzdata.zi is present in testcase
Jonathan Wakely
jwakely@redhat.com
Fri Aug 21 17:35:20 GMT 2026
When libstdc++ is configured without an embedded copy of the tzdata.zi
file (e.g. when using --with-libstdcxx-zoneinfo) this testcase can fail.
It aborts after chrono::reload_tzdb() throws an exception due to being
unable to load tzdata.zi from the __gnu_cxx::zoneinfo_dir_override()
path used in the test.
The test passes using the default configuration because the embedded
tzdata.zi is used, and it passes if another test has already run and
created ./tzdata.zi in the test's current working directory.
The solution is to create a dummy ./tzdata.zi file, which only needs to
contain a version line because we only care that chrono::reload_tzdb()
finishes, not that it loads valid data.
No other tests are affected, because they either write out a tzdata.zi
file, or call chrono::get_tzdb() (which has a fallback to a UTC-only
database). Only calling chrono::reload_tzdb() without a file present is
a problem, as in this test.
libstdc++-v3/ChangeLog:
* testsuite/std/time/clock/utc/leap_second_info-2.cc: Create
empty ./tzdata.zi file.
---
Tested x86_64-linux. Pushed to trunk and gcc-16.
.../testsuite/std/time/clock/utc/leap_second_info-2.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libstdc++-v3/testsuite/std/time/clock/utc/leap_second_info-2.cc b/libstdc++-v3/testsuite/std/time/clock/utc/leap_second_info-2.cc
index 59634b34944f..4f97c2eacaa5 100644
--- a/libstdc++-v3/testsuite/std/time/clock/utc/leap_second_info-2.cc
+++ b/libstdc++-v3/testsuite/std/time/clock/utc/leap_second_info-2.cc
@@ -103,6 +103,9 @@ Leap 2120 Dec 30 23:59:59 - S
int main()
{
+ // chrono::reload_tzdb() requires ./tzdata.zi to be present.
+ std::ofstream("tzdata.zi") << "# version empty\n";
+
test_known_leaps();
test_future_leaps();
}
--
2.55.0
More information about the Libstdc++
mailing list