summaryrefslogtreecommitdiff
path: root/src/regress/lib
diff options
context:
space:
mode:
authormillert <>2004-01-20 16:47:56 +0000
committermillert <>2004-01-20 16:47:56 +0000
commite794a18f3a5f5701d8afd76570112e83b4f8a336 (patch)
tree2480b83a995989d7c0651275130a0fa6c3bfae2c /src/regress/lib
parent3a9bdfad7b4583f085b2e8157df7796839aa8ae2 (diff)
downloadopenbsd-e794a18f3a5f5701d8afd76570112e83b4f8a336.tar.gz
openbsd-e794a18f3a5f5701d8afd76570112e83b4f8a336.tar.bz2
openbsd-e794a18f3a5f5701d8afd76570112e83b4f8a336.zip
Add strptime regress from NetBSD; OK miod@ after un-peeing.
Diffstat (limited to 'src/regress/lib')
-rw-r--r--src/regress/lib/libc/Makefile4
-rw-r--r--src/regress/lib/libc/time/Makefile5
-rw-r--r--src/regress/lib/libc/time/strptime/Makefile12
-rw-r--r--src/regress/lib/libc/time/strptime/expected346
-rw-r--r--src/regress/lib/libc/time/strptime/main.c117
-rw-r--r--src/regress/lib/libc/time/strptime/tests267
6 files changed, 749 insertions, 2 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
index 1861062bbe..1b655bcbed 100644
--- a/src/regress/lib/libc/Makefile
+++ b/src/regress/lib/libc/Makefile
@@ -1,8 +1,8 @@
1# $OpenBSD: Makefile,v 1.11 2003/05/15 04:23:49 deraadt Exp $ 1# $OpenBSD: Makefile,v 1.12 2004/01/20 16:47:55 millert Exp $
2 2
3SUBDIR+= alloca 3SUBDIR+= alloca
4SUBDIR+= _setjmp db getaddrinfo regex setjmp sigsetjmp malloc sigreturn popen 4SUBDIR+= _setjmp db getaddrinfo regex setjmp sigsetjmp malloc sigreturn popen
5SUBDIR+= longjmp atexit sprintf 5SUBDIR+= longjmp atexit sprintf time
6.if (${MACHINE_ARCH} != "vax") 6.if (${MACHINE_ARCH} != "vax")
7SUBDIR+= ieeefp 7SUBDIR+= ieeefp
8.endif 8.endif
diff --git a/src/regress/lib/libc/time/Makefile b/src/regress/lib/libc/time/Makefile
new file mode 100644
index 0000000000..28b5556027
--- /dev/null
+++ b/src/regress/lib/libc/time/Makefile
@@ -0,0 +1,5 @@
1# $OpenBSD: Makefile,v 1.1 2004/01/20 16:47:55 millert Exp $
2
3SUBDIR+=strptime
4
5.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/time/strptime/Makefile b/src/regress/lib/libc/time/strptime/Makefile
new file mode 100644
index 0000000000..9a288e3c0e
--- /dev/null
+++ b/src/regress/lib/libc/time/strptime/Makefile
@@ -0,0 +1,12 @@
1# $OpenBSD: Makefile,v 1.1 2004/01/20 16:47:55 millert Exp $
2
3PROG= strptime_test
4SRCS= main.c
5CLEANFILES+= got
6
7REGRESS_TARGETS=do-reg
8do-reg:
9 ./${PROG} < ${.CURDIR}/tests > got
10 diff ${.CURDIR}/expected got
11
12.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/time/strptime/expected b/src/regress/lib/libc/time/strptime/expected
new file mode 100644
index 0000000000..d038d319af
--- /dev/null
+++ b/src/regress/lib/libc/time/strptime/expected
@@ -0,0 +1,346 @@
1--- ctime --- 1
2succeeded
346 27 23 20 0 98 2 -1
4
5--- ctime --- 2
6succeeded
746 27 23 20 0 98 2 -1
8
9--- ctime --- 3
10succeeded
1146 27 23 20 0 98 2 -1
12
13--- %a --- 1
14succeeded
15-1 -1 -1 -1 -1 -1 0 -1
16
17--- %a --- 2
18succeeded
19-1 -1 -1 -1 -1 -1 0 -1
20
21--- %a --- 3
22succeeded
23-1 -1 -1 -1 -1 -1 1 -1
24
25--- %a --- 4
26succeeded
27-1 -1 -1 -1 -1 -1 1 -1
28
29--- %a --- 5
30succeeded
31-1 -1 -1 -1 -1 -1 2 -1
32
33--- %a --- 6
34succeeded
35-1 -1 -1 -1 -1 -1 2 -1
36
37--- %a --- 7
38succeeded
39-1 -1 -1 -1 -1 -1 3 -1
40
41--- %a --- 8
42succeeded
43-1 -1 -1 -1 -1 -1 3 -1
44
45--- %a --- 9
46succeeded
47-1 -1 -1 -1 -1 -1 4 -1
48
49--- %a --- 10
50succeeded
51-1 -1 -1 -1 -1 -1 4 -1
52
53--- %a --- 11
54succeeded
55-1 -1 -1 -1 -1 -1 5 -1
56
57--- %a --- 12
58succeeded
59-1 -1 -1 -1 -1 -1 5 -1
60
61--- %a --- 13
62succeeded
63-1 -1 -1 -1 -1 -1 6 -1
64
65--- %a --- 14
66succeeded
67-1 -1 -1 -1 -1 -1 6 -1
68
69--- %a --- 15
70succeeded
71-1 -1 -1 -1 -1 -1 6 -1
72urn
73
74--- %a --- 16
75failed
76--- %A --- 1
77succeeded
78-1 -1 -1 -1 -1 -1 0 -1
79
80--- %A --- 2
81succeeded
82-1 -1 -1 -1 -1 -1 0 -1
83
84--- %A --- 3
85succeeded
86-1 -1 -1 -1 -1 -1 1 -1
87
88--- %A --- 4
89succeeded
90-1 -1 -1 -1 -1 -1 1 -1
91
92--- %A --- 5
93succeeded
94-1 -1 -1 -1 -1 -1 2 -1
95
96--- %A --- 6
97succeeded
98-1 -1 -1 -1 -1 -1 2 -1
99
100--- %A --- 7
101succeeded
102-1 -1 -1 -1 -1 -1 3 -1
103
104--- %A --- 8
105succeeded
106-1 -1 -1 -1 -1 -1 3 -1
107
108--- %A --- 9
109succeeded
110-1 -1 -1 -1 -1 -1 4 -1
111
112--- %A --- 10
113succeeded
114-1 -1 -1 -1 -1 -1 4 -1
115
116--- %A --- 11
117succeeded
118-1 -1 -1 -1 -1 -1 5 -1
119
120--- %A --- 12
121succeeded
122-1 -1 -1 -1 -1 -1 5 -1
123
124--- %A --- 13
125succeeded
126-1 -1 -1 -1 -1 -1 6 -1
127
128--- %A --- 14
129succeeded
130-1 -1 -1 -1 -1 -1 6 -1
131
132--- %A --- 15
133succeeded
134-1 -1 -1 -1 -1 -1 6 -1
135urn
136
137--- %A --- 16
138failed
139--- %b --- 1
140succeeded
141-1 -1 -1 -1 0 -1 -1 -1
142
143--- %b --- 2
144succeeded
145-1 -1 -1 -1 0 -1 -1 -1
146
147--- %b --- 3
148succeeded
149-1 -1 -1 -1 1 -1 -1 -1
150
151--- %b --- 4
152succeeded
153-1 -1 -1 -1 1 -1 -1 -1
154
155--- %b --- 5
156succeeded
157-1 -1 -1 -1 2 -1 -1 -1
158
159--- %b --- 6
160succeeded
161-1 -1 -1 -1 2 -1 -1 -1
162
163--- %b --- 7
164succeeded
165-1 -1 -1 -1 3 -1 -1 -1
166
167--- %b --- 8
168succeeded
169-1 -1 -1 -1 3 -1 -1 -1
170
171--- %b --- 9
172succeeded
173-1 -1 -1 -1 4 -1 -1 -1
174
175--- %b --- 10
176succeeded
177-1 -1 -1 -1 5 -1 -1 -1
178
179--- %b --- 11
180succeeded
181-1 -1 -1 -1 5 -1 -1 -1
182
183--- %b --- 12
184succeeded
185-1 -1 -1 -1 6 -1 -1 -1
186
187--- %b --- 13
188succeeded
189-1 -1 -1 -1 6 -1 -1 -1
190
191--- %b --- 14
192succeeded
193-1 -1 -1 -1 7 -1 -1 -1
194
195--- %b --- 15
196succeeded
197-1 -1 -1 -1 7 -1 -1 -1
198
199--- %b --- 16
200succeeded
201-1 -1 -1 -1 8 -1 -1 -1
202
203--- %b --- 17
204succeeded
205-1 -1 -1 -1 8 -1 -1 -1
206
207--- %b --- 18
208succeeded
209-1 -1 -1 -1 9 -1 -1 -1
210
211--- %b --- 19
212succeeded
213-1 -1 -1 -1 9 -1 -1 -1
214
215--- %b --- 20
216succeeded
217-1 -1 -1 -1 10 -1 -1 -1
218
219--- %b --- 21
220succeeded
221-1 -1 -1 -1 10 -1 -1 -1
222
223--- %b --- 22
224succeeded
225-1 -1 -1 -1 11 -1 -1 -1
226
227--- %b --- 23
228succeeded
229-1 -1 -1 -1 11 -1 -1 -1
230
231--- %b --- 25
232succeeded
233-1 -1 -1 -1 4 -1 -1 -1
234or
235
236--- %b --- 24
237succeeded
238-1 -1 -1 -1 2 -1 -1 -1
239s
240
241--- %b --- 26
242failed
243--- %B --- 1
244succeeded
245-1 -1 -1 -1 0 -1 -1 -1
246
247--- %B --- 2
248succeeded
249-1 -1 -1 -1 0 -1 -1 -1
250
251--- %B --- 3
252succeeded
253-1 -1 -1 -1 1 -1 -1 -1
254
255--- %B --- 4
256succeeded
257-1 -1 -1 -1 1 -1 -1 -1
258
259--- %B --- 5
260succeeded
261-1 -1 -1 -1 2 -1 -1 -1
262
263--- %B --- 6
264succeeded
265-1 -1 -1 -1 2 -1 -1 -1
266
267--- %B --- 7
268succeeded
269-1 -1 -1 -1 3 -1 -1 -1
270
271--- %B --- 8
272succeeded
273-1 -1 -1 -1 3 -1 -1 -1
274
275--- %B --- 9
276succeeded
277-1 -1 -1 -1 4 -1 -1 -1
278
279--- %B --- 10
280succeeded
281-1 -1 -1 -1 5 -1 -1 -1
282
283--- %B --- 11
284succeeded
285-1 -1 -1 -1 5 -1 -1 -1
286
287--- %B --- 12
288succeeded
289-1 -1 -1 -1 6 -1 -1 -1
290
291--- %B --- 13
292succeeded
293-1 -1 -1 -1 6 -1 -1 -1
294
295--- %B --- 14
296succeeded
297-1 -1 -1 -1 7 -1 -1 -1
298
299--- %B --- 15
300succeeded
301-1 -1 -1 -1 7 -1 -1 -1
302
303--- %B --- 16
304succeeded
305-1 -1 -1 -1 8 -1 -1 -1
306
307--- %B --- 17
308succeeded
309-1 -1 -1 -1 8 -1 -1 -1
310
311--- %B --- 18
312succeeded
313-1 -1 -1 -1 9 -1 -1 -1
314
315--- %B --- 19
316succeeded
317-1 -1 -1 -1 9 -1 -1 -1
318
319--- %B --- 20
320succeeded
321-1 -1 -1 -1 10 -1 -1 -1
322
323--- %B --- 21
324succeeded
325-1 -1 -1 -1 10 -1 -1 -1
326
327--- %B --- 22
328succeeded
329-1 -1 -1 -1 11 -1 -1 -1
330
331--- %B --- 23
332succeeded
333-1 -1 -1 -1 11 -1 -1 -1
334
335--- %B --- 25
336succeeded
337-1 -1 -1 -1 4 -1 -1 -1
338or
339
340--- %B --- 24
341succeeded
342-1 -1 -1 -1 2 -1 -1 -1
343s
344
345--- %B --- 26
346failed
diff --git a/src/regress/lib/libc/time/strptime/main.c b/src/regress/lib/libc/time/strptime/main.c
new file mode 100644
index 0000000000..d1d9c394a5
--- /dev/null
+++ b/src/regress/lib/libc/time/strptime/main.c
@@ -0,0 +1,117 @@
1/* $OpenBSD: main.c,v 1.1 2004/01/20 16:47:56 millert Exp $ */
2/* $NetBSD: main.c,v 1.4 2002/02/21 07:38:18 itojun Exp $ */
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36#include <err.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <time.h>
41
42int main(int, char *[]);
43void die(void);
44
45void
46die(void)
47{
48
49 if (ferror(stdin))
50 err(1, "fgetln");
51 else
52 errx(1, "input is truncated");
53}
54
55int
56main(int argc, char *argv[])
57{
58 char *p, *title, *buf, *format;
59 size_t len;
60 struct tm tm;
61
62 for (;;) {
63 p = fgetln(stdin, &len);
64 if (p == 0)
65 die();
66 title = malloc(len + 1);
67 memcpy(title, p, len);
68 title[len] = '\0';
69
70 if (!strcmp(title, "EOF\n"))
71 return(0);
72 if (title[0] == '#' || title[0] == '\n') {
73 free(title);
74 continue;
75 }
76
77 p = fgetln(stdin, &len);
78 if (p == 0)
79 die();
80 buf = malloc(len + 1);
81 memcpy(buf, p, len);
82 buf[len] = '\0';
83
84 p = fgetln(stdin, &len);
85 if (p == 0)
86 die();
87 format = malloc(len + 1);
88 memcpy(format, p, len);
89 format[len] = '\0';
90
91 tm.tm_sec = -1;
92 tm.tm_min = -1;
93 tm.tm_hour = -1;
94 tm.tm_mday = -1;
95 tm.tm_mon = -1;
96 tm.tm_year = -1;
97 tm.tm_wday = -1;
98 tm.tm_yday = -1;
99
100 p = strptime(buf, format, &tm);
101
102 printf("%s", title);
103 if (p) {
104 printf("succeeded\n");
105 printf("%d %d %d %d %d %d %d %d\n",
106 tm.tm_sec, tm.tm_min, tm.tm_hour, tm.tm_mday,
107 tm.tm_mon, tm.tm_year, tm.tm_wday, tm.tm_yday);
108 printf("%s\n", p);
109 } else {
110 printf("failed\n");
111 }
112
113 free(title);
114 free(buf);
115 free(format);
116 }
117}
diff --git a/src/regress/lib/libc/time/strptime/tests b/src/regress/lib/libc/time/strptime/tests
new file mode 100644
index 0000000000..d96393b2b7
--- /dev/null
+++ b/src/regress/lib/libc/time/strptime/tests
@@ -0,0 +1,267 @@
1# some intial checks to make sure common things work
2--- ctime --- 1
3Tue Jan 20 23:27:46 1998
4%a %b %d %T %Y
5--- ctime --- 2
6Tue Jan 20 23:27:46 1998
7%a %b %d %H:%M:%S %Y
8--- ctime --- 3
9Tue Jan 20 23:27:46 1998
10%c
11
12# test some valid and invalid day names
13--- %a --- 1
14Sun
15%a
16--- %a --- 2
17Sunday
18%a
19--- %a --- 3
20Mon
21%a
22--- %a --- 4
23Monday
24%a
25--- %a --- 5
26Tue
27%a
28--- %a --- 6
29Tuesday
30%a
31--- %a --- 7
32Wed
33%a
34--- %a --- 8
35Wednesday
36%a
37--- %a --- 9
38Thu
39%a
40--- %a --- 10
41Thursday
42%a
43--- %a --- 11
44Fri
45%a
46--- %a --- 12
47Friday
48%a
49--- %a --- 13
50Sat
51%a
52--- %a --- 14
53Saturday
54%a
55--- %a --- 15
56Saturn
57%a
58--- %a --- 16
59Moon
60%a
61--- %A --- 1
62Sun
63%A
64--- %A --- 2
65Sunday
66%A
67--- %A --- 3
68Mon
69%A
70--- %A --- 4
71Monday
72%A
73--- %A --- 5
74Tue
75%A
76--- %A --- 6
77Tuesday
78%A
79--- %A --- 7
80Wed
81%A
82--- %A --- 8
83Wednesday
84%A
85--- %A --- 9
86Thu
87%A
88--- %A --- 10
89Thursday
90%A
91--- %A --- 11
92Fri
93%A
94--- %A --- 12
95Friday
96%A
97--- %A --- 13
98Sat
99%A
100--- %A --- 14
101Saturday
102%A
103--- %A --- 15
104Saturn
105%A
106--- %A --- 16
107Moon
108%A
109
110# test some valid and invalid month names
111--- %b --- 1
112Jan
113%b
114--- %b --- 2
115January
116%b
117--- %b --- 3
118Feb
119%b
120--- %b --- 4
121February
122%b
123--- %b --- 5
124Mar
125%b
126--- %b --- 6
127March
128%b
129--- %b --- 7
130Apr
131%b
132--- %b --- 8
133April
134%b
135--- %b --- 9
136May
137%b
138--- %b --- 10
139Jun
140%b
141--- %b --- 11
142June
143%b
144--- %b --- 12
145Jul
146%b
147--- %b --- 13
148July
149%b
150--- %b --- 14
151Aug
152%b
153--- %b --- 15
154August
155%b
156--- %b --- 16
157Sep
158%b
159--- %b --- 17
160September
161%b
162--- %b --- 18
163Oct
164%b
165--- %b --- 19
166October
167%b
168--- %b --- 20
169Nov
170%b
171--- %b --- 21
172November
173%b
174--- %b --- 22
175Dec
176%b
177--- %b --- 23
178December
179%b
180--- %b --- 25
181Mayor
182%b
183--- %b --- 24
184Mars
185%b
186--- %b --- 26
187Rover
188%b
189--- %B --- 1
190Jan
191%B
192--- %B --- 2
193January
194%B
195--- %B --- 3
196Feb
197%B
198--- %B --- 4
199February
200%B
201--- %B --- 5
202Mar
203%B
204--- %B --- 6
205March
206%B
207--- %B --- 7
208Apr
209%B
210--- %B --- 8
211April
212%B
213--- %B --- 9
214May
215%B
216--- %B --- 10
217Jun
218%B
219--- %B --- 11
220June
221%B
222--- %B --- 12
223Jul
224%B
225--- %B --- 13
226July
227%B
228--- %B --- 14
229Aug
230%B
231--- %B --- 15
232August
233%B
234--- %B --- 16
235Sep
236%B
237--- %B --- 17
238September
239%B
240--- %B --- 18
241Oct
242%B
243--- %B --- 19
244October
245%B
246--- %B --- 20
247Nov
248%B
249--- %B --- 21
250November
251%B
252--- %B --- 22
253Dec
254%B
255--- %B --- 23
256December
257%B
258--- %B --- 25
259Mayor
260%B
261--- %B --- 24
262Mars
263%B
264--- %B --- 26
265Rover
266%B
267EOF