summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-01-20 16:47:57 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-01-20 16:47:57 +0000
commitb55ff22bce1628dc5520f84e175a50fcaf826fd3 (patch)
tree4eaf98327dc4b95dd51cdbc306c25ff8c503c1ca /regress
parent19c8deb79660d1c9aea5bab2a665a726e7e48594 (diff)
Add strptime regress from NetBSD; OK miod@ after un-peeing.
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libc/Makefile4
-rw-r--r--regress/lib/libc/time/Makefile5
-rw-r--r--regress/lib/libc/time/strptime/Makefile12
-rw-r--r--regress/lib/libc/time/strptime/expected346
-rw-r--r--regress/lib/libc/time/strptime/main.c117
-rw-r--r--regress/lib/libc/time/strptime/tests267
6 files changed, 749 insertions, 2 deletions
diff --git a/regress/lib/libc/Makefile b/regress/lib/libc/Makefile
index 1861062bbed..1b655bcbed1 100644
--- a/regress/lib/libc/Makefile
+++ b/regress/lib/libc/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.11 2003/05/15 04:23:49 deraadt Exp $
+# $OpenBSD: Makefile,v 1.12 2004/01/20 16:47:55 millert Exp $
SUBDIR+= alloca
SUBDIR+= _setjmp db getaddrinfo regex setjmp sigsetjmp malloc sigreturn popen
-SUBDIR+= longjmp atexit sprintf
+SUBDIR+= longjmp atexit sprintf time
.if (${MACHINE_ARCH} != "vax")
SUBDIR+= ieeefp
.endif
diff --git a/regress/lib/libc/time/Makefile b/regress/lib/libc/time/Makefile
new file mode 100644
index 00000000000..28b55560270
--- /dev/null
+++ b/regress/lib/libc/time/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2004/01/20 16:47:55 millert Exp $
+
+SUBDIR+=strptime
+
+.include <bsd.subdir.mk>
diff --git a/regress/lib/libc/time/strptime/Makefile b/regress/lib/libc/time/strptime/Makefile
new file mode 100644
index 00000000000..9a288e3c0ee
--- /dev/null
+++ b/regress/lib/libc/time/strptime/Makefile
@@ -0,0 +1,12 @@
+# $OpenBSD: Makefile,v 1.1 2004/01/20 16:47:55 millert Exp $
+
+PROG= strptime_test
+SRCS= main.c
+CLEANFILES+= got
+
+REGRESS_TARGETS=do-reg
+do-reg:
+ ./${PROG} < ${.CURDIR}/tests > got
+ diff ${.CURDIR}/expected got
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libc/time/strptime/expected b/regress/lib/libc/time/strptime/expected
new file mode 100644
index 00000000000..d038d319afa
--- /dev/null
+++ b/regress/lib/libc/time/strptime/expected
@@ -0,0 +1,346 @@
+--- ctime --- 1
+succeeded
+46 27 23 20 0 98 2 -1
+
+--- ctime --- 2
+succeeded
+46 27 23 20 0 98 2 -1
+
+--- ctime --- 3
+succeeded
+46 27 23 20 0 98 2 -1
+
+--- %a --- 1
+succeeded
+-1 -1 -1 -1 -1 -1 0 -1
+
+--- %a --- 2
+succeeded
+-1 -1 -1 -1 -1 -1 0 -1
+
+--- %a --- 3
+succeeded
+-1 -1 -1 -1 -1 -1 1 -1
+
+--- %a --- 4
+succeeded
+-1 -1 -1 -1 -1 -1 1 -1
+
+--- %a --- 5
+succeeded
+-1 -1 -1 -1 -1 -1 2 -1
+
+--- %a --- 6
+succeeded
+-1 -1 -1 -1 -1 -1 2 -1
+
+--- %a --- 7
+succeeded
+-1 -1 -1 -1 -1 -1 3 -1
+
+--- %a --- 8
+succeeded
+-1 -1 -1 -1 -1 -1 3 -1
+
+--- %a --- 9
+succeeded
+-1 -1 -1 -1 -1 -1 4 -1
+
+--- %a --- 10
+succeeded
+-1 -1 -1 -1 -1 -1 4 -1
+
+--- %a --- 11
+succeeded
+-1 -1 -1 -1 -1 -1 5 -1
+
+--- %a --- 12
+succeeded
+-1 -1 -1 -1 -1 -1 5 -1
+
+--- %a --- 13
+succeeded
+-1 -1 -1 -1 -1 -1 6 -1
+
+--- %a --- 14
+succeeded
+-1 -1 -1 -1 -1 -1 6 -1
+
+--- %a --- 15
+succeeded
+-1 -1 -1 -1 -1 -1 6 -1
+urn
+
+--- %a --- 16
+failed
+--- %A --- 1
+succeeded
+-1 -1 -1 -1 -1 -1 0 -1
+
+--- %A --- 2
+succeeded
+-1 -1 -1 -1 -1 -1 0 -1
+
+--- %A --- 3
+succeeded
+-1 -1 -1 -1 -1 -1 1 -1
+
+--- %A --- 4
+succeeded
+-1 -1 -1 -1 -1 -1 1 -1
+
+--- %A --- 5
+succeeded
+-1 -1 -1 -1 -1 -1 2 -1
+
+--- %A --- 6
+succeeded
+-1 -1 -1 -1 -1 -1 2 -1
+
+--- %A --- 7
+succeeded
+-1 -1 -1 -1 -1 -1 3 -1
+
+--- %A --- 8
+succeeded
+-1 -1 -1 -1 -1 -1 3 -1
+
+--- %A --- 9
+succeeded
+-1 -1 -1 -1 -1 -1 4 -1
+
+--- %A --- 10
+succeeded
+-1 -1 -1 -1 -1 -1 4 -1
+
+--- %A --- 11
+succeeded
+-1 -1 -1 -1 -1 -1 5 -1
+
+--- %A --- 12
+succeeded
+-1 -1 -1 -1 -1 -1 5 -1
+
+--- %A --- 13
+succeeded
+-1 -1 -1 -1 -1 -1 6 -1
+
+--- %A --- 14
+succeeded
+-1 -1 -1 -1 -1 -1 6 -1
+
+--- %A --- 15
+succeeded
+-1 -1 -1 -1 -1 -1 6 -1
+urn
+
+--- %A --- 16
+failed
+--- %b --- 1
+succeeded
+-1 -1 -1 -1 0 -1 -1 -1
+
+--- %b --- 2
+succeeded
+-1 -1 -1 -1 0 -1 -1 -1
+
+--- %b --- 3
+succeeded
+-1 -1 -1 -1 1 -1 -1 -1
+
+--- %b --- 4
+succeeded
+-1 -1 -1 -1 1 -1 -1 -1
+
+--- %b --- 5
+succeeded
+-1 -1 -1 -1 2 -1 -1 -1
+
+--- %b --- 6
+succeeded
+-1 -1 -1 -1 2 -1 -1 -1
+
+--- %b --- 7
+succeeded
+-1 -1 -1 -1 3 -1 -1 -1
+
+--- %b --- 8
+succeeded
+-1 -1 -1 -1 3 -1 -1 -1
+
+--- %b --- 9
+succeeded
+-1 -1 -1 -1 4 -1 -1 -1
+
+--- %b --- 10
+succeeded
+-1 -1 -1 -1 5 -1 -1 -1
+
+--- %b --- 11
+succeeded
+-1 -1 -1 -1 5 -1 -1 -1
+
+--- %b --- 12
+succeeded
+-1 -1 -1 -1 6 -1 -1 -1
+
+--- %b --- 13
+succeeded
+-1 -1 -1 -1 6 -1 -1 -1
+
+--- %b --- 14
+succeeded
+-1 -1 -1 -1 7 -1 -1 -1
+
+--- %b --- 15
+succeeded
+-1 -1 -1 -1 7 -1 -1 -1
+
+--- %b --- 16
+succeeded
+-1 -1 -1 -1 8 -1 -1 -1
+
+--- %b --- 17
+succeeded
+-1 -1 -1 -1 8 -1 -1 -1
+
+--- %b --- 18
+succeeded
+-1 -1 -1 -1 9 -1 -1 -1
+
+--- %b --- 19
+succeeded
+-1 -1 -1 -1 9 -1 -1 -1
+
+--- %b --- 20
+succeeded
+-1 -1 -1 -1 10 -1 -1 -1
+
+--- %b --- 21
+succeeded
+-1 -1 -1 -1 10 -1 -1 -1
+
+--- %b --- 22
+succeeded
+-1 -1 -1 -1 11 -1 -1 -1
+
+--- %b --- 23
+succeeded
+-1 -1 -1 -1 11 -1 -1 -1
+
+--- %b --- 25
+succeeded
+-1 -1 -1 -1 4 -1 -1 -1
+or
+
+--- %b --- 24
+succeeded
+-1 -1 -1 -1 2 -1 -1 -1
+s
+
+--- %b --- 26
+failed
+--- %B --- 1
+succeeded
+-1 -1 -1 -1 0 -1 -1 -1
+
+--- %B --- 2
+succeeded
+-1 -1 -1 -1 0 -1 -1 -1
+
+--- %B --- 3
+succeeded
+-1 -1 -1 -1 1 -1 -1 -1
+
+--- %B --- 4
+succeeded
+-1 -1 -1 -1 1 -1 -1 -1
+
+--- %B --- 5
+succeeded
+-1 -1 -1 -1 2 -1 -1 -1
+
+--- %B --- 6
+succeeded
+-1 -1 -1 -1 2 -1 -1 -1
+
+--- %B --- 7
+succeeded
+-1 -1 -1 -1 3 -1 -1 -1
+
+--- %B --- 8
+succeeded
+-1 -1 -1 -1 3 -1 -1 -1
+
+--- %B --- 9
+succeeded
+-1 -1 -1 -1 4 -1 -1 -1
+
+--- %B --- 10
+succeeded
+-1 -1 -1 -1 5 -1 -1 -1
+
+--- %B --- 11
+succeeded
+-1 -1 -1 -1 5 -1 -1 -1
+
+--- %B --- 12
+succeeded
+-1 -1 -1 -1 6 -1 -1 -1
+
+--- %B --- 13
+succeeded
+-1 -1 -1 -1 6 -1 -1 -1
+
+--- %B --- 14
+succeeded
+-1 -1 -1 -1 7 -1 -1 -1
+
+--- %B --- 15
+succeeded
+-1 -1 -1 -1 7 -1 -1 -1
+
+--- %B --- 16
+succeeded
+-1 -1 -1 -1 8 -1 -1 -1
+
+--- %B --- 17
+succeeded
+-1 -1 -1 -1 8 -1 -1 -1
+
+--- %B --- 18
+succeeded
+-1 -1 -1 -1 9 -1 -1 -1
+
+--- %B --- 19
+succeeded
+-1 -1 -1 -1 9 -1 -1 -1
+
+--- %B --- 20
+succeeded
+-1 -1 -1 -1 10 -1 -1 -1
+
+--- %B --- 21
+succeeded
+-1 -1 -1 -1 10 -1 -1 -1
+
+--- %B --- 22
+succeeded
+-1 -1 -1 -1 11 -1 -1 -1
+
+--- %B --- 23
+succeeded
+-1 -1 -1 -1 11 -1 -1 -1
+
+--- %B --- 25
+succeeded
+-1 -1 -1 -1 4 -1 -1 -1
+or
+
+--- %B --- 24
+succeeded
+-1 -1 -1 -1 2 -1 -1 -1
+s
+
+--- %B --- 26
+failed
diff --git a/regress/lib/libc/time/strptime/main.c b/regress/lib/libc/time/strptime/main.c
new file mode 100644
index 00000000000..d1d9c394a5d
--- /dev/null
+++ b/regress/lib/libc/time/strptime/main.c
@@ -0,0 +1,117 @@
+/* $OpenBSD: main.c,v 1.1 2004/01/20 16:47:56 millert Exp $ */
+/* $NetBSD: main.c,v 1.4 2002/02/21 07:38:18 itojun Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+int main(int, char *[]);
+void die(void);
+
+void
+die(void)
+{
+
+ if (ferror(stdin))
+ err(1, "fgetln");
+ else
+ errx(1, "input is truncated");
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *p, *title, *buf, *format;
+ size_t len;
+ struct tm tm;
+
+ for (;;) {
+ p = fgetln(stdin, &len);
+ if (p == 0)
+ die();
+ title = malloc(len + 1);
+ memcpy(title, p, len);
+ title[len] = '\0';
+
+ if (!strcmp(title, "EOF\n"))
+ return(0);
+ if (title[0] == '#' || title[0] == '\n') {
+ free(title);
+ continue;
+ }
+
+ p = fgetln(stdin, &len);
+ if (p == 0)
+ die();
+ buf = malloc(len + 1);
+ memcpy(buf, p, len);
+ buf[len] = '\0';
+
+ p = fgetln(stdin, &len);
+ if (p == 0)
+ die();
+ format = malloc(len + 1);
+ memcpy(format, p, len);
+ format[len] = '\0';
+
+ tm.tm_sec = -1;
+ tm.tm_min = -1;
+ tm.tm_hour = -1;
+ tm.tm_mday = -1;
+ tm.tm_mon = -1;
+ tm.tm_year = -1;
+ tm.tm_wday = -1;
+ tm.tm_yday = -1;
+
+ p = strptime(buf, format, &tm);
+
+ printf("%s", title);
+ if (p) {
+ printf("succeeded\n");
+ printf("%d %d %d %d %d %d %d %d\n",
+ tm.tm_sec, tm.tm_min, tm.tm_hour, tm.tm_mday,
+ tm.tm_mon, tm.tm_year, tm.tm_wday, tm.tm_yday);
+ printf("%s\n", p);
+ } else {
+ printf("failed\n");
+ }
+
+ free(title);
+ free(buf);
+ free(format);
+ }
+}
diff --git a/regress/lib/libc/time/strptime/tests b/regress/lib/libc/time/strptime/tests
new file mode 100644
index 00000000000..d96393b2b73
--- /dev/null
+++ b/regress/lib/libc/time/strptime/tests
@@ -0,0 +1,267 @@
+# some intial checks to make sure common things work
+--- ctime --- 1
+Tue Jan 20 23:27:46 1998
+%a %b %d %T %Y
+--- ctime --- 2
+Tue Jan 20 23:27:46 1998
+%a %b %d %H:%M:%S %Y
+--- ctime --- 3
+Tue Jan 20 23:27:46 1998
+%c
+
+# test some valid and invalid day names
+--- %a --- 1
+Sun
+%a
+--- %a --- 2
+Sunday
+%a
+--- %a --- 3
+Mon
+%a
+--- %a --- 4
+Monday
+%a
+--- %a --- 5
+Tue
+%a
+--- %a --- 6
+Tuesday
+%a
+--- %a --- 7
+Wed
+%a
+--- %a --- 8
+Wednesday
+%a
+--- %a --- 9
+Thu
+%a
+--- %a --- 10
+Thursday
+%a
+--- %a --- 11
+Fri
+%a
+--- %a --- 12
+Friday
+%a
+--- %a --- 13
+Sat
+%a
+--- %a --- 14
+Saturday
+%a
+--- %a --- 15
+Saturn
+%a
+--- %a --- 16
+Moon
+%a
+--- %A --- 1
+Sun
+%A
+--- %A --- 2
+Sunday
+%A
+--- %A --- 3
+Mon
+%A
+--- %A --- 4
+Monday
+%A
+--- %A --- 5
+Tue
+%A
+--- %A --- 6
+Tuesday
+%A
+--- %A --- 7
+Wed
+%A
+--- %A --- 8
+Wednesday
+%A
+--- %A --- 9
+Thu
+%A
+--- %A --- 10
+Thursday
+%A
+--- %A --- 11
+Fri
+%A
+--- %A --- 12
+Friday
+%A
+--- %A --- 13
+Sat
+%A
+--- %A --- 14
+Saturday
+%A
+--- %A --- 15
+Saturn
+%A
+--- %A --- 16
+Moon
+%A
+
+# test some valid and invalid month names
+--- %b --- 1
+Jan
+%b
+--- %b --- 2
+January
+%b
+--- %b --- 3
+Feb
+%b
+--- %b --- 4
+February
+%b
+--- %b --- 5
+Mar
+%b
+--- %b --- 6
+March
+%b
+--- %b --- 7
+Apr
+%b
+--- %b --- 8
+April
+%b
+--- %b --- 9
+May
+%b
+--- %b --- 10
+Jun
+%b
+--- %b --- 11
+June
+%b
+--- %b --- 12
+Jul
+%b
+--- %b --- 13
+July
+%b
+--- %b --- 14
+Aug
+%b
+--- %b --- 15
+August
+%b
+--- %b --- 16
+Sep
+%b
+--- %b --- 17
+September
+%b
+--- %b --- 18
+Oct
+%b
+--- %b --- 19
+October
+%b
+--- %b --- 20
+Nov
+%b
+--- %b --- 21
+November
+%b
+--- %b --- 22
+Dec
+%b
+--- %b --- 23
+December
+%b
+--- %b --- 25
+Mayor
+%b
+--- %b --- 24
+Mars
+%b
+--- %b --- 26
+Rover
+%b
+--- %B --- 1
+Jan
+%B
+--- %B --- 2
+January
+%B
+--- %B --- 3
+Feb
+%B
+--- %B --- 4
+February
+%B
+--- %B --- 5
+Mar
+%B
+--- %B --- 6
+March
+%B
+--- %B --- 7
+Apr
+%B
+--- %B --- 8
+April
+%B
+--- %B --- 9
+May
+%B
+--- %B --- 10
+Jun
+%B
+--- %B --- 11
+June
+%B
+--- %B --- 12
+Jul
+%B
+--- %B --- 13
+July
+%B
+--- %B --- 14
+Aug
+%B
+--- %B --- 15
+August
+%B
+--- %B --- 16
+Sep
+%B
+--- %B --- 17
+September
+%B
+--- %B --- 18
+Oct
+%B
+--- %B --- 19
+October
+%B
+--- %B --- 20
+Nov
+%B
+--- %B --- 21
+November
+%B
+--- %B --- 22
+Dec
+%B
+--- %B --- 23
+December
+%B
+--- %B --- 25
+Mayor
+%B
+--- %B --- 24
+Mars
+%B
+--- %B --- 26
+Rover
+%B
+EOF