Make performance improvement to MIPS memcpy for small copies.
[glibc.git] / time / tst-posixtz.c
blob16aa19d65488c8c5354865112a321cc85725c639
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <time.h>
6 struct
8 time_t when;
9 const char *tz;
10 const char *result;
11 } tests[] =
13 { 909312849L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
14 "1998/10/25 21:54:09 dst=1 zone=AEDST" },
15 { 924864849L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
16 "1999/04/23 20:54:09 dst=0 zone=AEST" },
17 { 919973892L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
18 "1999/02/26 07:18:12 dst=1 zone=AEDST" },
19 { 909312849L, "EST+5EDT,M4.1.0/2,M10.5.0/2",
20 "1998/10/25 05:54:09 dst=0 zone=EST" },
21 { 909312849L, "EST5EDT,M4.1.0/2,M10.5.0/2",
22 "1998/10/25 05:54:09 dst=0 zone=EST" },
23 { 909312849L, "<EST5>5EDT,M4.1.0/2,M10.5.0/2",
24 "1998/10/25 05:54:09 dst=0 zone=EST5" },
25 { 924864849L, "EST+5EDT,M4.1.0/2,M10.5.0/2",
26 "1999/04/23 06:54:09 dst=1 zone=EDT" },
27 { 919973892L, "EST+5EDT,M4.1.0/2,M10.5.0/2",
28 "1999/02/25 15:18:12 dst=0 zone=EST" },
31 static int
32 do_test (void)
34 int result = 0;
35 size_t cnt;
37 for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
39 char buf[100];
40 struct tm *tmp;
42 printf ("TZ = \"%s\", time = %jd => ", tests[cnt].tz,
43 (intmax_t) tests[cnt].when);
44 fflush (stdout);
46 setenv ("TZ", tests[cnt].tz, 1);
48 tmp = localtime (&tests[cnt].when);
50 snprintf (buf, sizeof (buf),
51 "%04d/%02d/%02d %02d:%02d:%02d dst=%d zone=%s",
52 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
53 tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tmp->tm_isdst,
54 tzname[tmp->tm_isdst ? 1 : 0]);
56 fputs (buf, stdout);
58 if (strcmp (buf, tests[cnt].result) == 0)
59 puts (", OK");
60 else
62 result = 1;
63 puts (", FAIL");
67 setenv ("TZ", "Universal", 1);
68 localtime (&tests[0].when);
69 printf ("TZ = \"Universal\" daylight %d tzname = { \"%s\", \"%s\" }",
70 daylight, tzname[0], tzname[1]);
71 if (! daylight)
72 puts (", OK");
73 else
75 result = 1;
76 puts (", FAIL");
79 setenv ("TZ", "AEST-10AEDST-11,M10.5.0,M3.5.0", 1);
80 tzset ();
81 printf ("TZ = \"AEST-10AEDST-11,M10.5.0,M3.5.0\" daylight %d"
82 " tzname = { \"%s\", \"%s\" }", daylight, tzname[0], tzname[1]);
83 if (daylight
84 && strcmp (tzname[0], "AEST") == 0 && strcmp (tzname[1], "AEDST") == 0)
85 puts (", OK");
86 else
88 result = 1;
89 puts (", FAIL");
92 setenv ("TZ", "<AB1>-10<AB2>-11,M10.5.0,M3.5.0", 1);
93 tzset ();
94 printf ("TZ = \"<AB1>-10<AB2>-11,M10.5.0,M3.5.0\" daylight %d"
95 " tzname = { \"%s\", \"%s\" }", daylight, tzname[0], tzname[1]);
96 if (daylight
97 && strcmp (tzname[0], "AB1") == 0 && strcmp (tzname[1], "AB2") == 0)
98 puts (", OK");
99 else
101 result = 1;
102 puts (", FAIL");
105 setenv ("TZ", "<BB1>-10", 1);
106 tzset ();
107 printf ("TZ = \"<BB1>-10\" daylight %d"
108 " tzname = { \"%s\", \"%s\" }", daylight, tzname[0], tzname[1]);
109 if (daylight == 0
110 && strcmp (tzname[0], "BB1") == 0 && strcmp (tzname[1], "BB1") == 0)
111 puts (", OK");
112 else
114 result = 1;
115 puts (", FAIL");
118 return result;
121 #define TEST_FUNCTION do_test ()
122 #include "../test-skeleton.c"