Define dl_iterate_phdr to test which uses -nostdlib.
[glibc.git] / time / tst-mktime.c
blob8bc7631461525ebefa3e31f7e35daee49bb3ff24
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <time.h>
6 int
7 main (void)
9 struct tm time_str, *tm;
10 time_t t;
11 char daybuf[20];
12 int result;
14 time_str.tm_year = 2001 - 1900;
15 time_str.tm_mon = 7 - 1;
16 time_str.tm_mday = 4;
17 time_str.tm_hour = 0;
18 time_str.tm_min = 0;
19 time_str.tm_sec = 1;
20 time_str.tm_isdst = -1;
22 if (mktime (&time_str) == -1)
24 (void) puts ("-unknown-");
25 result = 1;
27 else
29 (void) strftime (daybuf, sizeof (daybuf), "%A", &time_str);
30 (void) puts (daybuf);
31 result = strcmp (daybuf, "Wednesday") != 0;
34 setenv ("TZ", "EST+5", 1);
35 #define EVENING69 1 * 60 * 60 + 2 * 60 + 29
36 t = EVENING69;
37 tm = localtime (&t);
38 if (tm == NULL)
40 (void) puts ("localtime returned NULL");
41 result = 1;
43 else
45 time_str = *tm;
46 t = mktime (&time_str);
47 if (t != EVENING69)
49 printf ("mktime returned %ld, expected %d\n",
50 (long) t, EVENING69);
51 result = 1;
53 else
54 (void) puts ("Dec 31 1969 EST test passed");
56 setenv ("TZ", "CET-1", 1);
57 t = mktime (&time_str);
58 if (t != (time_t) -1)
60 printf ("mktime returned %ld, expected -1\n", (long) t);
61 result = 1;
63 else
64 (void) puts ("Dec 31 1969 CET test passed");
67 return result;