diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-28 20:29:21 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-28 20:31:55 +0200 |
commit | 99ef2719fb3d703fe38c4113cd7f5adec516dd3a (patch) | |
tree | 2c1f77cb41b60ccbf8faa77a3640491a3546b546 /test/time | |
parent | 543308f6c46cf2edf8a524bc9c631e472570fe72 (diff) |
test: remove test suite
The test suite is now a developed in a separate git repository.
See here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng-test.git
The test suite should be just like every other software compiled
with the cross-toolchain. In the past strange problems where found
when the test suite got build in the toolchain creation step.
Diffstat (limited to 'test/time')
-rw-r--r-- | test/time/Makefile | 8 | ||||
-rw-r--r-- | test/time/Makefile.in | 22 | ||||
-rw-r--r-- | test/time/bug-asctime.c | 40 | ||||
-rw-r--r-- | test/time/bug-asctime_r.c | 37 | ||||
-rw-r--r-- | test/time/clocktest.c | 36 | ||||
-rw-r--r-- | test/time/test_time.c | 115 | ||||
-rw-r--r-- | test/time/time.c | 76 | ||||
-rw-r--r-- | test/time/tst-ctime.c | 44 | ||||
-rw-r--r-- | test/time/tst-ftime_l.c | 136 | ||||
-rw-r--r-- | test/time/tst-futimens1.c | 105 | ||||
-rw-r--r-- | test/time/tst-mktime.c | 70 | ||||
-rw-r--r-- | test/time/tst-mktime2.c | 141 | ||||
-rw-r--r-- | test/time/tst-mktime3.c | 50 | ||||
-rw-r--r-- | test/time/tst-posixtz.c | 88 | ||||
-rw-r--r-- | test/time/tst-strftime.c | 111 | ||||
-rw-r--r-- | test/time/tst-strptime.c | 192 | ||||
-rw-r--r-- | test/time/tst-strptime2.c | 59 | ||||
-rw-r--r-- | test/time/tst-timerfd.c | 71 | ||||
-rw-r--r-- | test/time/tst-timezone.c | 169 | ||||
-rw-r--r-- | test/time/tst_wcsftime.c | 65 |
20 files changed, 0 insertions, 1635 deletions
diff --git a/test/time/Makefile b/test/time/Makefile deleted file mode 100644 index fed45697b..000000000 --- a/test/time/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# uClibc time tests -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -top_builddir=../../ -top_srcdir=../../ -include ../Rules.mak --include Makefile.in -include ../Test.mak diff --git a/test/time/Makefile.in b/test/time/Makefile.in deleted file mode 100644 index 4eeb74161..000000000 --- a/test/time/Makefile.in +++ /dev/null @@ -1,22 +0,0 @@ -# uClibc time tests -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -TESTS_DISABLED := bug-asctime bug-asctime_r time tst-mktime2 tst-posixtz \ - tst-strftime tst-strptime tst-timezone - -ifeq ($(TARGET_avr32),y) -TESTS_DISABLED += tst-timerfd -endif - -ifneq ($(UCLIBC_HAS_XLOCALE),y) -TESTS_DISABLED += tst-ftime_l -endif - -ifneq ($(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_LOCALE),yy) -TESTS_DISABLED += tst_wcsftime -endif - -CFLAGS_tst-strptime2 := -std=c99 - -DODIFF_futimens1 := 1 -DODIFF_tst_wcsftime := 1 diff --git a/test/time/bug-asctime.c b/test/time/bug-asctime.c deleted file mode 100644 index 149e4e0a2..000000000 --- a/test/time/bug-asctime.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Note: we disable this on uClibc because we dont bother - * verifying if the year is sane ... we just return ???? - * for the year value ... - */ - -#include <errno.h> -#include <limits.h> -#include <stdio.h> -#include <time.h> - - -static int -do_test (void) -{ - int result = 0; - time_t t = time (NULL); - struct tm *tp = localtime (&t); - tp->tm_year = INT_MAX; - errno = 0; - char *s = asctime (tp); - if (s != NULL || errno != EOVERFLOW) - { - printf ("asctime did not fail correctly: s=%p, wanted %p; errno=%i, wanted %i\n", - s, NULL, errno, EOVERFLOW); - result = 1; - } - char buf[1000]; - errno = 0; - s = asctime_r (tp, buf); - if (s != NULL || errno != EOVERFLOW) - { - printf ("asctime_r did not fail correctly: s=%p, wanted %p; errno=%i, wanted %i\n", - s, NULL, errno, EOVERFLOW); - result = 1; - } - return result; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/test/time/bug-asctime_r.c b/test/time/bug-asctime_r.c deleted file mode 100644 index 1fcc4659f..000000000 --- a/test/time/bug-asctime_r.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Note: we disable this on uClibc because we dont bother - * verifying if the year is sane ... we just return ???? - * for the year value ... - */ - -#include <errno.h> -#include <limits.h> -#include <stdio.h> -#include <time.h> - - -static int -do_test (void) -{ - int result = 0; - time_t t = time (NULL); - struct tm *tp = localtime (&t); - tp->tm_year = 10000 - 1900; - char buf[1000]; - errno = 0; - buf[26] = '\xff'; - char *s = asctime_r (tp, buf); - if (s != NULL || errno != EOVERFLOW) - { - puts ("asctime_r did not fail correctly"); - result = 1; - } - if (buf[26] != '\xff') - { - puts ("asctime_r overwrote 27th byte in buffer"); - result = 1; - } - return result; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/test/time/clocktest.c b/test/time/clocktest.c deleted file mode 100644 index a5b2c09e7..000000000 --- a/test/time/clocktest.c +++ /dev/null @@ -1,36 +0,0 @@ -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <unistd.h> - -volatile int gotit = 0; - -static void -alarm_handler (int signum) -{ - gotit = 1; -} - - -int -main (int argc, char ** argv) -{ - clock_t start, stop; - - if (signal(SIGALRM, alarm_handler) == SIG_ERR) - { - perror ("signal"); - exit (1); - } - alarm(1); - start = clock (); - while (!gotit); - stop = clock (); - - printf ("%ld clock ticks per second (start=%ld,stop=%ld)\n", - stop - start, start, stop); - printf ("CLOCKS_PER_SEC=%ld, sysconf(_SC_CLK_TCK)=%ld\n", - CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK)); - return 0; -} diff --git a/test/time/test_time.c b/test/time/test_time.c deleted file mode 100644 index ab2931895..000000000 --- a/test/time/test_time.c +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 1991, 1992, 1994, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <stdio.h> -#include <stdlib.h> -#include <time.h> - - -int -main (int argc, char **argv) -{ - time_t t; - register struct tm *tp; - struct tm tbuf; - int lose = 0; - - --argc; - ++argv; - - do - { - char buf[BUFSIZ]; - if (argc > 0) - { - static char tzenvbuf[BUFSIZ]; - sprintf(tzenvbuf, "TZ=%s", *argv); - if (putenv(tzenvbuf)) - { - puts("putenv failed."); - lose = 1; - } - else - puts (tzenvbuf); - } - tzset(); - tbuf.tm_year = 72; - tbuf.tm_mon = 0; - tbuf.tm_mday = 31; - tbuf.tm_hour = 6; - tbuf.tm_min = 14; - tbuf.tm_sec = 50; - tbuf.tm_isdst = -1; - doit:; - t = mktime(&tbuf); - if (t == (time_t) -1) - { - puts("mktime() failed?"); - lose = 1; - } - tp = localtime(&t); - if (tp == NULL) - { - puts("localtime() failed."); - lose = 1; - } - else if (strftime(buf, sizeof(buf), "%a %b %d %X %Z %Y", tp) == 0) - { - puts("strftime() failed."); - lose = 1; - } - else - puts(buf); - if (tbuf.tm_year == 101) - { - tbuf.tm_year = 97; - tbuf.tm_mon = 0; - goto doit; - } - ++argv; - } while (--argc > 0); - - { -#define SIZE 256 - char buffer[SIZE]; - time_t curtime; - struct tm *loctime; - - curtime = time (NULL); - - loctime = localtime (&curtime); - - fputs (asctime (loctime), stdout); - - strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime); - fputs (buffer, stdout); - strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime); - fputs (buffer, stdout); - - loctime->tm_year = 72; - loctime->tm_mon = 8; - loctime->tm_mday = 12; - loctime->tm_hour = 20; - loctime->tm_min = 49; - loctime->tm_sec = 05; - curtime = mktime (loctime); - strftime (buffer, SIZE, "%D %T was %w the %jth.\n", loctime); - fputs (buffer, stdout); - } - - return (lose ? EXIT_FAILURE : EXIT_SUCCESS); -} diff --git a/test/time/time.c b/test/time/time.c deleted file mode 100644 index a4d68d50f..000000000 --- a/test/time/time.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -/* We use this instead of memcmp because some broken C libraries - * add additional nonstandard fields to struct tm... */ - -int tm_cmp(struct tm tm1, struct tm tm2) -{ - return tm1.tm_sec != tm2.tm_sec || - tm1.tm_min != tm2.tm_min || - tm1.tm_hour != tm2.tm_hour || - tm1.tm_mday != tm2.tm_mday || - tm1.tm_mon != tm2.tm_mon || - tm1.tm_year != tm2.tm_year || - tm1.tm_wday != tm2.tm_wday || - tm1.tm_yday != tm2.tm_yday || - tm1.tm_isdst!= tm2.tm_isdst; -} - -char *tm_str(struct tm tm) -{ - static int i; - static char b[4][64]; - i = (i+1)%4; - snprintf(b[i], sizeof b[i], - "s=%.2d m=%.2d h=%.2d mday=%.2d mon=%.2d year=%.4d wday=%d yday=%d isdst=%d", - tm.tm_sec, tm.tm_min, tm.tm_hour, - tm.tm_mday, tm.tm_mon, tm.tm_year, - tm.tm_wday, tm.tm_yday, tm.tm_isdst); - return b[i]; -} - -#define TM(ss,mm,hh,md,mo,yr,wd,yd,dst) (struct tm){ \ - .tm_sec = ss, .tm_min = mm, .tm_hour = hh, \ - .tm_mday = md, .tm_mon = mo, .tm_year = yr, \ - .tm_wday = wd, .tm_yday = yd, .tm_isdst = dst } - -#define TM_EPOCH TM(0,0,0,1,0,70,4,0,0) -#define TM_Y2038_1S TM(7,14,3,19,0,138,2,18,0) -#define TM_Y2038 TM(8,14,3,19,0,138,2,18,0) - -#define TEST_TM(r,x,m) (!tm_cmp((r),(x)) || \ -(printf(__FILE__ ":%d: %s failed:\n\tresult: %s\n\texpect: %s\n", __LINE__, \ -m, tm_str((r)), tm_str((x))), err++, 0) ) - -#define TEST(r, f, x, m) ( \ -((r) = (f)) == (x) || \ -(printf(__FILE__ ":%d: %s failed (" m ")\n", __LINE__, #f, r, x), err++, 0) ) - -int main(void) -{ - struct tm tm, *tm_p; - time_t t; - int err=0; - - putenv("TZ=GMT"); - tzset(); - - t=0; tm_p = gmtime(&t); - TEST_TM(*tm_p, TM_EPOCH, "gmtime(0)"); - - tm = TM_Y2038_1S; - t = mktime(&tm); - tm = *(gmtime(&t)); - TEST_TM(*tm_p, TM_Y2038_1S, "mktime/gmtime(Y2038-1)"); - - tm = TM_Y2038; - t = mktime(&tm); - tm = *(gmtime(&t)); - TEST_TM(*tm_p, TM_Y2038, "mktime/gmtime(Y2038)"); - - /* FIXME: set a TZ var and check DST boundary conditions */ - - return err; -} diff --git a/test/time/tst-ctime.c b/test/time/tst-ctime.c deleted file mode 100644 index 91d827aa2..000000000 --- a/test/time/tst-ctime.c +++ /dev/null @@ -1,44 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* testcase for ctime(3) with large time - * Copyright (C) 2010 David A Ramos <daramos@gustav.stanford.edu> - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#define MAX_POSITIVE(type) (~0 & ~((type) 1 << (sizeof(type)*8 - 1))) - -int do_test(int argc, char **argv) { - char *correct = 0, *s; - int status; - - /* need a very high positive number (e.g., max - 1024) */ - time_t test = MAX_POSITIVE(time_t) - 1024; - - s = asctime(localtime(&test)); - - if (s) { - // copy static buffer to heap - correct = malloc(strlen(s)+1); - strcpy(correct, s); - } - - s = ctime(&test); - - printf("ANSI:\t%suClibc:\t%s", correct, s); - - if (s != correct && strcmp(correct, s)) - status = EXIT_FAILURE; - else - status = EXIT_SUCCESS; - - if (correct) - free(correct); - - return status; -} - -#include <test-skeleton.c> diff --git a/test/time/tst-ftime_l.c b/test/time/tst-ftime_l.c deleted file mode 100644 index 95017f1f8..000000000 --- a/test/time/tst-ftime_l.c +++ /dev/null @@ -1,136 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <features.h> -#ifdef __UCLIBC_HAS_XLOCALE__ -#include <locale.h> -#include <wchar.h> - - -int -main (void) -{ - locale_t l; - locale_t old; - struct tm tm; - char buf[1000]; - wchar_t wbuf[1000]; - int result = 0; - size_t n; - - l = newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL); - if (l == NULL) - { - puts ("newlocale failed"); - exit (1); - } - - memset (&tm, '\0', sizeof (tm)); - - tm.tm_year = 102; - tm.tm_mon = 2; - tm.tm_mday = 1; - - if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0) - { - puts ("initial strftime failed"); - exit (1); - } - if (strcmp (buf, " 1 MARCH 2002") != 0) - { - printf ("initial strftime: expected \"%s\", got \"%s\"\n", - " 1 MARCH 2002", buf); - result = 1; - } - else - printf ("got \"%s\"\n", buf); - - /* Now using the extended locale model. */ - if (strftime_l (buf, sizeof (buf), "%e %^B %Y", &tm, l) == 0) - { - puts ("strftime_l failed"); - result = 1; - } - else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0) - { - printf ("strftime_l: expected \"%s\", got \"%s\"\n", - " 1 M\xc4RZ 2002", buf); - result = 1; - } - else - { - setlocale (LC_ALL, "de_DE.ISO-8859-1"); - printf ("got \"%s\"\n", buf); - setlocale (LC_ALL, "C"); - } - - /* And the wide character version. */ - if (wcsftime_l (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), L"%e %^B %Y", &tm, l) - == 0) - { - puts ("wcsftime_l failed"); - result = 1; - } - else if (wcscmp (wbuf, L" 1 M\x00c4RZ 2002") != 0) - { - printf ("wcsftime_l: expected \"%ls\", got \"%ls\"\n", - L" 1 M\x00c4RZ 2002", wbuf); - result = 1; - } - else - { - setlocale (LC_ALL, "de_DE.ISO-8859-1"); - printf ("got \"%ls\"\n", wbuf); - setlocale (LC_ALL, "C"); - } - - old = uselocale (l); - - n = strftime (buf, sizeof (buf), "%e %^B %Y", &tm); - - /* Switch back. */ - (void) uselocale (old); - - if (n == 0) - { - puts ("strftime after first uselocale failed"); - result = 1; - } - else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0) - { - printf ("strftime in non-C locale: expected \"%s\", got \"%s\"\n", - " 1 M\xc4RZ 2002", buf); - result = 1; - } - else - { - setlocale (LC_ALL, "de_DE.ISO-8859-1"); - printf ("got \"%s\"\n", buf); - setlocale (LC_ALL, "C"); - } - - if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0) - { - puts ("strftime after second uselocale failed"); - result = 1; - } - else if (strcmp (buf, " 1 MARCH 2002") != 0) - { - printf ("initial strftime: expected \"%s\", got \"%s\"\n", - " 1 MARCH 2002", buf); - result = 1; - } - else - printf ("got \"%s\"\n", buf); - - return result; -} - -#else -int main(void) -{ - puts("Test requires WCHAR support; skipping"); - return 0; -} -#endif diff --git a/test/time/tst-futimens1.c b/test/time/tst-futimens1.c deleted file mode 100644 index 2c25bd4de..000000000 --- a/test/time/tst-futimens1.c +++ /dev/null @@ -1,105 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* testcase for futimens(2) - * Copyright (C) 2009 Bernhard Reutner-Fischer <uClibc@uClibc.org> - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - */ -#include <sys/types.h> -#include <sys/stat.h> -#include <errno.h> -#include <stdlib.h> -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> - -struct -{ - char *name; /* name of file to open */ - int flags; /* flags for file descriptor */ - const struct timespec ts[2]; - int err; /* expected errno */ -} tests [] = -{ - {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,0}}, 0}, - {"futimens.tst", (O_CREAT|O_TRUNC), {{99,0},{0,0}}, 0}, - {"futimens.tst", (O_CREAT|O_TRUNC), {{0,99},{0,0}}, 0}, - {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{99,0}}, 0}, - {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,99}}, 0}, - {"futimens.tst", (O_CREAT|O_TRUNC), {{11,2},{3,4}}, 0}, -}; -int do_test(int argc, char **argv) { - char *name; - int i, errors; - errors = argc - argc + 0; - unsigned has_stat_nsec = 0; - { - struct stat probe; - /* Let's attempt an educated guess if this filesystem supports - * nanosecond mtime. */ - if ((!stat(".", &probe)) && probe.st_mtim.tv_nsec) - has_stat_nsec = 1; - else if ((!stat(argv[0], &probe)) && probe.st_mtim.tv_nsec) - has_stat_nsec = 1; - } - for (i=0; i < (int) (sizeof(tests)/sizeof(tests[0])); ++i) { - int err, fd; - struct stat sb; - name = tests[i].name; - if (*name != '.') - unlink(name); - fd = open(name, tests[i].flags, 0660); - if (fd < 0) - abort(); - errno = 0; - err = futimens(fd, tests[i].ts); - if ((errno && !err) || (!errno && err)) { - err = errno; - printf("FAILED test %d (errno and return value disagree)\n", i); - ++errors; - } else - err = errno; - if (err != tests[i].err) { - printf("FAILED test %d (expected errno %d, got %d)\n", - i, tests[i].err, err); - ++errors; - continue; - } - if (stat(name, &sb) < 0) { - printf("FAILED test %d (verification)\n", i); - ++errors; - continue; - } else { - unsigned wrong = tests[i].ts[0].tv_sec != sb.st_atim.tv_sec || - tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec || - tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec || - tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec; - if (wrong) { - if (tests[i].ts[0].tv_sec != sb.st_atim.tv_sec) { - printf("FAILED test %d (access time, sec: expected %ld, got %ld)\n", - i, tests[i].ts[0].tv_sec, sb.st_atim.tv_sec); - ++errors; - } - if (tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec) { - printf("FAILED test %d (access time, nsec: expected %ld, got %ld)\n", - i, tests[i].ts[0].tv_nsec, sb.st_atim.tv_nsec); - errors += has_stat_nsec; - } - - if (tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec) { - printf("FAILED test %d (modification time, sec: expected %ld, got %ld)\n", - i, tests[i].ts[1].tv_sec, sb.st_mtim.tv_sec); - ++errors; - } - if (tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec) { - printf("FAILED test %d (modification time, nsec: expected %ld, got %ld)\n", - i, tests[i].ts[1].tv_nsec, sb.st_mtim.tv_nsec); - errors += has_stat_nsec; - } - } - } - } - if (*name != '.') - unlink(name); - printf("%d errors.\n", errors); - return (!errors) ? EXIT_SUCCESS : EXIT_FAILURE; -} -#include <test-skeleton.c> diff --git a/test/time/tst-mktime.c b/test/time/tst-mktime.c deleted file mode 100644 index 416a85616..000000000 --- a/test/time/tst-mktime.c +++ /dev/null @@ -1,70 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <time.h> - -int -main (void) -{ - struct tm time_str, *tm; - time_t t; - char daybuf[20]; - int result; - - time_str.tm_year = 2001 - 1900; - time_str.tm_mon = 7 - 1; - time_str.tm_mday = 4; - time_str.tm_hour = 0; - time_str.tm_min = 0; - time_str.tm_sec = 1; - time_str.tm_isdst = -1; - - if (mktime (&time_str) == -1) - { - (void) puts ("-unknown-"); - result = 1; - } - else - { - (void) strftime (daybuf, sizeof (daybuf), "%A", &time_str); - (void) puts (daybuf); - result = strcmp (daybuf, "Wednesday") != 0; - } - - setenv ("TZ", "EST+5", 1); -#define EVENING69 1 * 60 * 60 + 2 * 60 + 29 - t = EVENING69; - tm = localtime (&t); - if (tm == NULL) - { - (void) puts ("localtime returned NULL"); - result = 1; - } - else - { - time_str = *tm; - t = mktime (&time_str); - if (t != EVENING69) - { - printf ("mktime returned %ld, expected %d\n", - (long) t, EVENING69); - result = 1; - } - else - (void) puts ("Dec 31 1969 EST test passed"); - - setenv ("TZ", "CET-1", 1); - t = mktime (&time_str); -#define EVENING69_CET (EVENING69 - (5 - -1) * 60 * 60) - if (t != EVENING69_CET) - { - printf ("mktime returned %ld, expected %ld\n", - (long) t, (long) EVENING69_CET); - result = 1; - } - else - (void) puts ("Dec 31 1969 CET test passed"); - } - - return result; -} diff --git a/test/time/tst-mktime2.c b/test/time/tst-mktime2.c deleted file mode 100644 index 6279218cb..000000000 --- a/test/time/tst-mktime2.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Test program from Paul Eggert and Tony Leneis. */ -#include <time.h> -#include <stdlib.h> -#include <unistd.h> - -static time_t time_t_max; -static time_t time_t_min; - -/* Values we'll use to set the TZ environment variable. */ -static const char *tz_strings[] = - { - (const char *) 0, "GMT0", "JST-9", - "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" - }; -#define N_STRINGS ((int) (sizeof (tz_strings) / sizeof (tz_strings[0]))) - -/* Fail if mktime fails to convert a date in the spring-forward gap. - Based on a problem report from Andreas Jaeger. */ -static void -spring_forward_gap (void) -{ - /* glibc (up to about 1998-10-07) failed this test. */ - struct tm tm; - - /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" - instead of "TZ=America/Vancouver" in order to detect the bug even - on systems that don't support the Olson extension, or don't have the - full zoneinfo tables installed. */ - setenv ("TZ", "PST8PDT,M4.1.0,M10.5.0", 1); - - tm.tm_year = 98; - tm.tm_mon = 3; - tm.tm_mday = 5; - tm.tm_hour = 2; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; - if (mktime (&tm) == (time_t)-1) - exit (1); -} - -static void -mktime_test1 (time_t now) -{ - struct tm *lt = localtime (&now); - if (lt && mktime (lt) != now) - exit (2); -} - -static void -mktime_test (time_t now) -{ - mktime_test1 (now); - mktime_test1 ((time_t) (time_t_max - now)); - mktime_test1 ((time_t) (time_t_min + now)); -} - -static void -irix_6_4_bug (void) -{ - /* Based on code from Ariel Faigon. */ - struct tm tm; - tm.tm_year = 96; - tm.tm_mon = 3; - tm.tm_mday = 0; - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; - mktime (&tm); - if (tm.tm_mon != 2 || tm.tm_mday != 31) - exit (3); -} - -static void -bigtime_test (int j) -{ - struct tm tm; - time_t now; - tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; - tm.tm_isdst = -1; - now = mktime (&tm); - if (now != (time_t) -1) - { - struct tm *lt = localtime (&now); - if (! (lt - && lt->tm_year == tm.tm_year - && lt->tm_mon == tm.tm_mon - && lt->tm_mday == tm.tm_mday - && lt->tm_hour == tm.tm_hour - && lt->tm_min == tm.tm_min - && lt->tm_sec == tm.tm_sec - && lt->tm_yday == tm.tm_yday - && lt->tm_wday == tm.tm_wday - && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) - == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) - exit (4); - } -} - -static int -do_test (void) -{ - time_t t, delta; - int i, j; - - setenv ("TZ", "America/Sao_Paulo", 1); - /* This test makes some buggy mktime implementations loop. - Give up after 60 seconds; a mktime slower than that - isn't worth using anyway. */ - alarm (60); - - for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) - continue; - time_t_max--; - if ((time_t) -1 < 0) - for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2) - continue; - delta = time_t_max / 997; /* a suitable prime number */ - for (i = 0; i < N_STRINGS; i++) - { - if (tz_strings[i]) - setenv ("TZ", tz_strings[i], 1); - - for (t = 0; t <= time_t_max - delta; t += delta) - mktime_test (t); - mktime_test ((time_t) 1); - mktime_test ((time_t) (60 * 60)); - mktime_test ((time_t) (60 * 60 * 24)); - - for (j = 1; 0 < j; j *= 2) - bigtime_test (j); - bigtime_test (j - 1); - } - irix_6_4_bug (); - spring_forward_gap (); - return 0; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/test/time/tst-mktime3.c b/test/time/tst-mktime3.c deleted file mode 100644 index 60d0e0b32..000000000 --- a/test/time/tst-mktime3.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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; -} diff --git a/test/time/tst-posixtz.c b/test/time/tst-posixtz.c deleted file mode 100644 index ccba63e5b..000000000 --- a/test/time/tst-posixtz.c +++ /dev/null @@ -1,88 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -struct -{ - time_t when; - const char *tz; - const char *result; -} tests[] = -{ - { 909312849L, "AEST-10AEDST-11,M10.5.0,M3.5.0", - "1998/10/25 21:54:09 dst=1 zone=AEDST" }, - { 924864849L, "AEST-10AEDST-11,M10.5.0,M3.5.0", - "1999/04/23 20:54:09 dst=0 zone=AEST" }, - { 919973892L, "AEST-10AEDST-11,M10.5.0,M3.5.0", - "1999/02/26 07:18:12 dst=1 zone=AEDST" }, - { 909312849L, "EST+5EDT,M4.1.0/2,M10.5.0/2", - "1998/10/25 05:54:09 dst=0 zone=EST" }, - { 924864849L, "EST+5EDT,M4.1.0/2,M10.5.0/2", - "1999/04/23 06:54:09 dst=1 zone=EDT" }, - { 919973892L, "EST+5EDT,M4.1.0/2,M10.5.0/2", - "1999/02/25 15:18:12 dst=0 zone=EST" }, -}; - -int -main (void) -{ - int result = 0; - size_t cnt; - - for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt) - { - char buf[100]; - struct tm *tmp; - - printf ("TZ = \"%s\", time = %ld => ", tests[cnt].tz, tests[cnt].when); - fflush (stdout); - - setenv ("TZ", tests[cnt].tz, 1); - - tmp = localtime (&tests[cnt].when); - - snprintf (buf, sizeof (buf), - "%04d/%02d/%02d %02d:%02d:%02d dst=%d zone=%s", - tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, - tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tmp->tm_isdst, - tzname[tmp->tm_isdst ? 1 : 0]); - - fputs (buf, stdout); - - if (strcmp (buf, tests[cnt].result) == 0) - puts (", OK"); - else - { - result = 1; - puts (", FAIL"); - } - } - - setenv ("TZ", "Universal", 1); - localtime (&tests[0].when); - printf ("TZ = \"Universal\" daylight %d tzname = { \"%s\", \"%s\" }", - daylight, tzname[0], tzname[1]); - if (! daylight) - puts (", OK"); - else - { - result = 1; - puts (", FAIL"); - } - - setenv ("TZ", "AEST-10AEDST-11,M10.5.0,M3.5.0", 1); - tzset (); - printf ("TZ = \"AEST-10AEDST-11,M10.5.0,M3.5.0\" daylight %d" - " tzname = { \"%s\", \"%s\" }", daylight, tzname[0], tzname[1]); - if (daylight - && str |