diff options
Diffstat (limited to 'time/tst-ctime.c')
-rw-r--r-- | time/tst-ctime.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/time/tst-ctime.c b/time/tst-ctime.c index e89a906bf8..884d69bfa0 100644 --- a/time/tst-ctime.c +++ b/time/tst-ctime.c @@ -24,6 +24,7 @@ static int do_test (void) { char *str; + char strb[32]; time_t t; /* Use glibc time zone extension "TZ=:" to to guarantee that UTC @@ -36,11 +37,21 @@ do_test (void) str = ctime (&t); TEST_COMPARE_STRING (str, "Thu Jan 1 00:00:00 1970\n"); + /* Same as before but with ctime_r. */ + str = ctime_r (&t, strb); + TEST_VERIFY (str == strb); + TEST_COMPARE_STRING (str, "Thu Jan 1 00:00:00 1970\n"); + /* Check if the max time value for 32 bit time_t can be converted. */ t = 0x7fffffff; str = ctime (&t); TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n"); + /* Same as before but with ctime_r. */ + str = ctime_r (&t, strb); + TEST_VERIFY (str == strb); + TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n"); + /* Check if we run on port with 32 bit time_t size */ time_t tov; if (__builtin_add_overflow (t, 1, &tov)) @@ -50,6 +61,11 @@ do_test (void) str = ctime (&tov); TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n"); + /* Same as before but with ctime_r. */ + str = ctime_r (&tov, strb); + TEST_VERIFY (str == strb); + TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n"); + return 0; } |