1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-21 18:03:41 +03:00

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.
This commit is contained in:
Luca Boccassi 2024-01-26 00:22:38 +00:00
parent 107d036c03
commit 1e902c3463
3 changed files with 14 additions and 1 deletions

View File

@ -254,4 +254,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);

View File

@ -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");

View File

@ -1171,6 +1171,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",