Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Sanitize the regex test cases.
details: https://anonhg.NetBSD.org/src/rev/e3357ec0aa95
branches: trunk
changeset: 781179:e3357ec0aa95
user: jmmv <jmmv%NetBSD.org@localhost>
date: Fri Aug 24 20:24:39 2012 +0000
description:
Sanitize the regex test cases.
- Merge h_regex_att (att.c) and t_regex_att.sh into a single C test program.
The former was really a test program, and the latter just a very strange
driver for it.
- Stop using awk to generate the shell test programs. This is unnecessary
and confusing. Instead, change t_regex.sh to generate the test case
functions on the fly with eval (as done in many other places).
diffstat:
distrib/sets/lists/tests/mi | 12 +-
tests/lib/libc/regex/Makefile | 19 +-
tests/lib/libc/regex/att.c | 534 ------------------------------
tests/lib/libc/regex/t_regex.awk | 59 ---
tests/lib/libc/regex/t_regex.in | 61 ---
tests/lib/libc/regex/t_regex.sh | 73 ++++
tests/lib/libc/regex/t_regex_att.c | 629 ++++++++++++++++++++++++++++++++++++
tests/lib/libc/regex/t_regex_att.in | 48 --
tests/lib/libtre/Makefile | 5 +-
9 files changed, 715 insertions(+), 725 deletions(-)
diffs (truncated from 1537 to 300 lines):
diff -r c6ded26ef0eb -r e3357ec0aa95 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Aug 24 16:37:45 2012 +0000
+++ b/distrib/sets/lists/tests/mi Fri Aug 24 20:24:39 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.488 2012/08/14 19:13:54 alnsn Exp $
+# $NetBSD: mi,v 1.489 2012/08/24 20:24:39 jmmv Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -448,7 +448,8 @@
./usr/libdata/debug/usr/tests/lib/libc/regex tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libc/regex/t_exhaust.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/regex/h_regex.debug tests-lib-debug debug,atf
-./usr/libdata/debug/usr/tests/lib/libc/regex/h_regex_att.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/regex/h_regex_att.debug tests-obsolete obsolete
+./usr/libdata/debug/usr/tests/lib/libc/regex/t_regex_att.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/rpc tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libc/rpc/t_xdr.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/setjmp tests-lib-debug
@@ -688,8 +689,9 @@
./usr/libdata/debug/usr/tests/lib/libskey tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libskey/t_algorithms.debug tests-lib-debug debug,atf,skey
./usr/libdata/debug/usr/tests/lib/libtre tests-lib-debug
-./usr/libdata/debug/usr/tests/lib/libtre/h_regex_att.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libtre/h_regex_att.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libtre/t_exhaust.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libtre/t_regex_att.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libutil tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libutil/t_efun.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libutil/t_parsedate.debug tests-lib-debug debug,atf
@@ -2347,7 +2349,7 @@
./usr/tests/lib/libc/regex/data/word_bound.in tests-lib-tests atf
./usr/tests/lib/libc/regex/data/zero.in tests-lib-tests atf
./usr/tests/lib/libc/regex/h_regex tests-lib-tests atf
-./usr/tests/lib/libc/regex/h_regex_att tests-lib-tests atf
+./usr/tests/lib/libc/regex/h_regex_att tests-obsolete obsolete
./usr/tests/lib/libc/regex/t_exhaust tests-lib-tests atf
./usr/tests/lib/libc/regex/t_regex tests-lib-tests atf
./usr/tests/lib/libc/regex/t_regex_att tests-lib-tests atf
@@ -2745,7 +2747,7 @@
./usr/tests/lib/libskey/t_algorithms tests-lib-tests atf,skey
./usr/tests/lib/libtre tests-lib-tests atf
./usr/tests/lib/libtre/Atffile tests-lib-tests atf
-./usr/tests/lib/libtre/h_regex_att tests-lib-tests atf
+./usr/tests/lib/libtre/h_regex_att tests-obsolete obsolete
./usr/tests/lib/libtre/t_exhaust tests-lib-tests atf
./usr/tests/lib/libtre/t_regex_att tests-lib-tests atf
./usr/tests/lib/libtre/data tests-lib-tests atf
diff -r c6ded26ef0eb -r e3357ec0aa95 tests/lib/libc/regex/Makefile
--- a/tests/lib/libc/regex/Makefile Fri Aug 24 16:37:45 2012 +0000
+++ b/tests/lib/libc/regex/Makefile Fri Aug 24 20:24:39 2012 +0000
@@ -1,23 +1,20 @@
-# $NetBSD: Makefile,v 1.8 2011/11/06 19:45:37 christos Exp $
+# $NetBSD: Makefile,v 1.9 2012/08/24 20:24:40 jmmv Exp $
MKMAN= no
.include <bsd.own.mk>
TESTSDIR?= ${TESTSBASE}/lib/libc/regex
-IMPLEMENTATION?= -DREGEX_SPENCER
-SKIPASSOC?= left
+IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_LEFTASSOC
BINDIR= ${TESTSDIR}
PROGS?= h_regex
-PROGS+= h_regex_att
-SRCS.h_regex_att= att.c
SRCS.h_regex= main.c split.c debug.c
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION}
TESTS_SH?= t_regex
-TESTS_SH+= t_regex_att
-TESTS_C= t_exhaust
+TESTS_C= t_regex_att
+TESTS_C+= t_exhaust
FILESDIR= ${TESTSDIR}/data
FILES+= README
@@ -49,12 +46,4 @@
FILES+= data/att/repetition.dat
FILES+= data/att/rightassoc.dat
-t_regex.sh: t_regex.awk t_regex.in
- ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}
-
-t_regex_att.sh: t_regex.awk t_regex_att.in
- ${TOOL_AWK} -v skipassoc=${SKIPASSOC} -f ${.ALLSRC} > ${.TARGET}
-
-CLEANFILES+= t_regex.sh t_regex_att.sh
-
.include <bsd.test.mk>
diff -r c6ded26ef0eb -r e3357ec0aa95 tests/lib/libc/regex/att.c
--- a/tests/lib/libc/regex/att.c Fri Aug 24 16:37:45 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,534 +0,0 @@
-/* $NetBSD: att.c,v 1.7 2011/11/06 18:32:17 christos Exp $ */
-
-/*-
- * Copyright (c) 2011 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
- *
- * 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 <sys/cdefs.h>
-__RCSID("$NetBSD: att.c,v 1.7 2011/11/06 18:32:17 christos Exp $");
-
-#include <stdio.h>
-#include <regex.h>
-#include <string.h>
-#include <stdlib.h>
-#include <vis.h>
-#include <ctype.h>
-#include <atf-c.h>
-
-ATF_TC(regex_att);
-
-ATF_TC_HEAD(regex_att, tc)
-{
-
- atf_tc_set_md_var(tc, "descr", "Driver for parsing AT&T format"
- " input files available from:"
- " http://www2.research.att.com/~gsf/testregex/");
-}
-
-static const char sep[] = "\r\n\t";
-static const char delim[3] = "\\\\\0";
-
-
-static void
-fail(const char *pattern, const char *input, size_t lineno) {
- fprintf(stderr,
- "skipping failed test at line %zu (pattern=%s, input=%s)\n",
- lineno, pattern, input);
-}
-
-static int
-bug(const char *pattern, const char *input, size_t lineno) {
- static const struct {
- const char *p;
- const char *i;
- } b[] = {
-#if defined(REGEX_SPENCER)
- /*
- * The default libc implementation by Henry Spencer
- */
- { "a[-]?c", "ac" }, // basic.dat
- { "(a*)*", "a" }, // categorization.dat
- { "(aba|a*b)*", "ababa" }, // categorization.dat
- { "\\(a\\(b\\)*\\)*\\2", "abab" }, // categorization.dat
- { "(a*)*", "aaaaaa" }, // nullsubexpression.dat
- { "(a*)*", "aaaaaax" }, // nullsubexpression.dat
- { "(a*)+", "a" }, // nullsubexpression.dat
- { "(a*)+", "aaaaaa" }, // nullsubexpression.dat
- { "(a*)+", "aaaaaax" }, // nullsubexpression.dat
- { "([a]*)*", "a" }, // nullsubexpression.dat
- { "([a]*)*", "aaaaaa" }, // nullsubexpression.dat
- { "([a]*)*", "aaaaaax" }, // nullsubexpression.dat
- { "([a]*)+", "a" }, // nullsubexpression.dat
- { "([a]*)+", "aaaaaa" }, // nullsubexpression.dat
- { "([a]*)+", "aaaaaax" }, // nullsubexpression.dat
- { "([^b]*)*", "a" }, // nullsubexpression.dat
- { "([^b]*)*", "aaaaaa" }, // nullsubexpression.dat
- { "([^b]*)*", "aaaaaab" }, // nullsubexpression.dat
- { "([ab]*)*", "a" }, // nullsubexpression.dat
- { "([ab]*)*", "aaaaaa" }, // nullsubexpression.dat
- { "([ab]*)*", "ababab" }, // nullsubexpression.dat
- { "([ab]*)*", "bababa" }, // nullsubexpression.dat
- { "([ab]*)*", "b" }, // nullsubexpression.dat
- { "([ab]*)*", "bbbbbb" }, // nullsubexpression.dat
- { "([ab]*)*", "aaaabcde" }, // nullsubexpression.dat
- { "([^a]*)*", "b" }, // nullsubexpression.dat
- { "([^a]*)*", "bbbbbb" }, // nullsubexpression.dat
- { "([^ab]*)*", "ccccxx" }, // nullsubexpression.dat
- { "\\(a*\\)*\\(x\\)", "ax" }, // nullsubexpression.dat
- { "\\(a*\\)*\\(x\\)", "axa" }, // nullsubexpression.dat
- { "\\(a*\\)*\\(x\\)\\(\\1\\)", "x" }, // nullsubexpression.dat
-/* crash! */ { "\\(a*\\)*\\(x\\)\\(\\1\\)", "ax" }, // nullsubexpression.dat
-/* crash! */ { "\\(a*\\)*\\(x\\)\\(\\1\\)\\(x\\)", "axxa" }, // ""
- { "(a*)*(x)", "ax" }, // nullsubexpression.dat
- { "(a*)*(x)", "axa" }, // nullsubexpression.dat
- { "(a*)+(x)", "ax" }, // nullsubexpression.dat
- { "(a*)+(x)", "axa" }, // nullsubexpression.dat
- { "((a|ab)(c|bcd))(d*)", "abcd" }, // forcedassoc.dat
- { "((a|ab)(bcd|c))(d*)", "abcd" }, // forcedassoc.dat
- { "((ab|a)(c|bcd))(d*)", "abcd" }, // forcedassoc.dat
- { "((ab|a)(bcd|c))(d*)", "abcd" }, // forcedassoc.dat
- { "((a*)(b|abc))(c*)", "abc" }, // forcedassoc.dat
- { "((a*)(abc|b))(c*)", "abc" }, // forcedassoc.dat
- { "((..)|(.)){2}", "aaa" }, // repetition.dat
- { "((..)|(.)){3}", "aaa" }, // repetition.dat
- { "((..)|(.)){3}", "aaaa" }, // repetition.dat
- { "((..)|(.)){3}", "aaaaa" }, // repetition.dat
- { "X(.?){0,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){1,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){2,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){3,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){4,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){5,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){6,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){7,}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){0,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){1,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){2,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){3,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){4,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){5,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){6,8}Y", "X1234567Y" }, // repetition.dat
- { "X(.?){7,8}Y", "X1234567Y" }, // repetition.dat
- { "(a|ab|c|bcd){0,}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd){1,}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd){2,}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd){3,}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd){1,10}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd){2,10}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd){3,10}(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd)*(d*)", "ababcd" }, // repetition.dat
- { "(a|ab|c|bcd)+(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){0,}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){1,}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){2,}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){3,}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){1,10}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){2,10}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd){3,10}(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd)*(d*)", "ababcd" }, // repetition.dat
- { "(ab|a|c|bcd)+(d*)", "ababcd" }, // repetition.dat
-#elif defined(REGEX_TRE)
- { "a[-]?c", "ac" }, // basic.dat
- { "a\\(b\\)*\\1", "a" }, // categorization.dat
- { "a\\(b\\)*\\1", "abab" }, // categorization.dat
- { "\\(a\\(b\\)*\\)*\\2", "abab" }, // categorization.dat
- { "\\(a*\\)*\\(x\\)\\(\\1\\)", "ax" }, // categorization.dat
- { "\\(a*\\)*\\(x\\)\\(\\1\\)\\(x\\)", "axxa" }, // ""
- { "((..)|(.))*", "aa" }, // repetition.dat
- { "((..)|(.))*", "aaa" }, // repetition.dat
- { "((..)|(.))*", "aaaaa" }, // repetition.dat
- { "X(.?){7,}Y", "X1234567Y" }, // repetition.dat
-#else
- { "", "" }
-#endif
- };
-
- for (size_t i = 0; i < __arraycount(b); i++) {
- if (strcmp(pattern, b[i].p) == 0 &&
- strcmp(input, b[i].i) == 0) {
- fail(pattern, input, lineno);
- return 1;
- }
- }
- return 0;
-}
-
-#ifdef REGEX_SPENCER
-#define HAVE_BRACES 1
-#define HAVE_MINIMAL 0
-#endif
-#ifndef HAVE_BRACES
-#define HAVE_BRACES 1
-#endif
-#ifndef HAVE_MINIMAL
-#define HAVE_MINIMAL 1
-#endif
-
-static int
-optional(const char *s)
-{
- static const struct{
- const char *n;
- int v;
Home |
Main Index |
Thread Index |
Old Index