Skip to content

Commit

Permalink
tests/c_lib: Ensure TZ value is UTC for ctime/ctime_r tests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
keith-packard authored and aescolar committed Sep 16, 2024
1 parent 6ce257c commit d7aaf9b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/lib/c_lib/common/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d7aaf9b

Please sign in to comment.