should have test it better, fix non-thread compile
[uclibc-ng.git] / test / time / bug-asctime_r.c
blob1fcc4659f1db6bfedca73ed1274ccb15600052c7
1 /* Note: we disable this on uClibc because we dont bother
2 * verifying if the year is sane ... we just return ????
3 * for the year value ...
4 */
6 #include <errno.h>
7 #include <limits.h>
8 #include <stdio.h>
9 #include <time.h>
12 static int
13 do_test (void)
15 int result = 0;
16 time_t t = time (NULL);
17 struct tm *tp = localtime (&t);
18 tp->tm_year = 10000 - 1900;
19 char buf[1000];
20 errno = 0;
21 buf[26] = '\xff';
22 char *s = asctime_r (tp, buf);
23 if (s != NULL || errno != EOVERFLOW)
25 puts ("asctime_r did not fail correctly");
26 result = 1;
28 if (buf[26] != '\xff')
30 puts ("asctime_r overwrote 27th byte in buffer");
31 result = 1;
33 return result;
36 #define TEST_FUNCTION do_test ()
37 #include "../test-skeleton.c"