This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Tests for tzname bug
- To: libc-hacker@cygnus.com
- Subject: Tests for tzname bug
- From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
- Date: Fri, 3 Jul 1998 10:19:58 +0200 (CEST)
Hi,
I've added some tests to libc for the broken setting of tzname as
reported a few hours ago. I hope that the tests are ok and help
fixing the bug.
Andreas
1998-07-03 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* timezone/tst-timezone.c: Add tests for tzname variable.
--- timezone/tst-timezone.c.~1~ Thu May 14 21:14:34 1998
+++ timezone/tst-timezone.c Fri Jul 3 10:18:25 1998
@@ -20,6 +20,7 @@
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
int failed = 0;
@@ -29,14 +30,16 @@
const char *name;
int daylight;
int timezone;
+ const char *tzname[2];
};
static const struct test_times tests[] =
{
- { "Europe/Berlin", 1, -3600 },
- { "Universal", 0, 0 },
- { "Australia/Melbourne", 1, -36000 },
- { "America/Sao_Paulo", 1, 10800 },
+ { "Europe/Berlin", 1, -3600, "CET", "CEST" },
+ { "Universal", 0, 0, {"UTC", "UTC" }},
+ { "Australia/Melbourne", 1, -36000, { "EST", "EST" }},
+ { "America/Sao_Paulo", 1, 10800, {"EST", "EDT" }},
+ { "America/Los_Angeles", 1, 28800, {"PST", "PDT" }},
{ NULL, 0, 0 }
};
@@ -52,8 +55,10 @@
void
-check_tzvars (const char *name, int dayl, int timez)
+check_tzvars (const char *name, int dayl, int timez, const char *const tznam[])
{
+ int i;
+
if (daylight != dayl)
{
printf ("Timezone: %s, daylight is: %d but should be: %d\n",
@@ -66,6 +71,15 @@
name, timezone, timez);
++failed;
}
+ for (i = 0; i <= 1; ++i)
+ {
+ if (strcmp (tzname[i], tznam[i]) != 0)
+ {
+ printf ("Timezone: %s, tzname[%d] is: %s but should be: %s\n",
+ name, i, tzname[i], tznam[i]);
+ ++failed;
+ }
+ }
}
@@ -92,12 +106,12 @@
}
tzset ();
print_tzvars ();
- check_tzvars (pt->name, pt->daylight, pt->timezone);
+ check_tzvars (pt->name, pt->daylight, pt->timezone, pt->tzname);
/* calling localtime shouldn't make a difference */
localtime (&t);
print_tzvars ();
- check_tzvars (pt->name, pt->daylight, pt->timezone);
+ check_tzvars (pt->name, pt->daylight, pt->timezone, pt->tzname);
}
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@alma.student.uni-kl.de