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:
parent
6ce257cc76
commit
d7aaf9bee3
1 changed files with 3 additions and 0 deletions
|
@ -1166,6 +1166,9 @@ ZTEST(libc_common, test_time_ctime)
|
||||||
char buf[26] = {0};
|
char buf[26] = {0};
|
||||||
time_t test1 = 1718260000;
|
time_t test1 = 1718260000;
|
||||||
|
|
||||||
|
#ifdef CONFIG_NATIVE_LIBC
|
||||||
|
setenv("TZ", "UTC", 1);
|
||||||
|
#endif
|
||||||
zassert_not_null(ctime_r(&test1, buf));
|
zassert_not_null(ctime_r(&test1, buf));
|
||||||
zassert_equal(strncmp("Thu Jun 13 06:26:40 2024\n", buf, sizeof(buf)), 0);
|
zassert_equal(strncmp("Thu Jun 13 06:26:40 2024\n", buf, sizeof(buf)), 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue