xref: /minix3/tests/lib/libc/regex/t_regex_att.c (revision 11be35a165022172ed3cea20f2b5df0307540b0e)
1*11be35a1SLionel Sambuc /*	$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $	*/
2*11be35a1SLionel Sambuc 
3*11be35a1SLionel Sambuc /*-
4*11be35a1SLionel Sambuc  * Copyright (c) 2011 The NetBSD Foundation, Inc.
5*11be35a1SLionel Sambuc  * All rights reserved.
6*11be35a1SLionel Sambuc  *
7*11be35a1SLionel Sambuc  * This code is derived from software contributed to The NetBSD Foundation
8*11be35a1SLionel Sambuc  * by Christos Zoulas.
9*11be35a1SLionel Sambuc  *
10*11be35a1SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
11*11be35a1SLionel Sambuc  * modification, are permitted provided that the following conditions
12*11be35a1SLionel Sambuc  * are met:
13*11be35a1SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
14*11be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
15*11be35a1SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
16*11be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
17*11be35a1SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
18*11be35a1SLionel Sambuc  * 3. All advertising materials mentioning features or use of this software
19*11be35a1SLionel Sambuc  *    must display the following acknowledgement:
20*11be35a1SLionel Sambuc  *        This product includes software developed by the NetBSD
21*11be35a1SLionel Sambuc  *        Foundation, Inc. and its contributors.
22*11be35a1SLionel Sambuc  * 4. Neither the name of The NetBSD Foundation nor the names of its
23*11be35a1SLionel Sambuc  *    contributors may be used to endorse or promote products derived
24*11be35a1SLionel Sambuc  *    from this software without specific prior written permission.
25*11be35a1SLionel Sambuc  *
26*11be35a1SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27*11be35a1SLionel Sambuc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28*11be35a1SLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29*11be35a1SLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30*11be35a1SLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31*11be35a1SLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32*11be35a1SLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33*11be35a1SLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34*11be35a1SLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35*11be35a1SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36*11be35a1SLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
37*11be35a1SLionel Sambuc  */
38*11be35a1SLionel Sambuc 
39*11be35a1SLionel Sambuc #include <sys/cdefs.h>
40*11be35a1SLionel Sambuc __RCSID("$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $");
41*11be35a1SLionel Sambuc 
42*11be35a1SLionel Sambuc #include <sys/param.h>
43*11be35a1SLionel Sambuc 
44*11be35a1SLionel Sambuc #include <stdio.h>
45*11be35a1SLionel Sambuc #include <regex.h>
46*11be35a1SLionel Sambuc #include <string.h>
47*11be35a1SLionel Sambuc #include <stdlib.h>
48*11be35a1SLionel Sambuc #include <vis.h>
49*11be35a1SLionel Sambuc #include <ctype.h>
50*11be35a1SLionel Sambuc #include <atf-c.h>
51*11be35a1SLionel Sambuc 
52*11be35a1SLionel Sambuc static const char sep[] = "\r\n\t";
53*11be35a1SLionel Sambuc static const char delim[3] = "\\\\\0";
54*11be35a1SLionel Sambuc 
55*11be35a1SLionel Sambuc 
56*11be35a1SLionel Sambuc static void
fail(const char * pattern,const char * input,size_t lineno)57*11be35a1SLionel Sambuc fail(const char *pattern, const char *input, size_t lineno) {
58*11be35a1SLionel Sambuc 	fprintf(stderr,
59*11be35a1SLionel Sambuc 	    "skipping failed test at line %zu (pattern=%s, input=%s)\n",
60*11be35a1SLionel Sambuc 	    lineno, pattern, input);
61*11be35a1SLionel Sambuc }
62*11be35a1SLionel Sambuc 
63*11be35a1SLionel Sambuc static int
bug(const char * pattern,const char * input,size_t lineno)64*11be35a1SLionel Sambuc bug(const char *pattern, const char *input, size_t lineno) {
65*11be35a1SLionel Sambuc 	static const struct {
66*11be35a1SLionel Sambuc 		const char *p;
67*11be35a1SLionel Sambuc 		const char *i;
68*11be35a1SLionel Sambuc 	} b[] = {
69*11be35a1SLionel Sambuc #if defined(REGEX_SPENCER)
70*11be35a1SLionel Sambuc 		/*
71*11be35a1SLionel Sambuc 		 * The default libc implementation by Henry Spencer
72*11be35a1SLionel Sambuc 		 */
73*11be35a1SLionel Sambuc 		{ "a[-]?c", "ac" },			// basic.dat
74*11be35a1SLionel Sambuc 		{ "(a*)*", "a" },			// categorization.dat
75*11be35a1SLionel Sambuc 		{ "(aba|a*b)*", "ababa" },		// categorization.dat
76*11be35a1SLionel Sambuc 		{ "\\(a\\(b\\)*\\)*\\2", "abab" },	// categorization.dat
77*11be35a1SLionel Sambuc 		{ "(a*)*", "aaaaaa" },			// nullsubexpression.dat
78*11be35a1SLionel Sambuc 		{ "(a*)*", "aaaaaax" },			// nullsubexpression.dat
79*11be35a1SLionel Sambuc 		{ "(a*)+", "a" },			// nullsubexpression.dat
80*11be35a1SLionel Sambuc 		{ "(a*)+", "aaaaaa" },			// nullsubexpression.dat
81*11be35a1SLionel Sambuc 		{ "(a*)+", "aaaaaax" },			// nullsubexpression.dat
82*11be35a1SLionel Sambuc 		{ "([a]*)*", "a" },			// nullsubexpression.dat
83*11be35a1SLionel Sambuc 		{ "([a]*)*", "aaaaaa" },		// nullsubexpression.dat
84*11be35a1SLionel Sambuc 		{ "([a]*)*", "aaaaaax" },		// nullsubexpression.dat
85*11be35a1SLionel Sambuc 		{ "([a]*)+", "a" },			// nullsubexpression.dat
86*11be35a1SLionel Sambuc 		{ "([a]*)+", "aaaaaa" },		// nullsubexpression.dat
87*11be35a1SLionel Sambuc 		{ "([a]*)+", "aaaaaax" },		// nullsubexpression.dat
88*11be35a1SLionel Sambuc 		{ "([^b]*)*", "a" },			// nullsubexpression.dat
89*11be35a1SLionel Sambuc 		{ "([^b]*)*", "aaaaaa" },		// nullsubexpression.dat
90*11be35a1SLionel Sambuc 		{ "([^b]*)*", "aaaaaab" },		// nullsubexpression.dat
91*11be35a1SLionel Sambuc 		{ "([ab]*)*", "a" },			// nullsubexpression.dat
92*11be35a1SLionel Sambuc 		{ "([ab]*)*", "aaaaaa" },		// nullsubexpression.dat
93*11be35a1SLionel Sambuc 		{ "([ab]*)*", "ababab" },		// nullsubexpression.dat
94*11be35a1SLionel Sambuc 		{ "([ab]*)*", "bababa" },		// nullsubexpression.dat
95*11be35a1SLionel Sambuc 		{ "([ab]*)*", "b" },			// nullsubexpression.dat
96*11be35a1SLionel Sambuc 		{ "([ab]*)*", "bbbbbb" },		// nullsubexpression.dat
97*11be35a1SLionel Sambuc 		{ "([ab]*)*", "aaaabcde" },		// nullsubexpression.dat
98*11be35a1SLionel Sambuc 		{ "([^a]*)*", "b" },			// nullsubexpression.dat
99*11be35a1SLionel Sambuc 		{ "([^a]*)*", "bbbbbb" },		// nullsubexpression.dat
100*11be35a1SLionel Sambuc 		{ "([^ab]*)*", "ccccxx" },		// nullsubexpression.dat
101*11be35a1SLionel Sambuc 		{ "\\(a*\\)*\\(x\\)", "ax" },		// nullsubexpression.dat
102*11be35a1SLionel Sambuc 		{ "\\(a*\\)*\\(x\\)", "axa" },		// nullsubexpression.dat
103*11be35a1SLionel Sambuc 		{ "\\(a*\\)*\\(x\\)\\(\\1\\)", "x" },	// nullsubexpression.dat
104*11be35a1SLionel Sambuc /* crash! */	{ "\\(a*\\)*\\(x\\)\\(\\1\\)", "ax" },	// nullsubexpression.dat
105*11be35a1SLionel Sambuc /* crash! */	{ "\\(a*\\)*\\(x\\)\\(\\1\\)\\(x\\)", "axxa" },	// ""
106*11be35a1SLionel Sambuc 		{ "(a*)*(x)",  "ax" },			// nullsubexpression.dat
107*11be35a1SLionel Sambuc 		{ "(a*)*(x)",  "axa" },			// nullsubexpression.dat
108*11be35a1SLionel Sambuc 		{ "(a*)+(x)",  "ax" },			// nullsubexpression.dat
109*11be35a1SLionel Sambuc 		{ "(a*)+(x)",  "axa" },			// nullsubexpression.dat
110*11be35a1SLionel Sambuc 		{ "((a|ab)(c|bcd))(d*)", "abcd" },	// forcedassoc.dat
111*11be35a1SLionel Sambuc 		{ "((a|ab)(bcd|c))(d*)", "abcd" },	// forcedassoc.dat
112*11be35a1SLionel Sambuc 		{ "((ab|a)(c|bcd))(d*)", "abcd" },	// forcedassoc.dat
113*11be35a1SLionel Sambuc 		{ "((ab|a)(bcd|c))(d*)", "abcd" },	// forcedassoc.dat
114*11be35a1SLionel Sambuc 		{ "((a*)(b|abc))(c*)", "abc" },		// forcedassoc.dat
115*11be35a1SLionel Sambuc 		{ "((a*)(abc|b))(c*)", "abc" },		// forcedassoc.dat
116*11be35a1SLionel Sambuc 		{ "((..)|(.)){2}", "aaa" },		// repetition.dat
117*11be35a1SLionel Sambuc 		{ "((..)|(.)){3}", "aaa" },		// repetition.dat
118*11be35a1SLionel Sambuc 		{ "((..)|(.)){3}", "aaaa" },		// repetition.dat
119*11be35a1SLionel Sambuc 		{ "((..)|(.)){3}", "aaaaa" },		// repetition.dat
120*11be35a1SLionel Sambuc 		{ "X(.?){0,}Y", "X1234567Y" },		// repetition.dat
121*11be35a1SLionel Sambuc 		{ "X(.?){1,}Y", "X1234567Y" },		// repetition.dat
122*11be35a1SLionel Sambuc 		{ "X(.?){2,}Y", "X1234567Y" },		// repetition.dat
123*11be35a1SLionel Sambuc 		{ "X(.?){3,}Y", "X1234567Y" },		// repetition.dat
124*11be35a1SLionel Sambuc 		{ "X(.?){4,}Y", "X1234567Y" },		// repetition.dat
125*11be35a1SLionel Sambuc 		{ "X(.?){5,}Y", "X1234567Y" },		// repetition.dat
126*11be35a1SLionel Sambuc 		{ "X(.?){6,}Y", "X1234567Y" },		// repetition.dat
127*11be35a1SLionel Sambuc 		{ "X(.?){7,}Y", "X1234567Y" },		// repetition.dat
128*11be35a1SLionel Sambuc 		{ "X(.?){0,8}Y", "X1234567Y" },		// repetition.dat
129*11be35a1SLionel Sambuc 		{ "X(.?){1,8}Y", "X1234567Y" },		// repetition.dat
130*11be35a1SLionel Sambuc 		{ "X(.?){2,8}Y", "X1234567Y" },		// repetition.dat
131*11be35a1SLionel Sambuc 		{ "X(.?){3,8}Y", "X1234567Y" },		// repetition.dat
132*11be35a1SLionel Sambuc 		{ "X(.?){4,8}Y", "X1234567Y" },		// repetition.dat
133*11be35a1SLionel Sambuc 		{ "X(.?){5,8}Y", "X1234567Y" },		// repetition.dat
134*11be35a1SLionel Sambuc 		{ "X(.?){6,8}Y", "X1234567Y" },		// repetition.dat
135*11be35a1SLionel Sambuc 		{ "X(.?){7,8}Y", "X1234567Y" },		// repetition.dat
136*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){0,}(d*)", "ababcd" },	// repetition.dat
137*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){1,}(d*)", "ababcd" },	// repetition.dat
138*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){2,}(d*)", "ababcd" },	// repetition.dat
139*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){3,}(d*)", "ababcd" },	// repetition.dat
140*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){1,10}(d*)", "ababcd" },	// repetition.dat
141*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){2,10}(d*)", "ababcd" },	// repetition.dat
142*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd){3,10}(d*)", "ababcd" },	// repetition.dat
143*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd)*(d*)", "ababcd" },	// repetition.dat
144*11be35a1SLionel Sambuc 		{ "(a|ab|c|bcd)+(d*)", "ababcd" },	// repetition.dat
145*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){0,}(d*)", "ababcd" },	// repetition.dat
146*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){1,}(d*)", "ababcd" },	// repetition.dat
147*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){2,}(d*)", "ababcd" },	// repetition.dat
148*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){3,}(d*)", "ababcd" },	// repetition.dat
149*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){1,10}(d*)", "ababcd" },	// repetition.dat
150*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){2,10}(d*)", "ababcd" },	// repetition.dat
151*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd){3,10}(d*)", "ababcd" },	// repetition.dat
152*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd)*(d*)", "ababcd" },	// repetition.dat
153*11be35a1SLionel Sambuc 		{ "(ab|a|c|bcd)+(d*)", "ababcd" },	// repetition.dat
154*11be35a1SLionel Sambuc #elif defined(REGEX_TRE)
155*11be35a1SLionel Sambuc 		{ "a[-]?c", "ac" },			// basic.dat
156*11be35a1SLionel Sambuc 		{ "a\\(b\\)*\\1", "a" },		// categorization.dat
157*11be35a1SLionel Sambuc 		{ "a\\(b\\)*\\1", "abab" },		// categorization.dat
158*11be35a1SLionel Sambuc 		{ "\\(a\\(b\\)*\\)*\\2", "abab" },	// categorization.dat
159*11be35a1SLionel Sambuc 		{ "\\(a*\\)*\\(x\\)\\(\\1\\)", "ax" },	// categorization.dat
160*11be35a1SLionel Sambuc 		{ "\\(a*\\)*\\(x\\)\\(\\1\\)\\(x\\)", "axxa" },	// ""
161*11be35a1SLionel Sambuc 		{ "((..)|(.))*", "aa" },		// repetition.dat
162*11be35a1SLionel Sambuc 		{ "((..)|(.))*", "aaa" },		// repetition.dat
163*11be35a1SLionel Sambuc 		{ "((..)|(.))*", "aaaaa" },		// repetition.dat
164*11be35a1SLionel Sambuc 		{ "X(.?){7,}Y", "X1234567Y" },		// repetition.dat
165*11be35a1SLionel Sambuc #else
166*11be35a1SLionel Sambuc 		{ "", "" }
167*11be35a1SLionel Sambuc #endif
168*11be35a1SLionel Sambuc 	};
169*11be35a1SLionel Sambuc 
170*11be35a1SLionel Sambuc 	for (size_t i = 0; i < __arraycount(b); i++) {
171*11be35a1SLionel Sambuc 		if (strcmp(pattern, b[i].p) == 0 &&
172*11be35a1SLionel Sambuc 		    strcmp(input, b[i].i) == 0) {
173*11be35a1SLionel Sambuc 			fail(pattern, input, lineno);
174*11be35a1SLionel Sambuc 			return 1;
175*11be35a1SLionel Sambuc 		}
176*11be35a1SLionel Sambuc 	}
177*11be35a1SLionel Sambuc 	return 0;
178*11be35a1SLionel Sambuc }
179*11be35a1SLionel Sambuc 
180*11be35a1SLionel Sambuc #ifdef REGEX_SPENCER
181*11be35a1SLionel Sambuc #define HAVE_BRACES	1
182*11be35a1SLionel Sambuc #define HAVE_MINIMAL	0
183*11be35a1SLionel Sambuc #endif
184*11be35a1SLionel Sambuc #ifndef HAVE_BRACES
185*11be35a1SLionel Sambuc #define HAVE_BRACES	1
186*11be35a1SLionel Sambuc #endif
187*11be35a1SLionel Sambuc #ifndef HAVE_MINIMAL
188*11be35a1SLionel Sambuc #define HAVE_MINIMAL	1
189*11be35a1SLionel Sambuc #endif
190*11be35a1SLionel Sambuc 
191*11be35a1SLionel Sambuc static int
optional(const char * s)192*11be35a1SLionel Sambuc optional(const char *s)
193*11be35a1SLionel Sambuc {
194*11be35a1SLionel Sambuc 	static const struct{
195*11be35a1SLionel Sambuc 		const char *n;
196*11be35a1SLionel Sambuc 		int v;
197*11be35a1SLionel Sambuc 	} nv[]= {
198*11be35a1SLionel Sambuc 		{ "[[<element>]] not supported", HAVE_BRACES },
199*11be35a1SLionel Sambuc 		{ "no *? +? mimimal match ops", HAVE_MINIMAL },
200*11be35a1SLionel Sambuc 	};
201*11be35a1SLionel Sambuc 
202*11be35a1SLionel Sambuc 	for (size_t i = 0; i < __arraycount(nv); i++)
203*11be35a1SLionel Sambuc 		if (strcmp(nv[i].n, s) == 0) {
204*11be35a1SLionel Sambuc 			if (nv[i].v)
205*11be35a1SLionel Sambuc 				return 0;
206*11be35a1SLionel Sambuc 			fprintf(stderr, "skipping unsupported [%s] tests\n", s);
207*11be35a1SLionel Sambuc 			return 1;
208*11be35a1SLionel Sambuc 		}
209*11be35a1SLionel Sambuc 
210*11be35a1SLionel Sambuc 	ATF_REQUIRE_MSG(0, "Unknown feature: %s", s);
211*11be35a1SLionel Sambuc 	return 0;
212*11be35a1SLionel Sambuc }
213*11be35a1SLionel Sambuc 
214*11be35a1SLionel Sambuc static int
unsupported(const char * s)215*11be35a1SLionel Sambuc unsupported(const char *s)
216*11be35a1SLionel Sambuc {
217*11be35a1SLionel Sambuc 	static const char *we[] = {
218*11be35a1SLionel Sambuc #if defined(REGEX_SPENCER)
219*11be35a1SLionel Sambuc 		"ASSOCIATIVITY=left",		// have right associativity
220*11be35a1SLionel Sambuc 		"SUBEXPRESSION=precedence",	// have grouping subexpression
221*11be35a1SLionel Sambuc 		"REPEAT_LONGEST=last",		// have first repeat longest
222*11be35a1SLionel Sambuc 		"BUG=alternation-order",	// don't have it
223*11be35a1SLionel Sambuc 		"BUG=first-match",		// don't have it
224*11be35a1SLionel Sambuc 		"BUG=nomatch-match",		// don't have it
225*11be35a1SLionel Sambuc 		"BUG=repeat-any",		// don't have it
226*11be35a1SLionel Sambuc 		"BUG=range-null",		// don't have it
227*11be35a1SLionel Sambuc 		"BUG=repeat-null-unknown",	// don't have it
228*11be35a1SLionel Sambuc 		"BUG=repeat-null",		// don't have it
229*11be35a1SLionel Sambuc 		"BUG=repeat-artifact",		// don't have it
230*11be35a1SLionel Sambuc 		"BUG=subexpression-first",	// don't have it
231*11be35a1SLionel Sambuc #elif defined(REGEX_TRE)
232*11be35a1SLionel Sambuc 		"ASSOCIATIVITY=right",		// have left associativity
233*11be35a1SLionel Sambuc 		"SUBEXPRESSION=grouping",	// have precedence subexpression
234*11be35a1SLionel Sambuc 		"REPEAT_LONGEST=first",		// have last repeat longest
235*11be35a1SLionel Sambuc 		"LENGTH=first",			// have last length
236*11be35a1SLionel Sambuc 		"BUG=alternation-order",	// don't have it
237*11be35a1SLionel Sambuc 		"BUG=first-match",		// don't have it
238*11be35a1SLionel Sambuc 		"BUG=range-null",		// don't have it
239*11be35a1SLionel Sambuc 		"BUG=repeat-null",		// don't have it
240*11be35a1SLionel Sambuc 		"BUG=repeat-artifact",		// don't have it
241*11be35a1SLionel Sambuc 		"BUG=subexpression-first",	// don't have it
242*11be35a1SLionel Sambuc 		"BUG=repeat-short",		// don't have it
243*11be35a1SLionel Sambuc #endif
244*11be35a1SLionel Sambuc 	};
245*11be35a1SLionel Sambuc 
246*11be35a1SLionel Sambuc 	if (s == NULL)
247*11be35a1SLionel Sambuc 		return 0;
248*11be35a1SLionel Sambuc 
249*11be35a1SLionel Sambuc 	while (*s == '#' || isspace((unsigned char)*s))
250*11be35a1SLionel Sambuc 		s++;
251*11be35a1SLionel Sambuc 
252*11be35a1SLionel Sambuc 	for (size_t i = 0; i < __arraycount(we); i++)
253*11be35a1SLionel Sambuc 		if (strcmp(we[i], s) == 0)
254*11be35a1SLionel Sambuc 			return 1;
255*11be35a1SLionel Sambuc 	return 0;
256*11be35a1SLionel Sambuc }
257*11be35a1SLionel Sambuc 
258*11be35a1SLionel Sambuc static void
geterror(const char * s,int * comp,int * exec)259*11be35a1SLionel Sambuc geterror(const char *s, int *comp, int *exec)
260*11be35a1SLionel Sambuc {
261*11be35a1SLionel Sambuc 	static const struct {
262*11be35a1SLionel Sambuc 		const char *n;
263*11be35a1SLionel Sambuc 		int v;
264*11be35a1SLionel Sambuc 		int ce;
265*11be35a1SLionel Sambuc 	} nv[] = {
266*11be35a1SLionel Sambuc #define COMP 1
267*11be35a1SLionel Sambuc #define EXEC 2
268*11be35a1SLionel Sambuc 		{ "OK", 0, COMP|EXEC },
269*11be35a1SLionel Sambuc #define _DO(a, b)	{ # a, REG_ ## a, b },
270*11be35a1SLionel Sambuc 		_DO(NOMATCH, EXEC)
271*11be35a1SLionel Sambuc 		_DO(BADPAT, COMP)
272*11be35a1SLionel Sambuc 		_DO(ECOLLATE, COMP)
273*11be35a1SLionel Sambuc 		_DO(ECTYPE, COMP)
274*11be35a1SLionel Sambuc 		_DO(EESCAPE, COMP)
275*11be35a1SLionel Sambuc 		_DO(ESUBREG, COMP)
276*11be35a1SLionel Sambuc 		_DO(EBRACK, COMP)
277*11be35a1SLionel Sambuc 		_DO(EPAREN, COMP)
278*11be35a1SLionel Sambuc 		_DO(EBRACE, COMP)
279*11be35a1SLionel Sambuc 		_DO(BADBR, COMP)
280*11be35a1SLionel Sambuc 		_DO(ERANGE, COMP)
281*11be35a1SLionel Sambuc 		_DO(ESPACE, EXEC)
282*11be35a1SLionel Sambuc 		_DO(BADRPT, COMP)
283*11be35a1SLionel Sambuc 		_DO(EMPTY, COMP)
284*11be35a1SLionel Sambuc 		_DO(ASSERT, COMP)
285*11be35a1SLionel Sambuc 		_DO(INVARG, COMP)
286*11be35a1SLionel Sambuc 		_DO(ENOSYS, COMP)
287*11be35a1SLionel Sambuc #undef _DO
288*11be35a1SLionel Sambuc 	};
289*11be35a1SLionel Sambuc 	*comp = 0;
290*11be35a1SLionel Sambuc 	*exec = 0;
291*11be35a1SLionel Sambuc 	for (size_t i = 0; i < __arraycount(nv); i++)
292*11be35a1SLionel Sambuc 		if (strcmp(s, nv[i].n) == 0) {
293*11be35a1SLionel Sambuc 			if (nv[i].ce & COMP)
294*11be35a1SLionel Sambuc 				*comp = nv[i].v;
295*11be35a1SLionel Sambuc 			if (nv[i].ce & EXEC)
296*11be35a1SLionel Sambuc 				*exec = nv[i].v;
297*11be35a1SLionel Sambuc 			return;
298*11be35a1SLionel Sambuc 		}
299*11be35a1SLionel Sambuc 	ATF_REQUIRE_MSG(0, "Unknown error %s", s);
300*11be35a1SLionel Sambuc 	return;
301*11be35a1SLionel Sambuc }
302*11be35a1SLionel Sambuc 
303*11be35a1SLionel Sambuc static int
getflags(char * s)304*11be35a1SLionel Sambuc getflags(char *s)
305*11be35a1SLionel Sambuc {
306*11be35a1SLionel Sambuc 	int flags = 0;
307*11be35a1SLionel Sambuc 
308*11be35a1SLionel Sambuc 	for (;; s++)
309*11be35a1SLionel Sambuc 		switch (*s) {
310*11be35a1SLionel Sambuc 		case '0': case '1': case '2': case '3': case '4':
311*11be35a1SLionel Sambuc 		case '5': case '6': case '7': case '8': case '9':
312*11be35a1SLionel Sambuc 			*s = '\0';
313*11be35a1SLionel Sambuc 			break;
314*11be35a1SLionel Sambuc 		case '\0':
315*11be35a1SLionel Sambuc 			return flags;
316*11be35a1SLionel Sambuc 		case 'B':
317*11be35a1SLionel Sambuc 		case 'E':
318*11be35a1SLionel Sambuc 		case 'F':
319*11be35a1SLionel Sambuc 		case 'L':
320*11be35a1SLionel Sambuc 			break;
321*11be35a1SLionel Sambuc 		case 'i':
322*11be35a1SLionel Sambuc 			flags |= REG_ICASE;
323*11be35a1SLionel Sambuc 			*s = '\0';
324*11be35a1SLionel Sambuc 			break;
325*11be35a1SLionel Sambuc 		case '$':
326*11be35a1SLionel Sambuc 			*s = '\0';
327*11be35a1SLionel Sambuc 			break;
328*11be35a1SLionel Sambuc 		case 'n':
329*11be35a1SLionel Sambuc 			*s = '\0';
330*11be35a1SLionel Sambuc 			break;
331*11be35a1SLionel Sambuc 		default:
332*11be35a1SLionel Sambuc 			ATF_REQUIRE_MSG(0, "Unknown char %c", *s);
333*11be35a1SLionel Sambuc 			break;
334*11be35a1SLionel Sambuc 		}
335*11be35a1SLionel Sambuc }
336*11be35a1SLionel Sambuc 
337*11be35a1SLionel Sambuc static size_t
getmatches(const char * s)338*11be35a1SLionel Sambuc getmatches(const char *s)
339*11be35a1SLionel Sambuc {
340*11be35a1SLionel Sambuc 	size_t i;
341*11be35a1SLionel Sambuc 	char *q;
342*11be35a1SLionel Sambuc 	for (i = 0; (q = strchr(s, '(')) != NULL; i++, s = q + 1)
343*11be35a1SLionel Sambuc 		continue;
344*11be35a1SLionel Sambuc 	ATF_REQUIRE_MSG(i != 0, "No parentheses found");
345*11be35a1SLionel Sambuc 	return i;
346*11be35a1SLionel Sambuc }
347*11be35a1SLionel Sambuc 
348*11be35a1SLionel Sambuc static void
checkcomment(const char * s,size_t lineno)349*11be35a1SLionel Sambuc checkcomment(const char *s, size_t lineno)
350*11be35a1SLionel Sambuc {
351*11be35a1SLionel Sambuc 	if (s && strstr(s, "BUG") != NULL)
352*11be35a1SLionel Sambuc 		fprintf(stderr, "Expected %s at line %zu\n", s, lineno);
353*11be35a1SLionel Sambuc }
354*11be35a1SLionel Sambuc 
355*11be35a1SLionel Sambuc static void
checkmatches(const char * matches,size_t nm,const regmatch_t * pm,size_t lineno)356*11be35a1SLionel Sambuc checkmatches(const char *matches, size_t nm, const regmatch_t *pm,
357*11be35a1SLionel Sambuc     size_t lineno)
358*11be35a1SLionel Sambuc {
359*11be35a1SLionel Sambuc 	if (nm == 0)
360*11be35a1SLionel Sambuc 		return;
361*11be35a1SLionel Sambuc 
362*11be35a1SLionel Sambuc 	char *res;
363*11be35a1SLionel Sambuc 	size_t len = strlen(matches) + 1, off = 0;
364*11be35a1SLionel Sambuc 
365*11be35a1SLionel Sambuc 	ATF_REQUIRE((res = strdup(matches)) != NULL);
366*11be35a1SLionel Sambuc 	for (size_t i = 0; i < nm; i++) {
367*11be35a1SLionel Sambuc 		int l;
368*11be35a1SLionel Sambuc 		if (pm[i].rm_so == -1 && pm[i].rm_eo == -1)
369*11be35a1SLionel Sambuc 			l = snprintf(res + off, len - off, "(?,?)");
370*11be35a1SLionel Sambuc 		else
371*11be35a1SLionel Sambuc 			l = snprintf(res + off, len - off, "(%lld,%lld)",
372*11be35a1SLionel Sambuc 			    (long long)pm[i].rm_so, (long long)pm[i].rm_eo);
373*11be35a1SLionel Sambuc 		ATF_REQUIRE_MSG((size_t) l < len - off, "String too long %s"
374*11be35a1SLionel Sambuc 		    " cur=%d, max=%zu", res, l, len - off);
375*11be35a1SLionel Sambuc 		off += l;
376*11be35a1SLionel Sambuc 	}
377*11be35a1SLionel Sambuc 	ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno);
378*11be35a1SLionel Sambuc 	free(res);
379*11be35a1SLionel Sambuc }
380*11be35a1SLionel Sambuc 
381*11be35a1SLionel Sambuc static void
att_test(const struct atf_tc * tc,const char * data_name)382*11be35a1SLionel Sambuc att_test(const struct atf_tc *tc, const char *data_name)
383*11be35a1SLionel Sambuc {
384*11be35a1SLionel Sambuc 	regex_t re;
385*11be35a1SLionel Sambuc 	char *line, *lastpattern = NULL, data_path[MAXPATHLEN];
386*11be35a1SLionel Sambuc 	size_t len, lineno = 0;
387*11be35a1SLionel Sambuc 	int skipping = 0;
388*11be35a1SLionel Sambuc 	FILE *input_file;
389*11be35a1SLionel Sambuc 
390*11be35a1SLionel Sambuc 	snprintf(data_path, sizeof(data_path), "%s/data/%s.dat",
391*11be35a1SLionel Sambuc 	    atf_tc_get_config_var(tc, "srcdir"), data_name);
392*11be35a1SLionel Sambuc 
393*11be35a1SLionel Sambuc 	input_file = fopen(data_path, "r");
394*11be35a1SLionel Sambuc 	if (input_file == NULL)
395*11be35a1SLionel Sambuc 		atf_tc_fail("Failed to open input file %s", data_path);
396*11be35a1SLionel Sambuc 
397*11be35a1SLionel Sambuc 	for (; (line = fparseln(input_file, &len, &lineno, delim, 0))
398*11be35a1SLionel Sambuc 	    != NULL; free(line)) {
399*11be35a1SLionel Sambuc 		char *name, *pattern, *input, *matches, *comment;
400*11be35a1SLionel Sambuc 		regmatch_t *pm;
401*11be35a1SLionel Sambuc 		size_t nm;
402*11be35a1SLionel Sambuc #ifdef DEBUG
403*11be35a1SLionel Sambuc 		fprintf(stderr, "[%s]\n", line);
404*11be35a1SLionel Sambuc #endif
405*11be35a1SLionel Sambuc 		if ((name = strtok(line, sep)) == NULL)
406*11be35a1SLionel Sambuc 			continue;
407*11be35a1SLionel Sambuc 
408*11be35a1SLionel Sambuc 		/*
409*11be35a1SLionel Sambuc 		 * We check these early so that we skip the lines quickly
410*11be35a1SLionel Sambuc 		 * in order to do more strict testing on the other arguments
411*11be35a1SLionel Sambuc 		 * The same characters are also tested in the switch below
412*11be35a1SLionel Sambuc 		 */
413*11be35a1SLionel Sambuc 		if (*name == '}') {
414*11be35a1SLionel Sambuc 			skipping = 0;
415*11be35a1SLionel Sambuc 			continue;
416*11be35a1SLionel Sambuc 		}
417*11be35a1SLionel Sambuc 		if (skipping)
418*11be35a1SLionel Sambuc 			continue;
419*11be35a1SLionel Sambuc 		if (*name == ';' || *name == '#' || strcmp(name, "NOTE") == 0)
420*11be35a1SLionel Sambuc 			continue;
421*11be35a1SLionel Sambuc 		if (*name == ':') {
422*11be35a1SLionel Sambuc 			/* Skip ":HA#???:" prefix */
423*11be35a1SLionel Sambuc 			while (*++name && *name != ':')
424*11be35a1SLionel Sambuc 				continue;
425*11be35a1SLionel Sambuc 			if (*name)
426*11be35a1SLionel Sambuc 				name++;
427*11be35a1SLionel Sambuc 		}
428*11be35a1SLionel Sambuc 
429*11be35a1SLionel Sambuc 		ATF_REQUIRE_MSG((pattern = strtok(NULL, sep)) != NULL,
430*11be35a1SLionel Sambuc 			"Missing pattern at line %zu", lineno);
431*11be35a1SLionel Sambuc 		ATF_REQUIRE_MSG((input = strtok(NULL, sep)) != NULL,
432*11be35a1SLionel Sambuc 			"Missing input at line %zu", lineno);
433*11be35a1SLionel Sambuc 
434*11be35a1SLionel Sambuc 		if (strchr(name, '$')) {
435*11be35a1SLionel Sambuc 			ATF_REQUIRE(strunvis(pattern, pattern) != -1);
436*11be35a1SLionel Sambuc 			ATF_REQUIRE(strunvis(input, input) != -1);
437*11be35a1SLionel Sambuc 		}
438*11be35a1SLionel Sambuc 
439*11be35a1SLionel Sambuc 
440*11be35a1SLionel Sambuc 		if (strcmp(input, "NULL") == 0)
441*11be35a1SLionel Sambuc 			*input = '\0';
442*11be35a1SLionel Sambuc 
443*11be35a1SLionel Sambuc 		if (strcmp(pattern, "SAME") == 0) {
444*11be35a1SLionel Sambuc 			ATF_REQUIRE(lastpattern != NULL);
445*11be35a1SLionel Sambuc 			pattern = lastpattern;
446*11be35a1SLionel Sambuc 		} else {
447*11be35a1SLionel Sambuc 			free(lastpattern);
448*11be35a1SLionel Sambuc 			ATF_REQUIRE((lastpattern = strdup(pattern)) != NULL);
449*11be35a1SLionel Sambuc 		}
450*11be35a1SLionel Sambuc 
451*11be35a1SLionel Sambuc 		ATF_REQUIRE_MSG((matches = strtok(NULL, sep)) != NULL,
452*11be35a1SLionel Sambuc 		    "Missing matches at line %zu", lineno);
453*11be35a1SLionel Sambuc 
454*11be35a1SLionel Sambuc 		comment = strtok(NULL, sep);
455*11be35a1SLionel Sambuc 		switch (*name) {
456*11be35a1SLionel Sambuc 		case '{':	/* Begin optional implementation */
457*11be35a1SLionel Sambuc 			if (optional(comment)) {
458*11be35a1SLionel Sambuc 				skipping++;
459*11be35a1SLionel Sambuc 				continue;
460*11be35a1SLionel Sambuc 			}
461*11be35a1SLionel Sambuc 			name++;	/* We have it, so ignore */
462*11be35a1SLionel Sambuc 			break;
463*11be35a1SLionel Sambuc 		case '}':	/* End optional implementation */
464*11be35a1SLionel Sambuc 			skipping = 0;
465*11be35a1SLionel Sambuc 			continue;
466*11be35a1SLionel Sambuc 		case '?':	/* Optional */
467*11be35a1SLionel Sambuc 		case '|':	/* Alternative */
468*11be35a1SLionel Sambuc 			if (unsupported(comment))
469*11be35a1SLionel Sambuc 				continue;
470*11be35a1SLionel Sambuc 			name++;	/* We have it, so ignore */
471*11be35a1SLionel Sambuc 			break;
472*11be35a1SLionel Sambuc 		case '#':	/* Comment */
473*11be35a1SLionel Sambuc 		case ';':	/* Skip */
474*11be35a1SLionel Sambuc 			continue;
475*11be35a1SLionel Sambuc 		default:
476*11be35a1SLionel Sambuc 			break;
477*11be35a1SLionel Sambuc 		}
478*11be35a1SLionel Sambuc 
479*11be35a1SLionel Sambuc 		/* XXX: Our bug */
480*11be35a1SLionel Sambuc 		if (bug(pattern, input, lineno))
481*11be35a1SLionel Sambuc 			continue;
482*11be35a1SLionel Sambuc 
483*11be35a1SLionel Sambuc 		int comp, exec;
484*11be35a1SLionel Sambuc 		if (*matches != '(') {
485*11be35a1SLionel Sambuc 			geterror(matches, &comp, &exec);
486*11be35a1SLionel Sambuc 			pm = NULL;
487*11be35a1SLionel Sambuc 			nm = 0;
488*11be35a1SLionel Sambuc 		} else {
489*11be35a1SLionel Sambuc 			comp = exec = 0;
490*11be35a1SLionel Sambuc 			nm = getmatches(matches);
491*11be35a1SLionel Sambuc 			ATF_REQUIRE((pm = calloc(nm, sizeof(*pm))) != NULL);
492*11be35a1SLionel Sambuc 		}
493*11be35a1SLionel Sambuc 
494*11be35a1SLionel Sambuc 
495*11be35a1SLionel Sambuc 
496*11be35a1SLionel Sambuc 		int iflags = getflags(name);
497*11be35a1SLionel Sambuc 		for (; *name; name++) {
498*11be35a1SLionel Sambuc 			int flags;
499*11be35a1SLionel Sambuc 			switch (*name) {
500*11be35a1SLionel Sambuc 			case 'B':
501*11be35a1SLionel Sambuc 				flags = REG_BASIC;
502*11be35a1SLionel Sambuc 				break;
503*11be35a1SLionel Sambuc 			case 'E':
504*11be35a1SLionel Sambuc 				flags = REG_EXTENDED;
505*11be35a1SLionel Sambuc 				break;
506*11be35a1SLionel Sambuc 			case 'L':
507*11be35a1SLionel Sambuc 				flags = REG_NOSPEC;
508*11be35a1SLionel Sambuc 				break;
509*11be35a1SLionel Sambuc 			default:
510*11be35a1SLionel Sambuc 				ATF_REQUIRE_MSG(0, "Bad name %c", *name);
511*11be35a1SLionel Sambuc 				continue;
512*11be35a1SLionel Sambuc 			}
513*11be35a1SLionel Sambuc 			int c = regcomp(&re, pattern, flags | iflags);
514*11be35a1SLionel Sambuc 			ATF_REQUIRE_MSG(c == comp,
515*11be35a1SLionel Sambuc 			    "regcomp returned %d for pattern %s at line %zu",
516*11be35a1SLionel Sambuc 			    c, pattern, lineno);
517*11be35a1SLionel Sambuc 			if (c)
518*11be35a1SLionel Sambuc 				continue;
519*11be35a1SLionel Sambuc 			int e = regexec(&re, input, nm, pm, 0);
520*11be35a1SLionel Sambuc 			ATF_REQUIRE_MSG(e == exec, "Expected error %d,"
521*11be35a1SLionel Sambuc 			    " got %d at line %zu", exec, e, lineno);
522*11be35a1SLionel Sambuc 			checkmatches(matches, nm, pm, lineno);
523*11be35a1SLionel Sambuc 			checkcomment(comment, lineno);
524*11be35a1SLionel Sambuc 			regfree(&re);
525*11be35a1SLionel Sambuc 		}
526*11be35a1SLionel Sambuc 		free(pm);
527*11be35a1SLionel Sambuc 	}
528*11be35a1SLionel Sambuc 
529*11be35a1SLionel Sambuc 	fclose(input_file);
530*11be35a1SLionel Sambuc }
531*11be35a1SLionel Sambuc 
532*11be35a1SLionel Sambuc ATF_TC(basic);
ATF_TC_HEAD(basic,tc)533*11be35a1SLionel Sambuc ATF_TC_HEAD(basic, tc)
534*11be35a1SLionel Sambuc {
535*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests basic functionality");
536*11be35a1SLionel Sambuc }
ATF_TC_BODY(basic,tc)537*11be35a1SLionel Sambuc ATF_TC_BODY(basic, tc)
538*11be35a1SLionel Sambuc {
539*11be35a1SLionel Sambuc 	att_test(tc, "basic");
540*11be35a1SLionel Sambuc }
541*11be35a1SLionel Sambuc 
542*11be35a1SLionel Sambuc ATF_TC(categorization);
ATF_TC_HEAD(categorization,tc)543*11be35a1SLionel Sambuc ATF_TC_HEAD(categorization, tc)
544*11be35a1SLionel Sambuc {
545*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests implementation categorization");
546*11be35a1SLionel Sambuc }
ATF_TC_BODY(categorization,tc)547*11be35a1SLionel Sambuc ATF_TC_BODY(categorization, tc)
548*11be35a1SLionel Sambuc {
549*11be35a1SLionel Sambuc 	att_test(tc, "categorization");
550*11be35a1SLionel Sambuc }
551*11be35a1SLionel Sambuc 
552*11be35a1SLionel Sambuc ATF_TC(nullsubexpr);
ATF_TC_HEAD(nullsubexpr,tc)553*11be35a1SLionel Sambuc ATF_TC_HEAD(nullsubexpr, tc)
554*11be35a1SLionel Sambuc {
555*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests (...)*");
556*11be35a1SLionel Sambuc }
ATF_TC_BODY(nullsubexpr,tc)557*11be35a1SLionel Sambuc ATF_TC_BODY(nullsubexpr, tc)
558*11be35a1SLionel Sambuc {
559*11be35a1SLionel Sambuc 	att_test(tc, "nullsubexpr");
560*11be35a1SLionel Sambuc }
561*11be35a1SLionel Sambuc 
562*11be35a1SLionel Sambuc ATF_TC(leftassoc);
ATF_TC_HEAD(leftassoc,tc)563*11be35a1SLionel Sambuc ATF_TC_HEAD(leftassoc, tc)
564*11be35a1SLionel Sambuc {
565*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests left-associative "
566*11be35a1SLionel Sambuc 	    "implementations");
567*11be35a1SLionel Sambuc }
ATF_TC_BODY(leftassoc,tc)568*11be35a1SLionel Sambuc ATF_TC_BODY(leftassoc, tc)
569*11be35a1SLionel Sambuc {
570*11be35a1SLionel Sambuc #if SKIP_LEFTASSOC
571*11be35a1SLionel Sambuc 	/* jmmv: I converted the original shell-based tests to C and they
572*11be35a1SLionel Sambuc 	 * disabled this test in a very unconventional way without giving
573*11be35a1SLionel Sambuc 	 * any explation.  Mark as broken here, but I don't know why. */
574*11be35a1SLionel Sambuc 	atf_tc_expect_fail("Reason for breakage unknown");
575*11be35a1SLionel Sambuc #endif
576*11be35a1SLionel Sambuc 	att_test(tc, "leftassoc");
577*11be35a1SLionel Sambuc }
578*11be35a1SLionel Sambuc 
579*11be35a1SLionel Sambuc ATF_TC(rightassoc);
ATF_TC_HEAD(rightassoc,tc)580*11be35a1SLionel Sambuc ATF_TC_HEAD(rightassoc, tc)
581*11be35a1SLionel Sambuc {
582*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests right-associative "
583*11be35a1SLionel Sambuc 	    "implementations");
584*11be35a1SLionel Sambuc }
ATF_TC_BODY(rightassoc,tc)585*11be35a1SLionel Sambuc ATF_TC_BODY(rightassoc, tc)
586*11be35a1SLionel Sambuc {
587*11be35a1SLionel Sambuc #if SKIP_RIGHTASSOC
588*11be35a1SLionel Sambuc 	/* jmmv: I converted the original shell-based tests to C and they
589*11be35a1SLionel Sambuc 	 * disabled this test in a very unconventional way without giving
590*11be35a1SLionel Sambuc 	 * any explation.  Mark as broken here, but I don't know why. */
591*11be35a1SLionel Sambuc 	atf_tc_expect_fail("Reason for breakage unknown");
592*11be35a1SLionel Sambuc #endif
593*11be35a1SLionel Sambuc 	att_test(tc, "rightassoc");
594*11be35a1SLionel Sambuc }
595*11be35a1SLionel Sambuc 
596*11be35a1SLionel Sambuc ATF_TC(forcedassoc);
ATF_TC_HEAD(forcedassoc,tc)597*11be35a1SLionel Sambuc ATF_TC_HEAD(forcedassoc, tc)
598*11be35a1SLionel Sambuc {
599*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests subexpression grouping to "
600*11be35a1SLionel Sambuc 	    "force association");
601*11be35a1SLionel Sambuc }
ATF_TC_BODY(forcedassoc,tc)602*11be35a1SLionel Sambuc ATF_TC_BODY(forcedassoc, tc)
603*11be35a1SLionel Sambuc {
604*11be35a1SLionel Sambuc 	att_test(tc, "forcedassoc");
605*11be35a1SLionel Sambuc }
606*11be35a1SLionel Sambuc 
607*11be35a1SLionel Sambuc ATF_TC(repetition);
ATF_TC_HEAD(repetition,tc)608*11be35a1SLionel Sambuc ATF_TC_HEAD(repetition, tc)
609*11be35a1SLionel Sambuc {
610*11be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Tests implicit vs. explicit "
611*11be35a1SLionel Sambuc 	    "repetition");
612*11be35a1SLionel Sambuc }
ATF_TC_BODY(repetition,tc)613*11be35a1SLionel Sambuc ATF_TC_BODY(repetition, tc)
614*11be35a1SLionel Sambuc {
615*11be35a1SLionel Sambuc 	att_test(tc, "repetition");
616*11be35a1SLionel Sambuc }
617*11be35a1SLionel Sambuc 
ATF_TP_ADD_TCS(tp)618*11be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
619*11be35a1SLionel Sambuc {
620*11be35a1SLionel Sambuc 
621*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, basic);
622*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, categorization);
623*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, nullsubexpr);
624*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, leftassoc);
625*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, rightassoc);
626*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, forcedassoc);
627*11be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, repetition);
628*11be35a1SLionel Sambuc 	return atf_no_error();
629*11be35a1SLionel Sambuc }
630