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 <keithp@keithp.com>
This commit is contained in:
Keith Packard 2024-09-12 15:47:42 -07:00 committed by Alberto Escolar
commit d7aaf9bee3

View file

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