From d7aaf9bee335377dcb2ae7fc2d3ee3bbd96a4db8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 12 Sep 2024 15:47:42 -0700 Subject: [PATCH] tests/c_lib: Ensure TZ value is UTC for ctime/ctime_r tests When testing these functions with CONFIG_NATIVE_LIBC, force the TZ environment variable to UTC to ensure they produce the expected results. Signed-off-by: Keith Packard --- tests/lib/c_lib/common/src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/lib/c_lib/common/src/main.c b/tests/lib/c_lib/common/src/main.c index f7db63c0ad8609..2e1f5cdf4cbb43 100644 --- a/tests/lib/c_lib/common/src/main.c +++ b/tests/lib/c_lib/common/src/main.c @@ -1166,6 +1166,9 @@ ZTEST(libc_common, test_time_ctime) char buf[26] = {0}; time_t test1 = 1718260000; +#ifdef CONFIG_NATIVE_LIBC + setenv("TZ", "UTC", 1); +#endif zassert_not_null(ctime_r(&test1, buf)); zassert_equal(strncmp("Thu Jun 13 06:26:40 2024\n", buf, sizeof(buf)), 0);