Resolves: RHEL-108555,RHEL-108568,RHEL-108576,RHEL-108584,RHEL-108596,RHEL-108598,RHEL-109096,RHEL-109488,RHEL-111065,RHEL-31756,RHEL-50103
64 lines
2.2 KiB
Diff
64 lines
2.2 KiB
Diff
From e0ac4a4632c99750ad63476c3ae62a1988b2883b Mon Sep 17 00:00:00 2001
|
|
From: Luca Boccassi <bluca@debian.org>
|
|
Date: Fri, 26 Jan 2024 00:22:38 +0000
|
|
Subject: [PATCH] test: unset TZ before timezone-sensitive unit tests are run
|
|
|
|
Some tests have hard-coded results that need to match, and change if
|
|
the caller has a timezone set via the TZ= environment variable, as it
|
|
is the case during reproducible build tests. Unset it.
|
|
|
|
(cherry picked from commit 1e902c3463024bb328bf0d01a5d58a69e1ccf739)
|
|
|
|
Related: RHEL-109488
|
|
---
|
|
src/test/test-calendarspec.c | 9 ++++++++-
|
|
src/test/test-date.c | 3 +++
|
|
src/test/test-time-util.c | 3 +++
|
|
3 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
|
|
index 564983b699..4699991535 100644
|
|
--- a/src/test/test-calendarspec.c
|
|
+++ b/src/test/test-calendarspec.c
|
|
@@ -260,4 +260,11 @@ TEST(calendar_spec_from_string) {
|
|
assert_se(calendar_spec_from_string("*:4,30:*\n", &c) == -EINVAL);
|
|
}
|
|
|
|
-DEFINE_TEST_MAIN(LOG_INFO);
|
|
+static int intro(void) {
|
|
+ /* Tests have hard-coded results that do not expect a specific timezone to be set by the caller */
|
|
+ assert_se(unsetenv("TZ") >= 0);
|
|
+
|
|
+ return EXIT_SUCCESS;
|
|
+}
|
|
+
|
|
+DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|
|
diff --git a/src/test/test-date.c b/src/test/test-date.c
|
|
index 097066b61a..cc11bd999e 100644
|
|
--- a/src/test/test-date.c
|
|
+++ b/src/test/test-date.c
|
|
@@ -62,6 +62,9 @@ static void test_one_noutc(const char *p) {
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
+ /* Tests have hard-coded results that do not expect a specific timezone to be set by the caller */
|
|
+ assert_se(unsetenv("TZ") >= 0);
|
|
+
|
|
test_setup_logging(LOG_DEBUG);
|
|
|
|
test_one("17:41");
|
|
diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c
|
|
index a5443ad7d7..21b05a3010 100644
|
|
--- a/src/test/test-time-util.c
|
|
+++ b/src/test/test-time-util.c
|
|
@@ -1016,6 +1016,9 @@ TEST(timezone_offset_change) {
|
|
}
|
|
|
|
static int intro(void) {
|
|
+ /* Tests have hard-coded results that do not expect a specific timezone to be set by the caller */
|
|
+ assert_se(unsetenv("TZ") >= 0);
|
|
+
|
|
log_info("realtime=" USEC_FMT "\n"
|
|
"monotonic=" USEC_FMT "\n"
|
|
"boottime=" USEC_FMT "\n",
|