diff options
author | Roland McGrath <roland@gnu.org> | 2004-12-02 22:16:35 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2004-12-02 22:16:35 +0000 |
commit | b78ad5fd49ddfbe2e74aa6f00afbe992399c0efe (patch) | |
tree | ad9de354dd4974b1b62515e1e4458e8e642eaea8 /time/tst-mktime3.c | |
parent | 469dcb0d463740a3c15ef231ea110bf01bafbaa3 (diff) | |
download | glibc-b78ad5fd49ddfbe2e74aa6f00afbe992399c0efe.tar glibc-b78ad5fd49ddfbe2e74aa6f00afbe992399c0efe.tar.gz glibc-b78ad5fd49ddfbe2e74aa6f00afbe992399c0efe.tar.bz2 glibc-b78ad5fd49ddfbe2e74aa6f00afbe992399c0efe.zip |
* time/mktime.c (__mktime_internal): If SEC_REQUESTED != SEC,
convert T2, not T.
* time/Makefile (tests): Add tst-mktime3.
* time/tst-mktime3.c: New test.
2004-12-01 Jakub Jelinek <jakub@redhat.com>
Diffstat (limited to 'time/tst-mktime3.c')
-rw-r--r-- | time/tst-mktime3.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/time/tst-mktime3.c b/time/tst-mktime3.c new file mode 100644 index 0000000000..60d0e0b32c --- /dev/null +++ b/time/tst-mktime3.c @@ -0,0 +1,50 @@ +/* Test program for mktime bugs with out-of-range tm_sec values. */ + +#include <stdlib.h> +#include <stdio.h> +#include <time.h> + +struct tm tests[] = +{ + { .tm_sec = -1, .tm_mday = 1, .tm_year = 104 }, + { .tm_sec = 65, .tm_min = 59, .tm_hour = 23, .tm_mday = 31, + .tm_mon = 11, .tm_year = 101 } +}; +struct tm expected[] = +{ + { .tm_sec = 59, .tm_min = 59, .tm_hour = 23, .tm_mday = 31, + .tm_mon = 11, .tm_year = 103, .tm_wday = 3, .tm_yday = 364 }, + { .tm_sec = 5, .tm_mday = 1, .tm_year = 102, .tm_wday = 2 } +}; + +int +main (void) +{ + setenv ("TZ", "UTC", 1); + int i; + for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i) + { + if (mktime (&tests[i]) < 0) + { + printf ("mktime %d failed\n", i); + return 1; + } +#define CHECK(name) \ + if (tests[i].name != expected[i].name) \ + { \ + printf ("test %d " #name " got %d expected %d\n", \ + i, tests[i].name, expected[i].name); \ + return 1; \ + } + CHECK (tm_sec) + CHECK (tm_min) + CHECK (tm_hour) + CHECK (tm_mday) + CHECK (tm_mon) + CHECK (tm_year) + CHECK (tm_wday) + CHECK (tm_yday) + CHECK (tm_isdst) + } + return 0; +} |