Wed Jun 5 15:57:28 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / time / test-tz.c
blob47565cedecdfef9302a8529e684381b11024a260
1 #include <stdlib.h>
2 #include <time.h>
3 #include <string.h>
4 #include <stdio.h>
6 struct {
7 const char * env;
8 time_t expected;
9 } tests[] = {
10 {"TZ=MST", 832935315},
11 {"TZ=", 832910115},
12 {"TZ=:UTC", 832910115},
13 {"TZ=UTC", 832910115},
14 {"TZ=UTC0", 832910115}
18 int
19 main(int argc, char ** argv)
21 int errors = 0;
22 struct tm tm;
23 time_t t;
24 int i;
26 memset (&tm, 0, sizeof (tm));
27 tm.tm_isdst = 0;
28 tm.tm_year = 96; /* years since 1900 */
29 tm.tm_mon = 4;
30 tm.tm_mday = 24;
31 tm.tm_hour = 3;
32 tm.tm_min = 55;
33 tm.tm_sec = 15;
35 for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
37 putenv (tests[i].env);
38 tzset ();
39 t = mktime(&tm);
40 if (t != tests[i].expected)
42 printf ("%s: flunked test %d (expected %lu, got %lu)\n",
43 argv[0], i, (long) tests[i].expected, (long) t);
44 ++errors;
47 if (errors == 0)
49 puts ("No errors.");
50 exit (EXIT_SUCCESS);
52 else
54 printf ("%d errors.\n", errors);
55 exit (EXIT_FAILURE);