xref: /freebsd/contrib/netbsd-tests/lib/libc/time/t_strptime.c (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /* $NetBSD: t_strptime.c,v 1.12 2015/10/31 02:25:11 christos Exp $ */
2 
3 /*-
4  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by David Laight.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include <sys/cdefs.h>
33 __COPYRIGHT("@(#) Copyright (c) 2008\
34  The NetBSD Foundation, inc. All rights reserved.");
35 __RCSID("$NetBSD: t_strptime.c,v 1.12 2015/10/31 02:25:11 christos Exp $");
36 
37 #include <time.h>
38 #include <stdlib.h>
39 #include <stdio.h>
40 
41 #include <atf-c.h>
42 
43 static void
44 h_pass(const char *buf, const char *fmt, int len,
45     int tm_sec, int tm_min, int tm_hour, int tm_mday,
46     int tm_mon, int tm_year, int tm_wday, int tm_yday)
47 {
48 	struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
49 	const char *ret, *exp;
50 
51 	exp = buf + len;
52 	ret = strptime(buf, fmt, &tm);
53 
54 #ifdef __FreeBSD__
55 	ATF_CHECK_MSG(ret == exp,
56 	    "strptime(\"%s\", \"%s\", tm): incorrect return code: "
57 	    "expected: %p, got: %p", buf, fmt, exp, ret);
58 
59 #define H_REQUIRE_FIELD(field)						\
60 		ATF_CHECK_MSG(tm.field == field,			\
61 		    "strptime(\"%s\", \"%s\", tm): incorrect %s: "	\
62 		    "expected: %d, but got: %d", buf, fmt,		\
63 		    ___STRING(field), field, tm.field)
64 #else
65 	ATF_REQUIRE_MSG(ret == exp,
66 	    "strptime(\"%s\", \"%s\", tm): incorrect return code: "
67 	    "expected: %p, got: %p", buf, fmt, exp, ret);
68 
69 #define H_REQUIRE_FIELD(field)						\
70 		ATF_REQUIRE_MSG(tm.field == field,			\
71 		    "strptime(\"%s\", \"%s\", tm): incorrect %s: "	\
72 		    "expected: %d, but got: %d", buf, fmt,		\
73 		    ___STRING(field), field, tm.field)
74 #endif
75 
76 	H_REQUIRE_FIELD(tm_sec);
77 	H_REQUIRE_FIELD(tm_min);
78 	H_REQUIRE_FIELD(tm_hour);
79 	H_REQUIRE_FIELD(tm_mday);
80 	H_REQUIRE_FIELD(tm_mon);
81 	H_REQUIRE_FIELD(tm_year);
82 	H_REQUIRE_FIELD(tm_wday);
83 	H_REQUIRE_FIELD(tm_yday);
84 
85 #undef H_REQUIRE_FIELD
86 }
87 
88 static void
89 h_fail(const char *buf, const char *fmt)
90 {
91 	struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
92 
93 #ifdef __FreeBSD__
94 	ATF_CHECK_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
95 	    "\"%s\", &tm) should fail, but it didn't", buf, fmt);
96 #else
97 	ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
98 	    "\"%s\", &tm) should fail, but it didn't", buf, fmt);
99 #endif
100 }
101 
102 static struct {
103 	const char *name;
104 	long offs;
105 } zt[] = {
106 #ifndef __FreeBSD__
107 	{ "Z",				0 },
108 	{ "UT",				0 },
109 	{ "UTC",			0 },
110 	{ "GMT",			0 },
111 	{ "EST",			-18000 },
112 	{ "EDT",			-14400 },
113 	{ "CST",			-21600 },
114 	{ "CDT",			-18000 },
115 	{ "MST",			-25200 },
116 	{ "MDT",			-21600 },
117 	{ "PST",			-28800 },
118 	{ "PDT",			-25200 },
119 
120 	{ "VST",			-1 },
121 	{ "VDT",			-1 },
122 
123 	{ "+03",			10800 },
124 	{ "-03",			-10800 },
125 	{ "+0403",			14580 },
126 	{ "-0403",			-14580 },
127 	{ "+04:03",			14580 },
128 	{ "-04:03",			-14580 },
129 	{ "+14:00",			50400 },
130 	{ "-14:00",			-50400 },
131 	{ "+23:59",			86340 },
132 	{ "-23:59",			-86340 },
133 
134 	{ "1",				-1 },
135 	{ "03",				-1 },
136 	{ "0304",			-1 },
137 	{ "+1",				-1 },
138 	{ "-203",			-1 },
139 	{ "+12345",			-1 },
140 	{ "+12:345",			-1 },
141 	{ "+123:45",			-1 },
142 	{ "+2400",			-1 },
143 	{ "-2400",			-1 },
144 	{ "+1060",			-1 },
145 	{ "-1060",			-1 },
146 
147 	{ "A",				-3600 },
148 	{ "B",				-7200 },
149 	{ "C",				-10800 },
150 	{ "D",				-14400 },
151 	{ "E",				-18000 },
152 	{ "F",				-21600 },
153 	{ "G",				-25200 },
154 	{ "H",				-28800 },
155 	{ "I",				-32400 },
156 	{ "L",				-39600 },
157 	{ "M",				-43200 },
158 	{ "N",				3600 },
159 	{ "O",				7200 },
160 	{ "P",				10800 },
161 	{ "Q",				14400 },
162 	{ "R",				18000 },
163 	{ "T",				25200 },
164 	{ "U",				28800 },
165 	{ "V",				32400 },
166 	{ "W",				36000 },
167 	{ "X",				39600 },
168 	{ "Y",				43200 },
169 
170 	{ "J",				-2 },
171 
172 	{ "America/Los_Angeles",	-28800 },
173 	{ "America/New_York",		-18000 },
174 	{ "EST4EDT",			-14400 },
175 
176 	{ "Bogus",			-1 },
177 #endif
178 };
179 
180 static void
181 ztest1(const char *name, const char *fmt, long value)
182 {
183 	struct tm tm;
184 	char *rv;
185 
186 	memset(&tm, 0, sizeof(tm));
187 	if ((rv = strptime(name, fmt, &tm)) == NULL)
188 		tm.tm_gmtoff = -1;
189 	else if (rv == name && fmt[1] == 'Z')
190 		value = 0;
191 
192 	switch (value) {
193 #ifndef __FreeBSD__
194 	case -2:
195 		value = -timezone;
196 		break;
197 #endif
198 	case -1:
199 		if (fmt[1] == 'Z')
200 			value = 0;
201 		break;
202 	default:
203 		break;
204 	}
205 
206 	ATF_REQUIRE_MSG(tm.tm_gmtoff == value,
207 	    "strptime(\"%s\", \"%s\", &tm): "
208 	    "expected: tm.tm_gmtoff=%ld, got: tm.tm_gmtoff=%ld",
209 	    name, fmt, value, tm.tm_gmtoff);
210 	printf("%s %s %ld\n", name, fmt, tm.tm_gmtoff);
211 }
212 
213 static void
214 ztest(const char *fmt)
215 {
216 	setenv("TZ", "US/Eastern", 1);
217 #ifndef __FreeBSD__
218 	ztest1("GMT", fmt, 0);
219 	ztest1("UTC", fmt, 0);
220 	ztest1("US/Eastern", fmt, -18000);
221 #endif
222 	for (size_t i = 0; i < __arraycount(zt); i++)
223 		ztest1(zt[i].name, fmt, zt[i].offs);
224 }
225 
226 ATF_TC(common);
227 
228 ATF_TC_HEAD(common, tc)
229 {
230 
231 	atf_tc_set_md_var(tc, "descr", "Checks strptime(3): various checks");
232 }
233 
234 ATF_TC_BODY(common, tc)
235 {
236 
237 	h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
238 		24, 46, 27, 23, 20, 0, 98, 2, 19);
239 	h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
240 		24, 46, 27, 23, 20, 0, 98, 2, 19);
241 	h_pass("Tue Jan 20 23:27:46 1998", "%c",
242 		24, 46, 27, 23, 20, 0, 98, 2, 19);
243 	h_pass("Fri Mar  4 20:05:34 2005", "%a %b %e %H:%M:%S %Y",
244 		24, 34, 5, 20, 4, 2, 105, 5, 62);
245 	h_pass("5\t3  4 8pm:05:34 2005", "%w%n%m%t%d%n%k%p:%M:%S %Y",
246 		21, 34, 5, 20, 4, 2, 105, 5, 62);
247 	h_pass("Fri Mar  4 20:05:34 2005", "%c",
248 		24, 34, 5, 20, 4, 2, 105, 5, 62);
249 }
250 
251 ATF_TC(day);
252 
253 ATF_TC_HEAD(day, tc)
254 {
255 
256 	atf_tc_set_md_var(tc, "descr",
257 			  "Checks strptime(3) day name conversions [aA]");
258 }
259 
260 ATF_TC_BODY(day, tc)
261 {
262 
263 	h_pass("Sun", "%a", 3, -1, -1, -1, -1, -1, -1, 0, -1);
264 	h_pass("Sunday", "%a", 6, -1, -1, -1, -1, -1, -1, 0, -1);
265 	h_pass("Mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
266 	h_pass("Monday", "%a", 6, -1, -1, -1, -1, -1, -1, 1, -1);
267 	h_pass("Tue", "%a", 3, -1, -1, -1, -1, -1, -1, 2, -1);
268 	h_pass("Tuesday", "%a", 7, -1, -1, -1, -1, -1, -1, 2, -1);
269 	h_pass("Wed", "%a", 3, -1, -1, -1, -1, -1, -1, 3, -1);
270 	h_pass("Wednesday", "%a", 9, -1, -1, -1, -1, -1, -1, 3, -1);
271 	h_pass("Thu", "%a", 3, -1, -1, -1, -1, -1, -1, 4, -1);
272 	h_pass("Thursday", "%a", 8, -1, -1, -1, -1, -1, -1, 4, -1);
273 	h_pass("Fri", "%a", 3, -1, -1, -1, -1, -1, -1, 5, -1);
274 	h_pass("Friday", "%a", 6, -1, -1, -1, -1, -1, -1, 5, -1);
275 	h_pass("Sat", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
276 	h_pass("Saturday", "%a", 8, -1, -1, -1, -1, -1, -1, 6, -1);
277 	h_pass("Saturn", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
278 	h_fail("Moon", "%a");
279 	h_pass("Sun", "%A", 3, -1, -1, -1, -1, -1, -1, 0, -1);
280 	h_pass("Sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
281 	h_pass("Mon", "%A", 3, -1, -1, -1, -1, -1, -1, 1, -1);
282 	h_pass("Monday", "%A", 6, -1, -1, -1, -1, -1, -1, 1, -1);
283 	h_pass("Tue", "%A", 3, -1, -1, -1, -1, -1, -1, 2, -1);
284 	h_pass("Tuesday", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
285 	h_pass("Wed", "%A", 3, -1, -1, -1, -1, -1, -1, 3, -1);
286 	h_pass("Wednesday", "%A", 9, -1, -1, -1, -1, -1, -1, 3, -1);
287 	h_pass("Thu", "%A", 3, -1, -1, -1, -1, -1, -1, 4, -1);
288 	h_pass("Thursday", "%A", 8, -1, -1, -1, -1, -1, -1, 4, -1);
289 	h_pass("Fri", "%A", 3, -1, -1, -1, -1, -1, -1, 5, -1);
290 	h_pass("Friday", "%A", 6, -1, -1, -1, -1, -1, -1, 5, -1);
291 	h_pass("Sat", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
292 	h_pass("Saturday", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
293 	h_pass("Saturn", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
294 	h_fail("Moon", "%A");
295 
296 	h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
297 	h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
298 	h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
299 #ifdef __NetBSD__
300 	h_fail("sunday", "%EA");
301 #else
302 	h_pass("Sunday", "%EA", 6, -1, -1, -1, -1, -1, -1, 0, -1);
303 #endif
304 	h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
305 #ifdef __NetBSD__
306 	h_fail("SaturDay", "%OA");
307 #else
308 	h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1);
309 #endif
310 
311 #ifdef __FreeBSD__
312 	h_fail("00", "%d");
313 #endif
314 }
315 
316 ATF_TC(hour);
317 
318 ATF_TC_HEAD(hour, tc)
319 {
320 
321 	atf_tc_set_md_var(tc, "descr",
322 #ifdef __FreeBSD__
323 			  "Checks strptime(3) hour conversions [HIkl]");
324 #else
325 			  "Checks strptime(3) hour conversions [IH]");
326 #endif
327 }
328 
329 ATF_TC_BODY(hour, tc)
330 {
331 
332 	h_fail("00", "%I");
333 	h_fail("13", "%I");
334 
335 #ifdef __FreeBSD__
336 	h_pass("0", "%k", 1, -1, -1, 0, -1, -1, -1, -1, -1);
337 	h_pass("04", "%k", 2, -1, -1, 4, -1, -1, -1, -1, -1);
338 	h_pass(" 8", "%k", 2, -1, -1, 8, -1, -1, -1, -1, -1);
339 	h_pass("23", "%k", 2, -1, -1, 23, -1, -1, -1, -1, -1);
340 	h_fail("24", "%k");
341 
342 	h_fail("0", "%l");
343 	h_pass("1", "%l", 1, -1, -1, 1, -1, -1, -1, -1, -1);
344 	h_pass("05", "%l", 2, -1, -1, 5, -1, -1, -1, -1, -1);
345 	h_pass(" 9", "%l", 2, -1, -1, 9, -1, -1, -1, -1, -1);
346 	h_pass("12", "%l", 2, -1, -1, 12, -1, -1, -1, -1, -1);
347 	h_fail("13", "%l");
348 #endif
349 
350 	h_pass("00", "%H", 2, -1, -1, 0, -1, -1, -1, -1, -1);
351 	h_pass("12", "%H", 2, -1, -1, 12, -1, -1, -1, -1, -1);
352 	h_pass("23", "%H", 2, -1, -1, 23, -1, -1, -1, -1, -1);
353 	h_fail("24", "%H");
354 }
355 
356 
357 ATF_TC(month);
358 
359 ATF_TC_HEAD(month, tc)
360 {
361 
362 	atf_tc_set_md_var(tc, "descr",
363 			  "Checks strptime(3) month name conversions [bB]");
364 }
365 
366 ATF_TC_BODY(month, tc)
367 {
368 
369 	h_pass("Jan", "%b", 3, -1, -1, -1, -1, 0, -1, -1, -1);
370 	h_pass("January", "%b", 7, -1, -1, -1, -1, 0, -1, -1, -1);
371 	h_pass("Feb", "%b", 3, -1, -1, -1, -1, 1, -1, -1, -1);
372 	h_pass("February", "%b", 8, -1, -1, -1, -1, 1, -1, -1, -1);
373 	h_pass("Mar", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
374 	h_pass("March", "%b", 5, -1, -1, -1, -1, 2, -1, -1, -1);
375 	h_pass("Apr", "%b", 3, -1, -1, -1, -1, 3, -1, -1, -1);
376 	h_pass("April", "%b", 5, -1, -1, -1, -1, 3, -1, -1, -1);
377 	h_pass("May", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
378 	h_pass("Jun", "%b", 3, -1, -1, -1, -1, 5, -1, -1, -1);
379 	h_pass("June", "%b", 4, -1, -1, -1, -1, 5, -1, -1, -1);
380 	h_pass("Jul", "%b", 3, -1, -1, -1, -1, 6, -1, -1, -1);
381 	h_pass("July", "%b", 4, -1, -1, -1, -1, 6, -1, -1, -1);
382 	h_pass("Aug", "%b", 3, -1, -1, -1, -1, 7, -1, -1, -1);
383 	h_pass("August", "%b", 6, -1, -1, -1, -1, 7, -1, -1, -1);
384 	h_pass("Sep", "%b", 3, -1, -1, -1, -1, 8, -1, -1, -1);
385 	h_pass("September", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
386 	h_pass("Oct", "%b", 3, -1, -1, -1, -1, 9, -1, -1, -1);
387 	h_pass("October", "%b", 7, -1, -1, -1, -1, 9, -1, -1, -1);
388 	h_pass("Nov", "%b", 3, -1, -1, -1, -1, 10, -1, -1, -1);
389 	h_pass("November", "%b", 8, -1, -1, -1, -1, 10, -1, -1, -1);
390 	h_pass("Dec", "%b", 3, -1, -1, -1, -1, 11, -1, -1, -1);
391 	h_pass("December", "%b", 8, -1, -1, -1, -1, 11, -1, -1, -1);
392 	h_pass("Mayor", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
393 	h_pass("Mars", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
394 	h_fail("Rover", "%b");
395 	h_pass("Jan", "%B", 3, -1, -1, -1, -1, 0, -1, -1, -1);
396 	h_pass("January", "%B", 7, -1, -1, -1, -1, 0, -1, -1, -1);
397 	h_pass("Feb", "%B", 3, -1, -1, -1, -1, 1, -1, -1, -1);
398 	h_pass("February", "%B", 8, -1, -1, -1, -1, 1, -1, -1, -1);
399 	h_pass("Mar", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
400 	h_pass("March", "%B", 5, -1, -1, -1, -1, 2, -1, -1, -1);
401 	h_pass("Apr", "%B", 3, -1, -1, -1, -1, 3, -1, -1, -1);
402 	h_pass("April", "%B", 5, -1, -1, -1, -1, 3, -1, -1, -1);
403 	h_pass("May", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
404 	h_pass("Jun", "%B", 3, -1, -1, -1, -1, 5, -1, -1, -1);
405 	h_pass("June", "%B", 4, -1, -1, -1, -1, 5, -1, -1, -1);
406 	h_pass("Jul", "%B", 3, -1, -1, -1, -1, 6, -1, -1, -1);
407 	h_pass("July", "%B", 4, -1, -1, -1, -1, 6, -1, -1, -1);
408 	h_pass("Aug", "%B", 3, -1, -1, -1, -1, 7, -1, -1, -1);
409 	h_pass("August", "%B", 6, -1, -1, -1, -1, 7, -1, -1, -1);
410 	h_pass("Sep", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
411 	h_pass("September", "%B", 9, -1, -1, -1, -1, 8, -1, -1, -1);
412 	h_pass("Oct", "%B", 3, -1, -1, -1, -1, 9, -1, -1, -1);
413 	h_pass("October", "%B", 7, -1, -1, -1, -1, 9, -1, -1, -1);
414 	h_pass("Nov", "%B", 3, -1, -1, -1, -1, 10, -1, -1, -1);
415 	h_pass("November", "%B", 8, -1, -1, -1, -1, 10, -1, -1, -1);
416 	h_pass("Dec", "%B", 3, -1, -1, -1, -1, 11, -1, -1, -1);
417 	h_pass("December", "%B", 8, -1, -1, -1, -1, 11, -1, -1, -1);
418 	h_pass("Mayor", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
419 	h_pass("Mars", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
420 	h_fail("Rover", "%B");
421 
422 	h_pass("september", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
423 	h_pass("septembe", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
424 }
425 
426 ATF_TC(seconds);
427 
428 ATF_TC_HEAD(seconds, tc)
429 {
430 
431 	atf_tc_set_md_var(tc, "descr",
432 			  "Checks strptime(3) seconds conversions [S]");
433 }
434 
435 ATF_TC_BODY(seconds, tc)
436 {
437 
438 	h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
439 	h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
440 	h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
441 #ifdef __FreeBSD__
442 	/*
443 	 * (Much) older versions of the standard (up to the Issue 6) allowed for
444 	 * [0;61] range in %S conversion for double-leap seconds, and it's
445 	 * apparently what NetBSD and glibc are expecting, however current
446 	 * version defines allowed values to be [0;60], and that is what our
447 	 * strptime() implementation expects.
448 	 */
449 	h_fail("61", "%S");
450 #else
451 	h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
452 #endif
453 	h_fail("62", "%S");
454 }
455 
456 ATF_TC(year);
457 
458 ATF_TC_HEAD(year, tc)
459 {
460 
461 	atf_tc_set_md_var(tc, "descr",
462 			  "Checks strptime(3) century/year conversions [CyY]");
463 }
464 
465 ATF_TC_BODY(year, tc)
466 {
467 
468 	h_pass("x20y", "x%Cy", 4, -1, -1, -1, -1, -1, 100, -1, -1);
469 	h_pass("x84y", "x%yy", 4, -1, -1, -1, -1, -1, 84, -1, -1);
470 	h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
471 	h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
472 	h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
473 #ifndef __FreeBSD__
474 	h_fail("%", "%E%");
475 #endif
476 
477 	h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
478 	h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
479 }
480 
481 ATF_TC(zone);
482 
483 ATF_TC_HEAD(zone, tc)
484 {
485 
486 	atf_tc_set_md_var(tc, "descr",
487 			  "Checks strptime(3) timezone conversion [z]");
488 }
489 
490 
491 ATF_TC_BODY(zone, tc)
492 {
493 	ztest("%z");
494 }
495 
496 ATF_TC(Zone);
497 
498 ATF_TC_HEAD(Zone, tc)
499 {
500 
501 	atf_tc_set_md_var(tc, "descr",
502 			  "Checks strptime(3) timezone conversion [Z]");
503 }
504 
505 
506 ATF_TC_BODY(Zone, tc)
507 {
508 	ztest("%Z");
509 }
510 
511 ATF_TP_ADD_TCS(tp)
512 {
513 
514 	ATF_TP_ADD_TC(tp, common);
515 	ATF_TP_ADD_TC(tp, day);
516 	ATF_TP_ADD_TC(tp, hour);
517 	ATF_TP_ADD_TC(tp, month);
518 	ATF_TP_ADD_TC(tp, seconds);
519 	ATF_TP_ADD_TC(tp, year);
520 	ATF_TP_ADD_TC(tp, zone);
521 	ATF_TP_ADD_TC(tp, Zone);
522 
523 	return atf_no_error();
524 }
525