summaryrefslogtreecommitdiffstats
path: root/debian/patches/test-unset-TZ-before-timezone-sensitive-unit-tests-are-ru.patch
blob: 2daa9993cd13963e0f77b68ca5b88f84ad141e7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From: Luca Boccassi <bluca@debian.org>
Date: Fri, 26 Jan 2024 00:22:38 +0000
Subject: 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)
(cherry picked from commit 85c88db9c64242f65c814f1ede467ef66066e663)
(cherry picked from commit d7fa5b8acbb5013992ae93c120845f0dc3fcfa93)
(cherry picked from commit 4d6d1a9f0557771e09a210ea9e83a7ed20df78de)
(cherry picked from commit d91a1c0f2c661731bc8a2149807ed9fd613b7c80)
---
 src/test/test-calendarspec.c | 3 +++
 src/test/test-date.c         | 3 +++
 src/test/test-time-util.c    | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
index 1b04186..a3bb2d8 100644
--- a/src/test/test-calendarspec.c
+++ b/src/test/test-calendarspec.c
@@ -121,6 +121,9 @@ static void test_hourly_bug_4031(void) {
 int main(int argc, char* argv[]) {
         CalendarSpec *c;
 
+        /* Tests have hard-coded results that do not expect a specific timezone to be set by the caller */
+        assert_se(unsetenv("TZ") >= 0);
+
         test_one("Sat,Thu,Mon-Wed,Sat-Sun", "Mon..Thu,Sat,Sun *-*-* 00:00:00");
         test_one("Sat,Thu,Mon..Wed,Sat..Sun", "Mon..Thu,Sat,Sun *-*-* 00:00:00");
         test_one("Mon,Sun 12-*-* 2,1:23", "Mon,Sun 2012-*-* 01,02:23:00");
diff --git a/src/test/test-date.c b/src/test/test-date.c
index 47b7096..cfd2338 100644
--- a/src/test/test-date.c
+++ b/src/test/test-date.c
@@ -65,6 +65,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 877b24c..3c673e7 100644
--- a/src/test/test-time-util.c
+++ b/src/test/test-time-util.c
@@ -525,6 +525,9 @@ static void test_map_clock_usec(void) {
 int main(int argc, char *argv[]) {
         test_setup_logging(LOG_INFO);
 
+        /* 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",