CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Jun 9 21:09:20 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: remove the kill in the trace code. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.13 src/tests/lib/libc/regex/t_exhaust.c:1.14 --- src/tests/lib/libc/regex/t_exhaust.c:1.13 Wed Jun 9 17:08:56 2021 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Jun 9 17:09:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.14 2021/06/09 21:09:20 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.14 2021/06/09 21:09:20 christos Exp $"); #include #include @@ -74,8 +74,6 @@ malloc(size_t l) return p; q = 1; printf("%p m %zu\n", p, l); - if (p == (void *)0x7f7ff7e21ac0) - kill(0, SIGSTOP); q = 0; return p; }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Jun 9 21:08:56 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: remove not required include files To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.12 src/tests/lib/libc/regex/t_exhaust.c:1.13 --- src/tests/lib/libc/regex/t_exhaust.c:1.12 Wed Jun 9 16:48:37 2021 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Jun 9 17:08:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $"); #include #include @@ -52,17 +52,17 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.12 202 #endif #include -#include #include #include #include -#include #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE #endif #ifdef TRACE + +#include void * malloc(size_t l) {
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Jun 9 20:48:37 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: 1. Preallocate the patterns so that out of memory conditions don't happen during their allocation, which the test cannot handle properly. 2. Enable building the test without atf so that we can easily debug with atf memory allocations interfering 3. Add memory tracing (disabled) To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.11 src/tests/lib/libc/regex/t_exhaust.c:1.12 --- src/tests/lib/libc/regex/t_exhaust.c:1.11 Mon Jun 7 07:45:35 2021 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Jun 9 16:48:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,20 +37,59 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $"); #include -#include #include + +#ifdef TEST +# include +# define ATF_REQUIRE(a) assert(a) +# define ATF_REQUIRE_MSG(a, fmt, ...) \ +if (!(a)) err(EXIT_FAILURE, fmt, __VA_ARGS__) +#else +# include +#endif + #include +#include #include #include #include +#include #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE #endif +#ifdef TRACE +void * +malloc(size_t l) +{ + static void *(*m)(size_t); + static int q; + if (m == NULL) m = dlsym(RTLD_NEXT, "malloc"); + void *p = (*m)(l); + if (q) + return p; + q = 1; + printf("%p m %zu\n", p, l); + if (p == (void *)0x7f7ff7e21ac0) + kill(0, SIGSTOP); + q = 0; + return p; +} + +void +free(void *p) +{ + static void (*f)(void *); + if (f == NULL) f = dlsym(RTLD_NEXT, "malloc"); + printf("%p f\n", p); + (*f)(p); +} +#endif + static char * mkstr(const char *str, size_t len) { @@ -168,43 +207,56 @@ static const struct { { p6, REG_BASIC }, }; -ATF_TC(regcomp_too_big); - -ATF_TC_HEAD(regcomp_too_big, tc) -{ - - atf_tc_set_md_var(tc, "descr", "Check that large patterns don't" - " crash, but return a proper error code"); - // libtre needs it. - atf_tc_set_md_var(tc, "timeout", "600"); - atf_tc_set_md_var(tc, "require.memory", "256M"); -} - -ATF_TC_BODY(regcomp_too_big, tc) +static void +run(void) { regex_t re; int e; struct rlimit limit; + char *patterns[__arraycount(tests)]; + + for (size_t i = 0; i < __arraycount(patterns); i++) { + patterns[i] = (*tests[i].pattern)(REGEX_MAXSIZE); + } limit.rlim_cur = limit.rlim_max = 256 * 1024 * 1024; ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1); for (size_t i = 0; i < __arraycount(tests); i++) { - char *d = (*tests[i].pattern)(REGEX_MAXSIZE); - e = regcomp(&re, d, tests[i].type); + e = regcomp(&re, patterns[i], tests[i].type); if (e) { char ebuf[1024]; (void)regerror(e, &re, ebuf, sizeof(ebuf)); ATF_REQUIRE_MSG(e == REG_ESPACE, - "regcomp returned %d (%s) for pattern %zu [%s]", e, ebuf, - i, d); - free(d); + "regcomp returned %d (%s) for pattern %zu [%s]", e, + ebuf, i, patterns[i]); continue; } - free(d); (void)regexec(&re, "aaa", 0, NULL, 0); regfree(&re); } + for (size_t i = 0; i < __arraycount(patterns); i++) { + free(patterns[i]); + } +} + +#ifndef TEST + +ATF_TC(regcomp_too_big); + +ATF_TC_HEAD(regcomp_too_big, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Check that large patterns don't" + " crash, but return a proper error code"); + // libtre needs it. + atf_tc_set_md_var(tc, "timeout", "600"); + atf_tc_set_md_var(tc, "require.memory", "256M"); +} + +ATF_TC_BODY(regcomp_too_big, tc) +{ + run(); } ATF_TP_ADD_TCS(tp) @@ -213,3 +265,11 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, regcomp_too_big); return atf_no_error(); } +#else +int +main(void) +{ + run(); + return 0; +} +#endif
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Mon Jun 7 11:45:35 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: Add more information for the malloc failure. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.10 src/tests/lib/libc/regex/t_exhaust.c:1.11 --- src/tests/lib/libc/regex/t_exhaust.c:1.10 Tue Jul 9 09:59:25 2019 +++ src/tests/lib/libc/regex/t_exhaust.c Mon Jun 7 07:45:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.10 2019/07/09 13:59:25 gson Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.10 2019/07/09 13:59:25 gson Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $"); #include #include @@ -69,7 +69,7 @@ concat(const char *d, const char *s) size_t slen = strlen(s); char *p = malloc(dlen + slen + 1); - ATF_REQUIRE(p != NULL); + ATF_REQUIRE_MSG(p != NULL, "slen=%zu, dlen=%zu", slen, dlen); strcpy(p, d); strcpy(p + dlen, s); return p;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Thu Feb 25 22:37:37 UTC 2021 Modified Files: src/tests/lib/libc/regex: Makefile debug.c Log Message: Adjust for conditional NLS To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/regex/Makefile cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.10 src/tests/lib/libc/regex/Makefile:1.11 --- src/tests/lib/libc/regex/Makefile:1.10 Thu Aug 25 21:31:43 2016 +++ src/tests/lib/libc/regex/Makefile Thu Feb 25 17:37:36 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2016/08/26 01:31:43 darcy Exp $ +# $NetBSD: Makefile,v 1.11 2021/02/25 22:37:36 christos Exp $ NOMAN= @@ -10,7 +10,7 @@ IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_ BINDIR= ${TESTSDIR} PROGS?= h_regex SRCS.h_regex= main.c split.c debug.c -CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION} +CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION} -DNLS TESTS_SH?= t_regex TESTS_C= t_regex_att Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.6 src/tests/lib/libc/regex/debug.c:1.7 --- src/tests/lib/libc/regex/debug.c:1.6 Wed Feb 24 13:18:53 2021 +++ src/tests/lib/libc/regex/debug.c Thu Feb 25 17:37:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $ */ +/* $NetBSD: debug.c,v 1.7 2021/02/25 22:37:36 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -33,8 +33,6 @@ #include #include #include -#include -#include #ifndef __linux__ /* Don't sort these! */
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Feb 24 18:18:53 UTC 2021 Modified Files: src/tests/lib/libc/regex: debug.c Log Message: remove casts To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.5 src/tests/lib/libc/regex/debug.c:1.6 --- src/tests/lib/libc/regex/debug.c:1.5 Tue Feb 23 21:33:56 2021 +++ src/tests/lib/libc/regex/debug.c Wed Feb 24 13:18:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $ */ +/* $NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -64,9 +64,7 @@ regprint(regex_t *r, FILE *d) #ifndef REGEX_NODEBUG struct re_guts *g = r->re_g; - fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets); - fprintf(d, ", first %ld last %ld", (long)g->firststate, - (long)g->laststate); + fprintf(d, ", first %u last %u", g->firststate, g->laststate); if (g->iflags&USEBOL) fprintf(d, ", USEBOL"); if (g->iflags&USEEOL) @@ -74,14 +72,13 @@ regprint(regex_t *r, FILE *d) if (g->iflags&BAD) fprintf(d, ", BAD"); if (g->nsub > 0) - fprintf(d, ", nsub=%ld", (long)g->nsub); + fprintf(d, ", nsub=%zu", g->nsub); if (g->must != NULL) - fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen, -g->must); + fprintf(d, ", must(%zu) `%*s'", g->mlen, (int)g->mlen, g->must); if (g->backrefs) fprintf(d, ", backrefs"); if (g->nplus > 0) - fprintf(d, ", nplus %ld", (long)g->nplus); + fprintf(d, ", nplus %u", g->nplus); fprintf(d, "\n"); s_print(g, d); fprintf(d, "\n"); @@ -144,63 +141,63 @@ s_print(struct re_guts *g, FILE *d) fprintf(d, "."); break; case OANYOF: - fprintf(d, "[(%ld)", (long)opnd); + fprintf(d, "[(%u)", opnd); fprintf(d, "]"); break; case OBACK_: - fprintf(d, "(\\<%ld>", (long)opnd); + fprintf(d, "(\\<%u>", opnd); break; case O_BACK: - fprintf(d, "<%ld>\\)", (long)opnd); + fprintf(d, "<%u>\\)", opnd); break; case OPLUS_: fprintf(d, "(+"); if (OP(*(s+opnd)) != O_PLUS) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); break; case O_PLUS: if (OP(*(s-opnd)) != OPLUS_) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); fprintf(d, "+)"); break; case OQUEST_: fprintf(d, "(?"); if (OP(*(s+opnd)) != O_QUEST) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); break; case O_QUEST: if (OP(*(s-opnd)) != OQUEST_) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); fprintf(d, "?)"); break; case OLPAREN: - fprintf(d, "((<%ld>", (long)opnd); + fprintf(d, "((<%u>", opnd); break; case ORPAREN: - fprintf(d, "<%ld>))", (long)opnd); + fprintf(d, "<%u>))", opnd); break; case OCH_: fprintf(d, "<"); - if (OP(*(s+opnd)) != (sop)OOR2) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s+opnd)) != OOR2) +fprintf(d, "<%u>", opnd); break; case OOR1: - if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) +fprintf(d, "<%u>", opnd); fprintf(d, "|"); break; case OOR2: fprintf(d, "|"); - if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) +fprintf(d, "<%u>", opnd); break; case O_CH: - if (OP(*(s-opnd)) != (sop)OOR1) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s-opnd)) != OOR1) +fprintf(d, "<%u>", opnd); fprintf(d, ">"); break; default: - fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd); + fprintf(d, "!%u(%u)!", OP(*s), opnd); break; } if (!done)
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Feb 24 02:33:56 UTC 2021 Modified Files: src/tests/lib/libc/regex: debug.c Log Message: minimal fix to match the library code (really make the constants unsigned instead) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.4 src/tests/lib/libc/regex/debug.c:1.5 --- src/tests/lib/libc/regex/debug.c:1.4 Tue Feb 23 09:59:09 2021 +++ src/tests/lib/libc/regex/debug.c Tue Feb 23 21:33:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.4 2021/02/23 14:59:09 christos Exp $ */ +/* $NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -181,21 +181,21 @@ s_print(struct re_guts *g, FILE *d) break; case OCH_: fprintf(d, "<"); - if (OP(*(s+opnd)) != OOR2) + if (OP(*(s+opnd)) != (sop)OOR2) fprintf(d, "<%ld>", (long)opnd); break; case OOR1: - if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) + if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_) fprintf(d, "<%ld>", (long)opnd); fprintf(d, "|"); break; case OOR2: fprintf(d, "|"); - if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) + if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH) fprintf(d, "<%ld>", (long)opnd); break; case O_CH: - if (OP(*(s-opnd)) != OOR1) + if (OP(*(s-opnd)) != (sop)OOR1) fprintf(d, "<%ld>", (long)opnd); fprintf(d, ">"); break;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 17:13:44 UTC 2021 Modified Files: src/tests/lib/libc/regex: main.c Log Message: Add REG_GNU To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/main.c diff -u src/tests/lib/libc/regex/main.c:1.3 src/tests/lib/libc/regex/main.c:1.4 --- src/tests/lib/libc/regex/main.c:1.3 Tue Feb 23 10:00:01 2021 +++ src/tests/lib/libc/regex/main.c Tue Feb 23 12:13:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $ */ +/* $NetBSD: main.c,v 1.4 2021/02/23 17:13:44 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -352,7 +352,7 @@ options(int type, char *s) { char *p; int o = (type == 'c') ? copts : eopts; - const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl"; + const char *legal = (type == 'c') ? "bisnmpg" : "^$#tl"; for (p = s; *p != '\0'; p++) if (strchr(legal, *p) != NULL) @@ -376,8 +376,8 @@ options(int type, char *s) case 'p': o |= REG_PEND; break; - case 'P': -o |= REG_POSIX; + case 'g': +o |= REG_GNU; break; case '^': o |= REG_NOTBOL;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 16:00:37 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_regex_att.c Log Message: Add support for ENOSYS (was never set) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/t_regex_att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_regex_att.c diff -u src/tests/lib/libc/regex/t_regex_att.c:1.3 src/tests/lib/libc/regex/t_regex_att.c:1.4 --- src/tests/lib/libc/regex/t_regex_att.c:1.3 Sat Jan 14 15:59:23 2017 +++ src/tests/lib/libc/regex/t_regex_att.c Tue Feb 23 11:00:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.4 2021/02/23 16:00:37 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $"); +__RCSID("$NetBSD: t_regex_att.c,v 1.4 2021/02/23 16:00:37 christos Exp $"); #include @@ -284,7 +284,12 @@ geterror(const char *s, int *comp, int * _DO(EMPTY, COMP) _DO(ASSERT, COMP) _DO(INVARG, COMP) +#ifdef REG_ENOSYS _DO(ENOSYS, COMP) +#endif +#ifdef REG_ILLSEQ + _DO(ILLSEQ, COMP) +#endif #undef _DO }; *comp = 0;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 15:00:01 UTC 2021 Modified Files: src/tests/lib/libc/regex: main.c Log Message: Add REG_POSIX, and make compile on linux where we don't have a lot of the internal flags. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/main.c diff -u src/tests/lib/libc/regex/main.c:1.2 src/tests/lib/libc/regex/main.c:1.3 --- src/tests/lib/libc/regex/main.c:1.2 Fri Sep 16 12:13:18 2011 +++ src/tests/lib/libc/regex/main.c Tue Feb 23 10:00:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.2 2011/09/16 16:13:18 plunky Exp $ */ +/* $NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -52,6 +52,16 @@ static char empty = '\0'; static char *eprint(int); static int efind(char *); +#ifndef REG_ATOI +#define REG_ATOI 0 +#define REG_ITOA 0 +#define REG_PEND 0 +#define REG_TRACE 0 +#define REG_BACKR 0 +#define REG_NOSPEC 0 +#define REG_LARGE 0 +#endif + /* * main - do the simple case, hand off to regress() for regression */ @@ -72,7 +82,7 @@ main(int argc, char *argv[]) progname = argv[0]; - while ((c = getopt(argc, argv, "c:e:S:E:x")) != -1) + while ((c = getopt(argc, argv, "c:E:e:S:x")) != -1) switch (c) { case 'c': /* compile options */ copts = options('c', optarg); @@ -80,12 +90,12 @@ main(int argc, char *argv[]) case 'e': /* execute options */ eopts = options('e', optarg); break; - case 'S': /* start offset */ - startoff = (regoff_t)atoi(optarg); - break; case 'E': /* end offset */ endoff = (regoff_t)atoi(optarg); break; + case 'S': /* start offset */ + startoff = (regoff_t)atoi(optarg); + break; case 'x': /* Debugging. */ debug++; break; @@ -211,7 +221,9 @@ regress(FILE *in) erbuf, bpname); status = 1; } +#if REG_ATOI re.re_endp = bpname; +#endif ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf)); if (atoi(erbuf) != (int)REG_BADPAT) { fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n", @@ -247,7 +259,9 @@ try(char *f0, char *f1, char *f2, char * char f2copy[1000]; strcpy(f0copy, f0); +#if REG_ATOI re.re_endp = (optsĀ®_PEND) ? f0copy + strlen(f0copy) : NULL; +#endif fixstr(f0copy); err = regcomp(&re, f0copy, opts); if (err != 0 && (!opt('C', f1) || err != efind(f2))) { @@ -338,7 +352,7 @@ options(int type, char *s) { char *p; int o = (type == 'c') ? copts : eopts; - const char *legal = (type == 'c') ? "bisnmp" : "^$#tl"; + const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl"; for (p = s; *p != '\0'; p++) if (strchr(legal, *p) != NULL) @@ -362,6 +376,9 @@ options(int type, char *s) case 'p': o |= REG_PEND; break; + case 'P': +o |= REG_POSIX; +break; case '^': o |= REG_NOTBOL; break; @@ -517,7 +534,9 @@ efind(char *name) sprintf(efbuf, "REG_%s", name); assert(strlen(efbuf) < sizeof(efbuf)); +#if REG_ATOI re.re_endp = efbuf; +#endif (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf)); return(atoi(efbuf)); }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 14:59:09 UTC 2021 Modified Files: src/tests/lib/libc/regex: debug.c Log Message: Delete category stuff that has changed with the new regex; make compile on linux and with TRE To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.3 src/tests/lib/libc/regex/debug.c:1.4 --- src/tests/lib/libc/regex/debug.c:1.3 Fri Jan 13 19:50:56 2017 +++ src/tests/lib/libc/regex/debug.c Tue Feb 23 09:59:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.3 2017/01/14 00:50:56 christos Exp $ */ +/* $NetBSD: debug.c,v 1.4 2021/02/23 14:59:09 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -36,14 +36,24 @@ #include #include +#ifndef __linux__ /* Don't sort these! */ #include "utils.h" #include "regex2.h" +#else +#define REGEX_NODEBUG +#endif + +#ifdef REGEX_TRE +#define REGEX_NODEBUG +#endif #include "test_regex.h" +#ifndef REGEX_NODEBUG static void s_print(struct re_guts *, FILE *); static char *regchar(int); +#endif /* * regprint - print a regexp for debugging @@ -51,13 +61,10 @@ static char *regchar(int); void regprint(regex_t *r, FILE *d) { +#ifndef REGEX_NODEBUG struct re_guts *g = r->re_g; - int c; - int last; - int nincat[NC]; - fprintf(d, "%ld states, %zu categories", (long)g->nstates, - g->ncategories); + fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets); fprintf(d, ", first %ld last %ld", (long)g->firststate, (long)g->laststate); if (g->iflags&USEBOL) @@ -77,43 +84,11 @@ regprint(regex_t *r, FILE *d) fprintf(d, ", nplus %ld", (long)g->nplus); fprintf(d, "\n"); s_print(g, d); - for (size_t i = 0; i < g->ncategories; i++) { - nincat[i] = 0; - for (c = CHAR_MIN; c <= CHAR_MAX; c++) - if (g->categories[c] == i) -nincat[i]++; - } - fprintf(d, "cc0#%d", nincat[0]); - for (size_t i = 1; i < g->ncategories; i++) - if (nincat[i] == 1) { - for (c = CHAR_MIN; c <= CHAR_MAX; c++) -if (g->categories[c] == i) - break; - fprintf(d, ", %zu=%s", i, regchar(c)); - } fprintf(d, "\n"); - for (size_t i = 1; i < g->ncategories; i++) - if (nincat[i] != 1) { - fprintf(d, "cc%zu\t", i); - last = -1; - for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */ -if (c <= CHAR_MAX && g->categories[c] == i) { - if (last < 0) { - fprintf(d, "%s", regchar(c)); - last = c; - } -} else { - if (last >= 0) { - if (last != c-1) - fprintf(d, "-%s", -regchar(c-1)); - last = -1; - } -} - fprintf(d, "\n"); - } +#endif } +#ifndef REGEX_NODEBUG /* * s_print - print the strip for debugging */ @@ -121,11 +96,9 @@ static void s_print(struct re_guts *g, FILE *d) { sop *s; - cset *cs; int done = 0; sop opnd; int col = 0; - ssize_t last; sopno offset = 2; # define GAP() { if (offset % 5 == 0) { \ if (col > 40) { \ @@ -172,22 +145,6 @@ s_print(struct re_guts *g, FILE *d) break; case OANYOF: fprintf(d, "[(%ld)", (long)opnd); - cs = &g->sets[opnd]; - last = -1; - for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */ -if (CHIN(cs, i) && i < g->csetsize) { - if (last < 0) { - fprintf(d, "%s", regchar(i)); - last = i; - } -} else { - if (last >= 0) { - if (last != (ssize_t)i - 1) - fprintf(d, "-%s", - regchar(i - 1)); - last = -1; - } -} fprintf(d, "]"); break; case OBACK_: @@ -243,7 +200,7 @@ s_print(struct re_guts *g, FILE *d) fprintf(d, ">"); break; default: - fprintf(d, "!%d(%d)!", OP(*s), opnd); + fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd); break; } if (!done) @@ -265,3 +222,4 @@ regchar(int ch) sprintf(buf, "\\%o", ch); return(buf); } +#endif
CVS commit: src/tests/lib/libc/regex/data
Module Name:src Committed By: christos Date: Tue Feb 23 14:57:16 UTC 2021 Modified Files: src/tests/lib/libc/regex/data: meta.in repet_bounded.in repet_multi.in Log Message: Comment out tests that the new stricter regex does not like To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/data/meta.in \ src/tests/lib/libc/regex/data/repet_bounded.in \ src/tests/lib/libc/regex/data/repet_multi.in Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/data/meta.in diff -u src/tests/lib/libc/regex/data/meta.in:1.1 src/tests/lib/libc/regex/data/meta.in:1.2 --- src/tests/lib/libc/regex/data/meta.in:1.1 Sat Jan 8 13:10:32 2011 +++ src/tests/lib/libc/regex/data/meta.in Tue Feb 23 09:57:16 2021 @@ -4,7 +4,8 @@ a[bc]d & abd abd a\*c & a*c a*c a\\b & a\b a\b a\\\*b & a\*b a\*b -a\bc & abc abc +# legacy escape +#a\bc & abc abc a\ &C EESCAPE a\\bc & a\bc a\bc \{ bC BADRPT Index: src/tests/lib/libc/regex/data/repet_bounded.in diff -u src/tests/lib/libc/regex/data/repet_bounded.in:1.1 src/tests/lib/libc/regex/data/repet_bounded.in:1.2 --- src/tests/lib/libc/regex/data/repet_bounded.in:1.1 Sat Jan 8 13:10:32 2011 +++ src/tests/lib/libc/regex/data/repet_bounded.in Tue Feb 23 09:57:16 2021 @@ -1,9 +1,10 @@ # the dreaded bounded repetitions -{ & { { -{abc & {abc {abc +# unclosed and with missing values are now errors +#{ & { { +#{abc & {abc {abc {1 C BADRPT {1} C BADRPT -a{b & a{b a{b +#a{b & a{b a{b a{1}b - ab ab a\{1\}b b ab ab a{1,}b - ab ab @@ -16,9 +17,9 @@ a{1a C EBRACE a\{1a bC EBRACE a{1a} C BADBR a\{1a\} bC BADBR -a{,2} - a{,2} a{,2} +#a{,2} - a{,2} a{,2} a\{,2\} bC BADBR -a{,} - a{,} a{,} +#a{,} - a{,} a{,} a\{,\} bC BADBR a{1,x} C BADBR a\{1,x\} bC BADBR Index: src/tests/lib/libc/regex/data/repet_multi.in diff -u src/tests/lib/libc/regex/data/repet_multi.in:1.1 src/tests/lib/libc/regex/data/repet_multi.in:1.2 --- src/tests/lib/libc/regex/data/repet_multi.in:1.1 Sat Jan 8 13:10:32 2011 +++ src/tests/lib/libc/regex/data/repet_multi.in Tue Feb 23 09:57:16 2021 @@ -15,7 +15,8 @@ a?{1} C BADRPT a{1}* C BADRPT a{1}+ C BADRPT a{1}? C BADRPT -a*{b} - a{b} a{b} +# repetition needs to be a number +#a*{b} - a{b} a{b} a\{1\}\{1\} bC BADRPT a*\{1\} bC BADRPT a\{1\}* bC BADRPT
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sat Mar 16 21:57:15 UTC 2019 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: PR/54061: Bump memory for jemalloc (a lot). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.8 src/tests/lib/libc/regex/t_exhaust.c:1.9 --- src/tests/lib/libc/regex/t_exhaust.c:1.8 Fri Jan 13 19:50:56 2017 +++ src/tests/lib/libc/regex/t_exhaust.c Sat Mar 16 17:57:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.9 2019/03/16 21:57:15 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.9 2019/03/16 21:57:15 christos Exp $"); #include #include @@ -56,7 +56,7 @@ mkstr(const char *str, size_t len) { size_t slen = strlen(str); char *p = malloc(slen * len + 1); - ATF_REQUIRE(p != NULL); + ATF_REQUIRE_MSG(p != NULL, "slen=%zu, len=%zu", slen, len); for (size_t i = 0; i < len; i++) strcpy(&p[i * slen], str); return p; @@ -183,11 +183,12 @@ ATF_TC_HEAD(regcomp_too_big, tc) ATF_TC_BODY(regcomp_too_big, tc) { regex_t re; - struct rlimit limit; int e; + struct rlimit limit; - limit.rlim_cur = limit.rlim_max = 64 * 1024 * 1024; + limit.rlim_cur = limit.rlim_max = 256 * 1024 * 1024; ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1); + for (size_t i = 0; i < __arraycount(tests); i++) { char *d = (*tests[i].pattern)(REGEX_MAXSIZE); e = regcomp(&re, d, tests[i].type);
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sat Jan 14 20:59:23 UTC 2017 Modified Files: src/tests/lib/libc/regex: t_regex_att.c Log Message: PR/51873: Ngie Cooper: add util.h #include To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/t_regex_att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_regex_att.c diff -u src/tests/lib/libc/regex/t_regex_att.c:1.2 src/tests/lib/libc/regex/t_regex_att.c:1.3 --- src/tests/lib/libc/regex/t_regex_att.c:1.2 Fri Jan 13 19:50:56 2017 +++ src/tests/lib/libc/regex/t_regex_att.c Sat Jan 14 15:59:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,17 +37,18 @@ */ #include -__RCSID("$NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $"); +__RCSID("$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $"); #include -#include +#include +#include #include -#include +#include #include +#include +#include #include -#include -#include static const char sep[] = "\r\n\t"; static const char delim[3] = "\0";
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sat Jan 14 00:50:56 UTC 2017 Modified Files: src/tests/lib/libc/regex: debug.c t_exhaust.c t_regex_att.c Log Message: PR/51832: Ngie Cooper: - limit memory to 64M - error msg fixes - includes fixes To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/debug.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/regex/t_exhaust.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/t_regex_att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.2 src/tests/lib/libc/regex/debug.c:1.3 --- src/tests/lib/libc/regex/debug.c:1.2 Mon Oct 10 00:32:41 2011 +++ src/tests/lib/libc/regex/debug.c Fri Jan 13 19:50:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.2 2011/10/10 04:32:41 christos Exp $ */ +/* $NetBSD: debug.c,v 1.3 2017/01/14 00:50:56 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -26,14 +26,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include #include #include #include - -#include +#include +#include /* Don't sort these! */ #include "utils.h" Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.7 src/tests/lib/libc/regex/t_exhaust.c:1.8 --- src/tests/lib/libc/regex/t_exhaust.c:1.7 Wed Nov 16 13:37:31 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Fri Jan 13 19:50:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,14 +37,15 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $"); -#include +#include +#include +#include #include -#include +#include #include -#include -#include +#include #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE @@ -176,14 +177,17 @@ ATF_TC_HEAD(regcomp_too_big, tc) " crash, but return a proper error code"); // libtre needs it. atf_tc_set_md_var(tc, "timeout", "600"); - atf_tc_set_md_var(tc, "require.memory", "120M"); + atf_tc_set_md_var(tc, "require.memory", "64M"); } ATF_TC_BODY(regcomp_too_big, tc) { regex_t re; + struct rlimit limit; int e; + limit.rlim_cur = limit.rlim_max = 64 * 1024 * 1024; + ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1); for (size_t i = 0; i < __arraycount(tests); i++) { char *d = (*tests[i].pattern)(REGEX_MAXSIZE); e = regcomp(&re, d, tests[i].type); Index: src/tests/lib/libc/regex/t_regex_att.c diff -u src/tests/lib/libc/regex/t_regex_att.c:1.1 src/tests/lib/libc/regex/t_regex_att.c:1.2 --- src/tests/lib/libc/regex/t_regex_att.c:1.1 Fri Aug 24 16:24:40 2012 +++ src/tests/lib/libc/regex/t_regex_att.c Fri Jan 13 19:50:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $"); +__RCSID("$NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $"); #include @@ -374,7 +374,7 @@ checkmatches(const char *matches, size_t " cur=%d, max=%zu", res, l, len - off); off += l; } - ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno); + ATF_CHECK_STREQ_MSG(res, matches, " at line %zu", lineno); free(res); }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Nov 16 18:37:31 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: this works with much less memory too. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.6 src/tests/lib/libc/regex/t_exhaust.c:1.7 --- src/tests/lib/libc/regex/t_exhaust.c:1.6 Wed Nov 16 12:47:19 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Nov 16 13:37:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.6 2011/11/16 17:47:19 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.6 2011/11/16 17:47:19 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $"); #include #include @@ -176,7 +176,7 @@ ATF_TC_HEAD(regcomp_too_big, tc) " crash, but return a proper error code"); // libtre needs it. atf_tc_set_md_var(tc, "timeout", "600"); - atf_tc_set_md_var(tc, "require.memory", "500M"); + atf_tc_set_md_var(tc, "require.memory", "120M"); } ATF_TC_BODY(regcomp_too_big, tc)
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Nov 16 17:47:19 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: add require.memory=500M To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.5 src/tests/lib/libc/regex/t_exhaust.c:1.6 --- src/tests/lib/libc/regex/t_exhaust.c:1.5 Wed Nov 9 10:14:44 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Nov 16 12:47:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.5 2011/11/09 15:14:44 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.6 2011/11/16 17:47:19 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.5 2011/11/09 15:14:44 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.6 2011/11/16 17:47:19 christos Exp $"); #include #include @@ -176,6 +176,7 @@ ATF_TC_HEAD(regcomp_too_big, tc) " crash, but return a proper error code"); // libtre needs it. atf_tc_set_md_var(tc, "timeout", "600"); + atf_tc_set_md_var(tc, "require.memory", "500M"); } ATF_TC_BODY(regcomp_too_big, tc)
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Nov 9 15:14:44 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: add a large timeout for libtre To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.4 src/tests/lib/libc/regex/t_exhaust.c:1.5 --- src/tests/lib/libc/regex/t_exhaust.c:1.4 Sun Nov 6 13:34:48 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Nov 9 10:14:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.4 2011/11/06 18:34:48 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.5 2011/11/09 15:14:44 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.4 2011/11/06 18:34:48 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.5 2011/11/09 15:14:44 christos Exp $"); #include #include @@ -174,6 +174,8 @@ ATF_TC_HEAD(regcomp_too_big, tc) atf_tc_set_md_var(tc, "descr", "Check that large patterns don't" " crash, but return a proper error code"); + // libtre needs it. + atf_tc_set_md_var(tc, "timeout", "600"); } ATF_TC_BODY(regcomp_too_big, tc)
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 19:45:37 UTC 2011 Modified Files: src/tests/lib/libc/regex: Makefile Log Message: make the standard tests optional. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/regex/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.7 src/tests/lib/libc/regex/Makefile:1.8 --- src/tests/lib/libc/regex/Makefile:1.7 Sun Nov 6 13:35:22 2011 +++ src/tests/lib/libc/regex/Makefile Sun Nov 6 14:45:37 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 2011/11/06 18:35:22 christos Exp $ +# $NetBSD: Makefile,v 1.8 2011/11/06 19:45:37 christos Exp $ MKMAN= no @@ -9,12 +9,13 @@ IMPLEMENTATION?= -DREGEX_SPENCER SKIPASSOC?= left BINDIR= ${TESTSDIR} -PROGS+= h_regex h_regex_att +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 TESTS_SH+= t_regex_att TESTS_C= t_exhaust
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 18:35:22 UTC 2011 Modified Files: src/tests/lib/libc/regex: Makefile Log Message: skip the association that does not match with our implementation. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/regex/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.6 src/tests/lib/libc/regex/Makefile:1.7 --- src/tests/lib/libc/regex/Makefile:1.6 Sun Nov 6 12:02:33 2011 +++ src/tests/lib/libc/regex/Makefile Sun Nov 6 13:35:22 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2011/11/06 17:02:33 christos Exp $ +# $NetBSD: Makefile,v 1.7 2011/11/06 18:35:22 christos Exp $ MKMAN= no @@ -6,6 +6,7 @@ MKMAN= no TESTSDIR?= ${TESTSBASE}/lib/libc/regex IMPLEMENTATION?= -DREGEX_SPENCER +SKIPASSOC?= left BINDIR= ${TESTSDIR} PROGS+= h_regex h_regex_att @@ -51,7 +52,7 @@ 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} -f ${.ALLSRC} > ${.TARGET} + ${TOOL_AWK} -v skipassoc=${SKIPASSOC} -f ${.ALLSRC} > ${.TARGET} CLEANFILES+= t_regex.sh t_regex_att.sh
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 18:34:48 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: - Print the symbolic error using regerror, as well as the pattern that caused it. - Add the ability to set the number of repetitions in the pattern from cpp since TRE handles things poorly: - It runs the machine out of memory with rep=9 (we use rep=) - It truncates the pattern with rep= To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.3 src/tests/lib/libc/regex/t_exhaust.c:1.4 --- src/tests/lib/libc/regex/t_exhaust.c:1.3 Fri Nov 4 11:48:10 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Sun Nov 6 13:34:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.3 2011/11/04 15:48:10 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.4 2011/11/06 18:34:48 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.3 2011/11/04 15:48:10 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.4 2011/11/06 18:34:48 christos Exp $"); #include #include @@ -46,6 +46,9 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.3 2011 #include #include +#ifndef REGEX_MAXSIZE +#define REGEX_MAXSIZE +#endif static char * mkstr(const char *str, size_t len) @@ -179,14 +182,18 @@ ATF_TC_BODY(regcomp_too_big, tc) int e; for (size_t i = 0; i < __arraycount(tests); i++) { - char *d = (*tests[i].pattern)(); + char *d = (*tests[i].pattern)(REGEX_MAXSIZE); e = regcomp(&re, d, tests[i].type); - free(d); if (e) { + char ebuf[1024]; + (void)regerror(e, &re, ebuf, sizeof(ebuf)); ATF_REQUIRE_MSG(e == REG_ESPACE, - "regcomp returned %d for pattern %zu", e, i); + "regcomp returned %d (%s) for pattern %zu [%s]", e, ebuf, + i, d); + free(d); continue; } + free(d); (void)regexec(&re, "aaa", 0, NULL, 0); regfree(&re); }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 18:32:39 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_regex.awk Log Message: ability to select associativity To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/t_regex.awk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_regex.awk diff -u src/tests/lib/libc/regex/t_regex.awk:1.1 src/tests/lib/libc/regex/t_regex.awk:1.2 --- src/tests/lib/libc/regex/t_regex.awk:1.1 Sat Jan 8 13:10:31 2011 +++ src/tests/lib/libc/regex/t_regex.awk Sun Nov 6 13:32:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_regex.awk,v 1.1 2011/01/08 18:10:31 pgoyette Exp $ +# $NetBSD: t_regex.awk,v 1.2 2011/11/06 18:32:39 christos Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -48,6 +48,8 @@ BEGIN { /^tc_list/ { for (i = 0; i < count; i++) { + if (skipassoc != "" && index(tcs[i], skipassoc) != 0) + continue; printf(" atf_add_test_case %s\n", tcs[i]); }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 18:32:17 UTC 2011 Modified Files: src/tests/lib/libc/regex: att.c Log Message: - Handle TRE - Make BUG comments print. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/att.c diff -u src/tests/lib/libc/regex/att.c:1.6 src/tests/lib/libc/regex/att.c:1.7 --- src/tests/lib/libc/regex/att.c:1.6 Sun Nov 6 11:43:25 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 13:32:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: att.c,v 1.6 2011/11/06 16:43:25 christos Exp $ */ +/* $NetBSD: att.c,v 1.7 2011/11/06 18:32:17 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: att.c,v 1.6 2011/11/06 16:43:25 christos Exp $"); +__RCSID("$NetBSD: att.c,v 1.7 2011/11/06 18:32:17 christos Exp $"); #include #include @@ -74,7 +74,7 @@ bug(const char *pattern, const char *inp const char *p; const char *i; } b[] = { -#ifdef REGEX_SPENCER +#if defined(REGEX_SPENCER) /* * The default libc implementation by Henry Spencer */ @@ -159,6 +159,19 @@ bug(const char *pattern, const char *inp { "(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 + { "((..)|(.))*", "a" }, // repetition.dat + { "X(.?){7,}Y", "X1234567Y" }, // repetition.dat +#else + { "", "" } #endif }; @@ -210,6 +223,7 @@ static int unsupported(const char *s) { static const char *we[] = { +#if defined(REGEX_SPENCER) "ASSOCIATIVITY=left", // have right associativity "SUBEXPRESSION=precedence", // have grouping subexpression "REPEAT_LONGEST=last", // have first repeat longest @@ -222,6 +236,19 @@ unsupported(const char *s) "BUG=repeat-null", // don't have it "BUG=repeat-artifact", // don't have it "BUG=subexpression-first", // don't have it +#elif defined(REGEX_TRE) + "ASSOCIATIVITY=right", // have left associativity + "SUBEXPRESSION=grouping", // have precedence subexpression + "REPEAT_LONGEST=first", // have last repeat longest + "LENGTH=first", // have last length + "BUG=alternation-order", // don't have it + "BUG=first-match", // don't have it + "BUG=range-null", // don't have it + "BUG=repeat-null", // don't have it + "BUG=repeat-artifact", // don't have it + "BUG=subexpression-first", // don't have it + "BUG=repeat-short", // don't have it +#endif }; if (s == NULL) @@ -327,6 +354,13 @@ getmatches(const char *s) } static void +checkcomment(const char *s, size_t lineno) +{ + if (s && strstr(s, "BUG") != NULL) + fprintf(stderr, "Expected %s at line %zu\n", s, lineno); +} + +static void checkmatches(const char *matches, size_t nm, const regmatch_t *pm, size_t lineno) { @@ -485,6 +519,7 @@ ATF_TC_BODY(regex_att, tc) ATF_REQUIRE_MSG(e == exec, "Expected error %d," " got %d at line %zu", exec, e, lineno); checkmatches(matches, nm, pm, lineno); + checkcomment(comment, lineno); regfree(&re); } free(pm);
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 18:31:30 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_regex_att.in Log Message: leave all tests in and have the awk script select which ones are appropriate. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/t_regex_att.in Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_regex_att.in diff -u src/tests/lib/libc/regex/t_regex_att.in:1.1 src/tests/lib/libc/regex/t_regex_att.in:1.2 --- src/tests/lib/libc/regex/t_regex_att.in:1.1 Sun Nov 6 12:02:33 2011 +++ src/tests/lib/libc/regex/t_regex_att.in Sun Nov 6 13:31:30 2011 @@ -1,5 +1,5 @@ #! /usr/bin/atf-sh -# $NetBSD: t_regex_att.in,v 1.1 2011/11/06 17:02:33 christos Exp $ +# $NetBSD: t_regex_att.in,v 1.2 2011/11/06 18:31:30 christos Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,7 +37,7 @@ h_check() tc:basic:Tests basic functionality tc:categorization:Tests implementation categorization tc:nullsubexpr:Tests (...)* -# tc:leftassoc:Tests left-associative implementations +tc:leftassoc:Tests left-associative implementations tc:rightassoc:Tests right-associative implementations tc:forcedassoc:Tests subexpression grouping to force association tc:repetition:Tests implicit vs. explicit repetition
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 17:02:33 UTC 2011 Modified Files: src/tests/lib/libc/regex: Makefile Added Files: src/tests/lib/libc/regex: t_regex_att.in Log Message: Add the AT&T regex tests To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/regex/t_regex_att.in Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.5 src/tests/lib/libc/regex/Makefile:1.6 --- src/tests/lib/libc/regex/Makefile:1.5 Sat Nov 5 19:33:15 2011 +++ src/tests/lib/libc/regex/Makefile Sun Nov 6 12:02:33 2011 @@ -1,17 +1,20 @@ -# $NetBSD: Makefile,v 1.5 2011/11/05 23:33:15 christos Exp $ +# $NetBSD: Makefile,v 1.6 2011/11/06 17:02:33 christos Exp $ MKMAN= no .include TESTSDIR?= ${TESTSBASE}/lib/libc/regex +IMPLEMENTATION?= -DREGEX_SPENCER BINDIR= ${TESTSDIR} -PROGS+= h_regex +PROGS+= h_regex h_regex_att +SRCS.h_regex_att= att.c SRCS.h_regex= main.c split.c debug.c -CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex +CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION} TESTS_SH= t_regex +TESTS_SH+= t_regex_att TESTS_C= t_exhaust FILESDIR= ${TESTSDIR}/data @@ -35,10 +38,21 @@ FILES+= data/subexp.in FILES+= data/subtle.in FILES+= data/word_bound.in FILES+= data/zero.in +#FILES+= data/att/README +FILES+= data/att/basic.dat +FILES+= data/att/categorization.dat +FILES+= data/att/forcedassoc.dat +FILES+= data/att/leftassoc.dat +FILES+= data/att/nullsubexpr.dat +FILES+= data/att/repetition.dat +FILES+= data/att/rightassoc.dat t_regex.sh: t_regex.awk t_regex.in ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} -CLEANFILES+= t_regex.sh +t_regex_att.sh: t_regex.awk t_regex_att.in + ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} + +CLEANFILES+= t_regex.sh t_regex_att.sh .include Added files: Index: src/tests/lib/libc/regex/t_regex_att.in diff -u /dev/null src/tests/lib/libc/regex/t_regex_att.in:1.1 --- /dev/null Sun Nov 6 12:02:33 2011 +++ src/tests/lib/libc/regex/t_regex_att.in Sun Nov 6 12:02:33 2011 @@ -0,0 +1,48 @@ +#! /usr/bin/atf-sh +# $NetBSD: t_regex_att.in,v 1.1 2011/11/06 17:02:33 christos Exp $ +# +# Copyright (c) 2008 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. +# +# 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. +# + +h_check() +{ + prog="$(atf_get_srcdir)/h_regex_att" + data="$(atf_get_srcdir)/data/$1.dat" + + atf_check -o match:passed -e ignore -x "${prog} regex_att <${data}" +} + +tc:basic:Tests basic functionality +tc:categorization:Tests implementation categorization +tc:nullsubexpr:Tests (...)* +# tc:leftassoc:Tests left-associative implementations +tc:rightassoc:Tests right-associative implementations +tc:forcedassoc:Tests subexpression grouping to force association +tc:repetition:Tests implicit vs. explicit repetition + +atf_init_test_cases() +{ +tc_list +}
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 16:43:25 UTC 2011 Modified Files: src/tests/lib/libc/regex: att.c Log Message: be less chatty. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/att.c diff -u src/tests/lib/libc/regex/att.c:1.5 src/tests/lib/libc/regex/att.c:1.6 --- src/tests/lib/libc/regex/att.c:1.5 Sun Nov 6 11:26:54 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 11:43:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: att.c,v 1.5 2011/11/06 16:26:54 christos Exp $ */ +/* $NetBSD: att.c,v 1.6 2011/11/06 16:43:25 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: att.c,v 1.5 2011/11/06 16:26:54 christos Exp $"); +__RCSID("$NetBSD: att.c,v 1.6 2011/11/06 16:43:25 christos Exp $"); #include #include @@ -364,8 +364,9 @@ ATF_TC_BODY(regex_att, tc) char *name, *pattern, *input, *matches, *comment; regmatch_t *pm; size_t nm; - +#ifdef DEBUG fprintf(stderr, "[%s]\n", line); +#endif if ((name = strtok(line, sep)) == NULL) continue;
CVS commit: src/tests/lib/libc/regex/att
Module Name:src Committed By: christos Date: Sun Nov 6 16:41:03 UTC 2011 Removed Files: src/tests/lib/libc/regex/att: README basic.dat categorization.dat forcedassoc.dat leftassoc.dat nullsubexpr.dat repetition.dat rightassoc.dat Log Message: moved below To generate a diff of this commit: cvs rdiff -u -r1.1 -r0 src/tests/lib/libc/regex/att/README \ src/tests/lib/libc/regex/att/basic.dat \ src/tests/lib/libc/regex/att/categorization.dat \ src/tests/lib/libc/regex/att/forcedassoc.dat \ src/tests/lib/libc/regex/att/leftassoc.dat \ src/tests/lib/libc/regex/att/nullsubexpr.dat \ src/tests/lib/libc/regex/att/repetition.dat \ src/tests/lib/libc/regex/att/rightassoc.dat Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/regex/data/att
Module Name:src Committed By: christos Date: Sun Nov 6 16:40:37 UTC 2011 Added Files: src/tests/lib/libc/regex/data/att: README basic.dat categorization.dat forcedassoc.dat leftassoc.dat nullsubexpr.dat repetition.dat rightassoc.dat Log Message: moved because we cannot have multiple FILESDIR To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/regex/data/att/README \ src/tests/lib/libc/regex/data/att/basic.dat \ src/tests/lib/libc/regex/data/att/categorization.dat \ src/tests/lib/libc/regex/data/att/forcedassoc.dat \ src/tests/lib/libc/regex/data/att/leftassoc.dat \ src/tests/lib/libc/regex/data/att/nullsubexpr.dat \ src/tests/lib/libc/regex/data/att/repetition.dat \ src/tests/lib/libc/regex/data/att/rightassoc.dat Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/lib/libc/regex/data/att/README diff -u /dev/null src/tests/lib/libc/regex/data/att/README:1.1 --- /dev/null Sun Nov 6 11:40:37 2011 +++ src/tests/lib/libc/regex/data/att/README Sun Nov 6 11:40:37 2011 @@ -0,0 +1,8 @@ +AT&T test data from: http://www2.research.att.com/~gsf/testregex/ + +Quoting from the page: +testregex.c 2004-05-31 is the latest source for the AT&T Research +regression test harness for the X/Open regex pattern match interface. +See testregex(1) for option and test input details. The source and +test data posted here are license free. + Index: src/tests/lib/libc/regex/data/att/basic.dat diff -u /dev/null src/tests/lib/libc/regex/data/att/basic.dat:1.1 --- /dev/null Sun Nov 6 11:40:37 2011 +++ src/tests/lib/libc/regex/data/att/basic.dat Sun Nov 6 11:40:37 2011 @@ -0,0 +1,216 @@ +NOTE all standard compliant implementations should pass these : 2002-05-31 + +BE abracadabra$ abracadabracadabra (7,18) +BE a...b abababbb (2,7) +BE XX ..XX (2,8) +E \) () (1,2) +BE a] a]a (0,2) +B } } (0,1) +E \} } (0,1) +BE \] ] (0,1) +B ] ] (0,1) +E ] ] (0,1) +B { { (0,1) +B } } (0,1) +BE ^a ax (0,1) +BE \^a a^a (1,3) +BE a\^ a^ (0,2) +BE a$ aa (1,2) +BE a\$ a$ (0,2) +BE ^$ NULL (0,0) +E $^ NULL (0,0) +E a($) aa (1,2)(2,2) +E a*(^a) aa (0,1)(0,1) +E (..)*(...)* a (0,0) +E (..)*(...)* abcd (0,4)(2,4) +E (ab|a)(bc|c) abc (0,3)(0,2)(2,3) +E (ab)c|abc abc (0,3)(0,2) +E a{0}b ab (1,2) +E (a*)(b?)(b+)b{3} aaabbb (0,10)(0,3)(3,4)(4,7) +E (a*)(b{0,1})(b{1,})b{3} aaabbb (0,10)(0,3)(3,4)(4,7) +E a{9876543210} NULL BADBR +E ((a|a)|a) a (0,1)(0,1)(0,1) +E (a*)(a|aa) (0,4)(0,3)(3,4) +E a*(a.|aa) (0,4)(2,4) +E a(b)|c(d)|a(e)f aef (0,3)(?,?)(?,?)(1,2) +E (a|b)?.* b (0,1)(0,1) +E (a|b)c|a(b|c) ac (0,2)(0,1) +E (a|b)c|a(b|c) ab (0,2)(?,?)(1,2) +E (a|b)*c|(a|ab)*c abc (0,3)(1,2) +E (a|b)*c|(a|ab)*c xc (1,2) +E (.a|.b).*|.*(.a|.b) xa (0,2)(0,2) +E a?(ab|ba)ab abab (0,4)(0,2) +E a?(ac{0}b|ba)ab abab (0,4)(0,2) +E ab|abababbabab (0,2) +E aba|bab|bba baaabbbaba (5,8) +E aba|babbaaabbbaba (6,9) +E (aa|aaa)*|(a|a) aa (0,2)(0,2) +E (a.|.a.)*|(a|.a...) aa (0,2)(0,2) +E ab|axabc (1,3) +E ab|axxabc (2,4) +Ei (Ab|cD)* aBcD (0,4)(2,4) +BE [^-] --a (2,3) +BE [a-]* --a (0,3) +BE [a-m-]* --amoma-- (0,4) +E :::1:::0:|:::1:1:0: :::0:::1:::1:::0: (8,17) +E :::1:::0:|:::1:1:1: :::0:::1:::1:::0: (8,17) +{E [[:upper:]] A (0,1) [[]] not supported +E [[:lower:]]+ `az{ (1,3) +E [[:upper:]]+ @AZ[ (1,3) +BE [[-]] [[-]] (2,4) +BE [[.NIL.]] NULL ECOLLATE +BE [[=aleph=]] NULL ECOLLATE +} +BE$ \n \n (0,1) +BEn$ \n \n (0,1) +BE$ [^a] \n (0,1) +BE$ \na \na (0,2) +E (a)(b)(c) abc (0,3)(0,1)(1,2)(2,3) +BE xxx xxx (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 6, (0,6) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) 2/7 (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 1,Feb 6 (5,11) +E3 ((x)) x (0,1)(0,1)(0,1) +E3 ((x))* xx (0,2)(1,2)(1,2) +E a?(ab|ba)* ababababababababababababababababababababababababababababababababababababababababa (0,81)(79,81) +E abaa|abbaa|abbbaa|aaa ababbabbbabbbaaaa (18,25) +E abaa|abbaa|abbbaa|aaa ababbabbbabbbaabaa (18,22) +E aaac|aabc|abac|abbc|baac|babc|bbac|bbbc baaabbbabac (7,11) +BE$ .* \x01\xff (0,2) +E |||d|ee|fff|||i|j|k| XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaX (53,57) +L \n\n\nd\nee\nfff\n\n\ni\nj\nk\n XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaX NOMATCH +E a*a*a*a*a*b ab (0,10) +BE ^ NULL (0,0) +BE $ NULL (0,0) +BE ^$ NULL (0,0) +BE ^a$ a (0,1) +BE abc abc (0,3) +BE abc xabcy (1,4) +BE abc ababc (2,5) +BE ab*c abc (0,3) +BE ab*bc abc (0,3) +BE ab*bc abbc (0,4) +BE ab*bc abb
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 16:26:54 UTC 2011 Modified Files: src/tests/lib/libc/regex: att.c Log Message: more failed tests, perhaps I should move the data to a file, but how do you open a file in ATF? To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/att.c diff -u src/tests/lib/libc/regex/att.c:1.4 src/tests/lib/libc/regex/att.c:1.5 --- src/tests/lib/libc/regex/att.c:1.4 Sun Nov 6 11:08:28 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 11:26:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: att.c,v 1.4 2011/11/06 16:08:28 christos Exp $ */ +/* $NetBSD: att.c,v 1.5 2011/11/06 16:26:54 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: att.c,v 1.4 2011/11/06 16:08:28 christos Exp $"); +__RCSID("$NetBSD: att.c,v 1.5 2011/11/06 16:26:54 christos Exp $"); #include #include @@ -121,6 +121,44 @@ bug(const char *pattern, const char *inp { "((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}", "" }, // repetition.dat + { "((..)|(.)){3}", "a" }, // 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 #endif }; @@ -342,8 +380,15 @@ ATF_TC_BODY(regex_att, tc) } if (skipping) continue; - if (*name == ';' || strcmp(name, "NOTE") == 0) + if (*name == ';' || *name == '#' || strcmp(name, "NOTE") == 0) continue; + if (*name == ':') { + /* Skip ":HA#???:" prefix */ + while (*++name && *name != ':') +continue; + if (*name) +name++; + } ATF_REQUIRE_MSG((pattern = strtok(NULL, sep)) != NULL, "Missing pattern at line %zu", lineno); @@ -388,6 +433,7 @@ ATF_TC_BODY(regex_att, tc) continue; name++; /* We have it, so ignore */ break; + case '#': /* Comment */ case ';': /* Skip */ continue; default:
CVS commit: src/tests/lib/libc/regex/att
Module Name:src Committed By: christos Date: Sun Nov 6 16:26:20 UTC 2011 Added Files: src/tests/lib/libc/regex/att: README basic.dat categorization.dat forcedassoc.dat leftassoc.dat nullsubexpr.dat repetition.dat rightassoc.dat Log Message: Add tests from: http://www2.research.att.com/~gsf/testregex/ To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/regex/att/README \ src/tests/lib/libc/regex/att/basic.dat \ src/tests/lib/libc/regex/att/categorization.dat \ src/tests/lib/libc/regex/att/forcedassoc.dat \ src/tests/lib/libc/regex/att/leftassoc.dat \ src/tests/lib/libc/regex/att/nullsubexpr.dat \ src/tests/lib/libc/regex/att/repetition.dat \ src/tests/lib/libc/regex/att/rightassoc.dat Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/lib/libc/regex/att/README diff -u /dev/null src/tests/lib/libc/regex/att/README:1.1 --- /dev/null Sun Nov 6 11:26:20 2011 +++ src/tests/lib/libc/regex/att/README Sun Nov 6 11:26:20 2011 @@ -0,0 +1,8 @@ +AT&T test data from: http://www2.research.att.com/~gsf/testregex/ + +Quoting from the page: +testregex.c 2004-05-31 is the latest source for the AT&T Research +regression test harness for the X/Open regex pattern match interface. +See testregex(1) for option and test input details. The source and +test data posted here are license free. + Index: src/tests/lib/libc/regex/att/basic.dat diff -u /dev/null src/tests/lib/libc/regex/att/basic.dat:1.1 --- /dev/null Sun Nov 6 11:26:20 2011 +++ src/tests/lib/libc/regex/att/basic.dat Sun Nov 6 11:26:20 2011 @@ -0,0 +1,216 @@ +NOTE all standard compliant implementations should pass these : 2002-05-31 + +BE abracadabra$ abracadabracadabra (7,18) +BE a...b abababbb (2,7) +BE XX ..XX (2,8) +E \) () (1,2) +BE a] a]a (0,2) +B } } (0,1) +E \} } (0,1) +BE \] ] (0,1) +B ] ] (0,1) +E ] ] (0,1) +B { { (0,1) +B } } (0,1) +BE ^a ax (0,1) +BE \^a a^a (1,3) +BE a\^ a^ (0,2) +BE a$ aa (1,2) +BE a\$ a$ (0,2) +BE ^$ NULL (0,0) +E $^ NULL (0,0) +E a($) aa (1,2)(2,2) +E a*(^a) aa (0,1)(0,1) +E (..)*(...)* a (0,0) +E (..)*(...)* abcd (0,4)(2,4) +E (ab|a)(bc|c) abc (0,3)(0,2)(2,3) +E (ab)c|abc abc (0,3)(0,2) +E a{0}b ab (1,2) +E (a*)(b?)(b+)b{3} aaabbb (0,10)(0,3)(3,4)(4,7) +E (a*)(b{0,1})(b{1,})b{3} aaabbb (0,10)(0,3)(3,4)(4,7) +E a{9876543210} NULL BADBR +E ((a|a)|a) a (0,1)(0,1)(0,1) +E (a*)(a|aa) (0,4)(0,3)(3,4) +E a*(a.|aa) (0,4)(2,4) +E a(b)|c(d)|a(e)f aef (0,3)(?,?)(?,?)(1,2) +E (a|b)?.* b (0,1)(0,1) +E (a|b)c|a(b|c) ac (0,2)(0,1) +E (a|b)c|a(b|c) ab (0,2)(?,?)(1,2) +E (a|b)*c|(a|ab)*c abc (0,3)(1,2) +E (a|b)*c|(a|ab)*c xc (1,2) +E (.a|.b).*|.*(.a|.b) xa (0,2)(0,2) +E a?(ab|ba)ab abab (0,4)(0,2) +E a?(ac{0}b|ba)ab abab (0,4)(0,2) +E ab|abababbabab (0,2) +E aba|bab|bba baaabbbaba (5,8) +E aba|babbaaabbbaba (6,9) +E (aa|aaa)*|(a|a) aa (0,2)(0,2) +E (a.|.a.)*|(a|.a...) aa (0,2)(0,2) +E ab|axabc (1,3) +E ab|axxabc (2,4) +Ei (Ab|cD)* aBcD (0,4)(2,4) +BE [^-] --a (2,3) +BE [a-]* --a (0,3) +BE [a-m-]* --amoma-- (0,4) +E :::1:::0:|:::1:1:0: :::0:::1:::1:::0: (8,17) +E :::1:::0:|:::1:1:1: :::0:::1:::1:::0: (8,17) +{E [[:upper:]] A (0,1) [[]] not supported +E [[:lower:]]+ `az{ (1,3) +E [[:upper:]]+ @AZ[ (1,3) +BE [[-]] [[-]] (2,4) +BE [[.NIL.]] NULL ECOLLATE +BE [[=aleph=]] NULL ECOLLATE +} +BE$ \n \n (0,1) +BEn$ \n \n (0,1) +BE$ [^a] \n (0,1) +BE$ \na \na (0,2) +E (a)(b)(c) abc (0,3)(0,1)(1,2)(2,3) +BE xxx xxx (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 6, (0,6) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) 2/7 (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 1,Feb 6 (5,11) +E3 ((x)) x (0,1)(0,1)(0,1) +E3 ((x))* xx (0,2)(1,2)(1,2) +E a?(ab|ba)* ababababababababababababababababababababababababababababababababababababababababa (0,81)(79,81) +E abaa|abbaa|abbbaa|aaa ababbabbbabbbaaaa (18,25) +E abaa|abbaa|abbbaa|aaa ababbabbbabbbaabaa (18,22) +E aaac|aabc|abac|abbc|baac|babc|bbac|bbbc baaabbbabac (7,11) +BE$ .* \x01\xff (0,2) +E |||d|ee|fff|||i|j|k| XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaX (53,57) +L \n\n\nd\nee\nfff\n\n\ni\nj\nk\n XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaX NOMATCH +E a*a*a*a*a*b ab (0,10) +BE ^ NULL (0,0) +BE $ NULL (0,0) +BE ^$ NULL (0,0) +BE ^a$ a (0,1) +BE abc abc (0,3) +BE abc xabcy (1,4) +BE abc ababc (2,5) +BE ab*c abc (0,3) +BE ab*bc abc (0,3) +BE ab*bc abbc (0,4) +BE ab*bc ac (0,6) +E ab+bc abbc (0,4) +E ab+bc ac (0,6) +E
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 16:08:29 UTC 2011 Modified Files: src/tests/lib/libc/regex: att.c Log Message: Add the failed forced association tests. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/att.c diff -u src/tests/lib/libc/regex/att.c:1.3 src/tests/lib/libc/regex/att.c:1.4 --- src/tests/lib/libc/regex/att.c:1.3 Sun Nov 6 11:02:08 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 11:08:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: att.c,v 1.3 2011/11/06 16:02:08 christos Exp $ */ +/* $NetBSD: att.c,v 1.4 2011/11/06 16:08:28 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: att.c,v 1.3 2011/11/06 16:02:08 christos Exp $"); +__RCSID("$NetBSD: att.c,v 1.4 2011/11/06 16:08:28 christos Exp $"); #include #include @@ -115,6 +115,12 @@ bug(const char *pattern, const char *inp { "(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 #endif };
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 16:02:08 UTC 2011 Modified Files: src/tests/lib/libc/regex: att.c Log Message: Add the nullsubexpression tests. We mostly fail or don't support them. Two of the tests actually cause the regex library to enter infinite recursion. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/att.c diff -u src/tests/lib/libc/regex/att.c:1.2 src/tests/lib/libc/regex/att.c:1.3 --- src/tests/lib/libc/regex/att.c:1.2 Sun Nov 6 10:19:31 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 11:02:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: att.c,v 1.2 2011/11/06 15:19:31 christos Exp $ */ +/* $NetBSD: att.c,v 1.3 2011/11/06 16:02:08 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: att.c,v 1.2 2011/11/06 15:19:31 christos Exp $"); +__RCSID("$NetBSD: att.c,v 1.3 2011/11/06 16:02:08 christos Exp $"); #include #include @@ -60,34 +60,6 @@ ATF_TC_HEAD(regex_att, tc) static const char sep[] = "\r\n\t"; static const char delim[3] = "\0"; -static const struct { - const char *n; - int v; - int ce; -#define COMP 1 -#define EXEC 2 -} nv[] = { - { "OK", 0, COMP|EXEC }, -#define _DO(a, b) { # a, REG_ ## a, b }, - _DO(NOMATCH, EXEC) - _DO(BADPAT, COMP) - _DO(ECOLLATE, COMP) - _DO(ECTYPE, COMP) - _DO(EESCAPE, COMP) - _DO(ESUBREG, COMP) - _DO(EBRACK, COMP) - _DO(EPAREN, COMP) - _DO(EBRACE, COMP) - _DO(BADBR, COMP) - _DO(ERANGE, COMP) - _DO(ESPACE, EXEC) - _DO(BADRPT, COMP) - _DO(EMPTY, COMP) - _DO(ASSERT, COMP) - _DO(INVARG, COMP) - _DO(ENOSYS, COMP) -#undef _DO -}; static void fail(const char *pattern, const char *input, size_t lineno) { @@ -106,10 +78,43 @@ bug(const char *pattern, const char *inp /* * 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[-]?c", "ac" }, // basic.dat + { "(a*)*", "a" }, // categorization.dat + { "(aba|a*b)*", "ababa" }, // categorization.dat + { "\\(a\\(b\\)*\\)*\\2", "abab" }, // categorization.dat + { "(a*)*", "aa" }, // nullsubexpression.dat + { "(a*)*", "aax" }, // nullsubexpression.dat + { "(a*)+", "a" }, // nullsubexpression.dat + { "(a*)+", "aa" }, // nullsubexpression.dat + { "(a*)+", "aax" }, // nullsubexpression.dat + { "([a]*)*", "a" }, // nullsubexpression.dat + { "([a]*)*", "aa" }, // nullsubexpression.dat + { "([a]*)*", "aax" }, // nullsubexpression.dat + { "([a]*)+", "a" }, // nullsubexpression.dat + { "([a]*)+", "aa" }, // nullsubexpression.dat + { "([a]*)+", "aax" }, // nullsubexpression.dat + { "([^b]*)*", "a" }, // nullsubexpression.dat + { "([^b]*)*", "aa" }, // nullsubexpression.dat + { "([^b]*)*", "aab" }, // nullsubexpression.dat + { "([ab]*)*", "a" }, // nullsubexpression.dat + { "([ab]*)*", "aa" }, // nullsubexpression.dat + { "([ab]*)*", "ababab" }, // nullsubexpression.dat + { "([ab]*)*", "bababa" }, // nullsubexpression.dat + { "([ab]*)*", "b" }, // nullsubexpression.dat + { "([ab]*)*", "bb" }, // nullsubexpression.dat + { "([ab]*)*", "bcde" }, // nullsubexpression.dat + { "([^a]*)*", "b" }, // nullsubexpression.dat + { "([^a]*)*", "bb" }, // nullsubexpression.dat + { "([^ab]*)*", "xx" }, // 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 #endif }; @@ -123,6 +128,40 @@ bug(const char *pattern, const char *inp 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; + } nv[]= { + { "[[]] not supported", HAVE_BRACES }, + { "no *? +? mimimal match ops", HAVE_MINIMAL }, + }; + + for (size_t i = 0; i < __arraycount(nv); i++) + if (strcmp(nv[i].n, s) == 0) { + if (nv[i].v) +return 0; + fprintf(stderr, "skipping unsupported [%s] tests\n", s); + return 1; + } + + ATF_REQUIRE_MSG(0, "Unknown feature: %s", s); + return 0; +} + stat
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 15:19:31 UTC 2011 Modified Files: src/tests/lib/libc/regex: att.c Log Message: Add a bug section so we can skip tests that don't work. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/att.c diff -u src/tests/lib/libc/regex/att.c:1.1 src/tests/lib/libc/regex/att.c:1.2 --- src/tests/lib/libc/regex/att.c:1.1 Sun Nov 6 09:23:04 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 10:19:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: att.c,v 1.1 2011/11/06 14:23:04 christos Exp $ */ +/* $NetBSD: att.c,v 1.2 2011/11/06 15:19:31 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,16 +37,16 @@ */ #include -__RCSID("$NetBSD: att.c,v 1.1 2011/11/06 14:23:04 christos Exp $"); +__RCSID("$NetBSD: att.c,v 1.2 2011/11/06 15:19:31 christos Exp $"); #include #include #include #include #include +#include #include - ATF_TC(regex_att); ATF_TC_HEAD(regex_att, tc) @@ -58,6 +58,7 @@ ATF_TC_HEAD(regex_att, tc) } static const char sep[] = "\r\n\t"; +static const char delim[3] = "\0"; static const struct { const char *n; @@ -66,6 +67,7 @@ static const struct { #define COMP 1 #define EXEC 2 } nv[] = { + { "OK", 0, COMP|EXEC }, #define _DO(a, b) { # a, REG_ ## a, b }, _DO(NOMATCH, EXEC) _DO(BADPAT, COMP) @@ -88,6 +90,70 @@ static const struct { }; 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[] = { +#ifdef 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 +#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; +} + +static int +unsupported(const char *s) +{ + static const char *we[] = { + "ASSOCIATIVITY=left", // have right associativity + "SUBEXPRESSION=precedence", // have grouping subexpression + "REPEAT_LONGEST=last", // have first repeat longest + "BUG=alternation-order", // don't have it + "BUG=first-match", // don't have it + "BUG=nomatch-match", // don't have it + "BUG=repeat-any", // don't have it + "BUG=range-null", // don't have it + "BUG=repeat-null-unknown", // don't have it + "BUG=repeat-null", // don't have it + "BUG=repeat-artifact", // don't have it + "BUG=subexpression-first", // don't have it + }; + + if (s == NULL) + return 0; + + while (*s == '#' || isspace((unsigned char)*s)) + s++; + + for (size_t i = 0; i < __arraycount(we); i++) + if (strcmp(we[i], s) == 0) + return 1; + return 0; +} + +static void geterror(const char *s, int *comp, int *exec) { *comp = 0; @@ -150,7 +216,8 @@ getmatches(const char *s) } static void -checkmatches(const char *matches, size_t nm, const regmatch_t *pm) +checkmatches(const char *matches, size_t nm, const regmatch_t *pm, +size_t lineno) { if (nm == 0) return; @@ -170,7 +237,7 @@ checkmatches(const char *matches, size_t " cur=%d, max=%zu", res, l, len - off); off += l; } - ATF_REQUIRE_STREQ(res, matches); + ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno); free(res); } @@ -180,9 +247,9 @@ ATF_TC_BODY(regex_att, tc) char *line; size_t len, lineno = 0; - for (; (line = fparseln(stdin, &len, &lineno, NULL, 0)) + for (; (line = fparseln(stdin, &len, &lineno, delim, 0)) != NULL; free(line)) { - char *name, *pattern, *input, *matches; + char *name, *pattern, *input, *matches, *comment; regmatch_t *pm; size_t nm; @@ -190,13 +257,9 @@ ATF_TC_BODY(regex_att, tc) if ((name = strtok(line, sep)) == NULL) continue; - if (strcmp(name, "NOTE") == 0) + if (*name == ';' || *name == '}' || strcmp(name, "NOTE") == 0) continue; - if (*name == '{') - name++; - if (*name == '}') - continue; ATF_REQUIRE_MSG((pattern = strtok(NULL, sep)) != NULL, "Missing pattern at line %zu", lineno); @@ -214,6 +277,29 @@ ATF_TC_BODY(regex_att, tc) ATF_REQUIRE_MSG((matches = strtok(NULL, sep)) != NULL, "Missing matches at line %zu", lineno); + comment = strtok(NULL, sep); + switch (*name) { + case '{': /* Begin optional implementation */ + name++; /* We have it, so ignore */ + break; + case '}': /* End optional implementation */ + continue; + case '?': /* Optional */ + cas
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Nov 6 14:23:04 UTC 2011 Added Files: src/tests/lib/libc/regex: att.c Log Message: Add a test harness for the att data files: http://www2.research.att.com/~gsf/testregex/ Not part of the build yet. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/regex/att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/lib/libc/regex/att.c diff -u /dev/null src/tests/lib/libc/regex/att.c:1.1 --- /dev/null Sun Nov 6 09:23:04 2011 +++ src/tests/lib/libc/regex/att.c Sun Nov 6 09:23:04 2011 @@ -0,0 +1,276 @@ +/* $NetBSD: att.c,v 1.1 2011/11/06 14:23:04 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 +__RCSID("$NetBSD: att.c,v 1.1 2011/11/06 14:23:04 christos Exp $"); + +#include +#include +#include +#include +#include +#include + + +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 struct { + const char *n; + int v; + int ce; +#define COMP 1 +#define EXEC 2 +} nv[] = { +#define _DO(a, b) { # a, REG_ ## a, b }, + _DO(NOMATCH, EXEC) + _DO(BADPAT, COMP) + _DO(ECOLLATE, COMP) + _DO(ECTYPE, COMP) + _DO(EESCAPE, COMP) + _DO(ESUBREG, COMP) + _DO(EBRACK, COMP) + _DO(EPAREN, COMP) + _DO(EBRACE, COMP) + _DO(BADBR, COMP) + _DO(ERANGE, COMP) + _DO(ESPACE, EXEC) + _DO(BADRPT, COMP) + _DO(EMPTY, COMP) + _DO(ASSERT, COMP) + _DO(INVARG, COMP) + _DO(ENOSYS, COMP) +#undef _DO +}; + +static void +geterror(const char *s, int *comp, int *exec) +{ + *comp = 0; + *exec = 0; + for (size_t i = 0; i < __arraycount(nv); i++) + if (strcmp(s, nv[i].n) == 0) { + if (nv[i].ce & COMP) +*comp = nv[i].v; + if (nv[i].ce & EXEC) +*exec = nv[i].v; + return; + } + ATF_REQUIRE_MSG(0, "Unknown error %s", s); + return; +} + +static int +getflags(char *s) +{ + int flags = 0; + + for (;; s++) + switch (*s) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + *s = '\0'; + break; + case '\0': + return flags; + case 'B': + case 'E': + case 'F': + case 'L': + break; + case 'i': + flags |= REG_ICASE; + *s = '\0'; + break; + case '$': + *s = '\0'; + break; + case 'n': + *s = '\0'; + break; + default: + ATF_REQUIRE_MSG(0, "Unknown char %c", *s); + break; + } +} + +static size_t +getmatches(const char *s) +{ + size_t i; + char *q; + for (i = 0; (q = strchr(s, '(')) != NULL; i++, s = q + 1) + continue; + ATF_REQUIRE_MSG(i != 0, "No parentheses found"); + return i; +} + +static void +checkmatches(const char *matches, size_t nm, const regmatch_t *pm) +{ + if (nm == 0) + return; + + char *res; + size_t len = strlen(matches) + 1, off = 0; + + ATF_REQUIRE((res = strdup(matches)) != NULL); + for (size_t i = 0; i < nm; i++) {
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sat Nov 5 23:33:15 UTC 2011 Modified Files: src/tests/lib/libc/regex: Makefile Log Message: Arrange so that the same tests can be used by libtre. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/regex/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.4 src/tests/lib/libc/regex/Makefile:1.5 --- src/tests/lib/libc/regex/Makefile:1.4 Tue Oct 11 19:04:21 2011 +++ src/tests/lib/libc/regex/Makefile Sat Nov 5 19:33:15 2011 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.4 2011/10/11 23:04:21 dholland Exp $ +# $NetBSD: Makefile,v 1.5 2011/11/05 23:33:15 christos Exp $ MKMAN= no .include -TESTSDIR= ${TESTSBASE}/lib/libc/regex +TESTSDIR?= ${TESTSBASE}/lib/libc/regex BINDIR= ${TESTSDIR} PROGS+= h_regex @@ -37,7 +37,7 @@ FILES+= data/word_bound.in FILES+= data/zero.in t_regex.sh: t_regex.awk t_regex.in - ${TOOL_AWK} -f ${.CURDIR}/t_regex.awk ${.CURDIR}/t_regex.in > ${.TARGET} + ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} CLEANFILES+= t_regex.sh
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Fri Nov 4 15:48:10 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: stylistic improvements. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.2 src/tests/lib/libc/regex/t_exhaust.c:1.3 --- src/tests/lib/libc/regex/t_exhaust.c:1.2 Thu Oct 20 20:41:34 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Fri Nov 4 11:48:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.2 2011/10/21 00:41:34 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.3 2011/11/04 15:48:10 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.2 2011/10/21 00:41:34 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.3 2011/11/04 15:48:10 christos Exp $"); #include #include @@ -52,8 +52,7 @@ mkstr(const char *str, size_t len) { size_t slen = strlen(str); char *p = malloc(slen * len + 1); - if (p == NULL) - err(1, "malloc"); + ATF_REQUIRE(p != NULL); for (size_t i = 0; i < len; i++) strcpy(&p[i * slen], str); return p; @@ -65,6 +64,8 @@ concat(const char *d, const char *s) size_t dlen = strlen(d); size_t slen = strlen(s); char *p = malloc(dlen + slen + 1); + + ATF_REQUIRE(p != NULL); strcpy(p, d); strcpy(p + dlen, s); return p; @@ -150,14 +151,17 @@ p6(size_t len) return d; } -static char *(*patterns[])(size_t) = { - p0, - p1, - p2, - p3, - p4, - p5, - p6, +static const struct { + char *(*pattern)(size_t); + int type; +} tests[] = { + { p0, REG_EXTENDED }, + { p1, REG_EXTENDED }, + { p2, REG_EXTENDED }, + { p3, REG_EXTENDED }, + { p4, REG_EXTENDED }, + { p5, REG_EXTENDED }, + { p6, REG_BASIC }, }; ATF_TC(regcomp_too_big); @@ -174,16 +178,16 @@ ATF_TC_BODY(regcomp_too_big, tc) regex_t re; int e; - for (size_t i = 0; i < __arraycount(patterns); i++) { - char *d = (*patterns[i])(); - e = regcomp(&re, d, i == 6 ? REG_BASIC : REG_EXTENDED); + for (size_t i = 0; i < __arraycount(tests); i++) { + char *d = (*tests[i].pattern)(); + e = regcomp(&re, d, tests[i].type); free(d); if (e) { ATF_REQUIRE_MSG(e == REG_ESPACE, "regcomp returned %d for pattern %zu", e, i); continue; } - (void)regexec(&re, "", 0, NULL, 0); + (void)regexec(&re, "aaa", 0, NULL, 0); regfree(&re); } }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Fri Oct 21 00:41:35 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: simplify. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.1 src/tests/lib/libc/regex/t_exhaust.c:1.2 --- src/tests/lib/libc/regex/t_exhaust.c:1.1 Sun Oct 9 14:21:08 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Thu Oct 20 20:41:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.1 2011/10/09 18:21:08 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.2 2011/10/21 00:41:34 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.1 2011/10/09 18:21:08 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.2 2011/10/21 00:41:34 christos Exp $"); #include #include @@ -178,12 +178,12 @@ ATF_TC_BODY(regcomp_too_big, tc) char *d = (*patterns[i])(); e = regcomp(&re, d, i == 6 ? REG_BASIC : REG_EXTENDED); free(d); - if (e != 0) + if (e) { ATF_REQUIRE_MSG(e == REG_ESPACE, "regcomp returned %d for pattern %zu", e, i); - if (e) continue; - e = regexec(&re, "", 0, NULL, 0); + } + (void)regexec(&re, "", 0, NULL, 0); regfree(&re); } }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Mon Oct 10 04:32:42 UTC 2011 Modified Files: src/tests/lib/libc/regex: Makefile debug.c Log Message: - Use PROGS instead of PROG so that we can co-exist with TESTS_C - Make the helper program compile again. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.2 src/tests/lib/libc/regex/Makefile:1.3 --- src/tests/lib/libc/regex/Makefile:1.2 Sun Oct 9 14:21:08 2011 +++ src/tests/lib/libc/regex/Makefile Mon Oct 10 00:32:41 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2011/10/09 18:21:08 christos Exp $ +# $NetBSD: Makefile,v 1.3 2011/10/10 04:32:41 christos Exp $ MKMAN= no @@ -7,8 +7,8 @@ MKMAN= no TESTSDIR= ${TESTSBASE}/lib/libc/regex BINDIR= ${TESTSDIR} -PROG= h_regex -SRCS= main.c split.c debug.c +PROGS+= h_regex +SRCS.h_regex= main.c split.c debug.c CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex TESTS_SH= t_regex Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.1 src/tests/lib/libc/regex/debug.c:1.2 --- src/tests/lib/libc/regex/debug.c:1.1 Sat Jan 8 13:10:31 2011 +++ src/tests/lib/libc/regex/debug.c Mon Oct 10 00:32:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.1 2011/01/08 18:10:31 pgoyette Exp $ */ +/* $NetBSD: debug.c,v 1.2 2011/10/10 04:32:41 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -51,12 +51,11 @@ void regprint(regex_t *r, FILE *d) { struct re_guts *g = r->re_g; - int i; int c; int last; int nincat[NC]; - fprintf(d, "%ld states, %d categories", (long)g->nstates, + fprintf(d, "%ld states, %zu categories", (long)g->nstates, g->ncategories); fprintf(d, ", first %ld last %ld", (long)g->firststate, (long)g->laststate); @@ -77,24 +76,24 @@ regprint(regex_t *r, FILE *d) fprintf(d, ", nplus %ld", (long)g->nplus); fprintf(d, "\n"); s_print(g, d); - for (i = 0; i < g->ncategories; i++) { + for (size_t i = 0; i < g->ncategories; i++) { nincat[i] = 0; for (c = CHAR_MIN; c <= CHAR_MAX; c++) if (g->categories[c] == i) nincat[i]++; } fprintf(d, "cc0#%d", nincat[0]); - for (i = 1; i < g->ncategories; i++) + for (size_t i = 1; i < g->ncategories; i++) if (nincat[i] == 1) { for (c = CHAR_MIN; c <= CHAR_MAX; c++) if (g->categories[c] == i) break; - fprintf(d, ", %d=%s", i, regchar(c)); + fprintf(d, ", %zu=%s", i, regchar(c)); } fprintf(d, "\n"); - for (i = 1; i < g->ncategories; i++) + for (size_t i = 1; i < g->ncategories; i++) if (nincat[i] != 1) { - fprintf(d, "cc%d\t", i); + fprintf(d, "cc%zu\t", i); last = -1; for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */ if (c <= CHAR_MAX && g->categories[c] == i) { @@ -122,11 +121,10 @@ s_print(struct re_guts *g, FILE *d) { sop *s; cset *cs; - int i; int done = 0; sop opnd; int col = 0; - int last; + ssize_t last; sopno offset = 2; # define GAP() { if (offset % 5 == 0) { \ if (col > 40) { \ @@ -175,7 +173,7 @@ s_print(struct re_guts *g, FILE *d) fprintf(d, "[(%ld)", (long)opnd); cs = &g->sets[opnd]; last = -1; - for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */ + for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */ if (CHIN(cs, i) && i < g->csetsize) { if (last < 0) { fprintf(d, "%s", regchar(i)); @@ -183,9 +181,9 @@ s_print(struct re_guts *g, FILE *d) } } else { if (last >= 0) { - if (last != i-1) + if (last != (ssize_t)i - 1) fprintf(d, "-%s", -regchar(i-1)); + regchar(i - 1)); last = -1; } }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Sun Oct 9 18:21:09 UTC 2011 Modified Files: src/tests/lib/libc/regex: Makefile Added Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: Add a test to check for DoS attacks against regcomp/regexec. From Maksymilian Arciemowicz. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.1 src/tests/lib/libc/regex/Makefile:1.2 --- src/tests/lib/libc/regex/Makefile:1.1 Sat Jan 8 20:00:40 2011 +++ src/tests/lib/libc/regex/Makefile Sun Oct 9 14:21:08 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2011/01/09 01:00:40 pgoyette Exp $ +# $NetBSD: Makefile,v 1.2 2011/10/09 18:21:08 christos Exp $ MKMAN= no @@ -12,6 +12,7 @@ SRCS= main.c split.c debug.c CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex TESTS_SH= t_regex +TESTS_C= t_exhaust FILESDIR= ${TESTSDIR}/data FILES+= README Added files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u /dev/null src/tests/lib/libc/regex/t_exhaust.c:1.1 --- /dev/null Sun Oct 9 14:21:09 2011 +++ src/tests/lib/libc/regex/t_exhaust.c Sun Oct 9 14:21:08 2011 @@ -0,0 +1,196 @@ +/* $NetBSD: t_exhaust.c,v 1.1 2011/10/09 18:21:08 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 +__RCSID("$NetBSD: t_exhaust.c,v 1.1 2011/10/09 18:21:08 christos Exp $"); + +#include +#include +#include +#include +#include +#include + + +static char * +mkstr(const char *str, size_t len) +{ + size_t slen = strlen(str); + char *p = malloc(slen * len + 1); + if (p == NULL) + err(1, "malloc"); + for (size_t i = 0; i < len; i++) + strcpy(&p[i * slen], str); + return p; +} + +static char * +concat(const char *d, const char *s) +{ + size_t dlen = strlen(d); + size_t slen = strlen(s); + char *p = malloc(dlen + slen + 1); + strcpy(p, d); + strcpy(p + dlen, s); + return p; +} + +static char * +p0(size_t len) +{ + char *d, *s1, *s2; + s1 = mkstr("\\(", len); + s2 = concat(s1, ")"); + free(s1); + d = concat("(", s2); + free(s2); + return d; +} + +static char * +p1(size_t len) +{ + char *d, *s1, *s2, *s3; + s1 = mkstr("\\(", 60); + s2 = mkstr("(.*)", len); + s3 = concat(s1, s2); + free(s2); + free(s1); + s1 = concat(s3, ")"); + free(s3); + d = concat("(", s1); + free(s1); + return d; +} + +static char * +ps(const char *m, const char *s, size_t len) +{ + char *d, *s1, *s2, *s3; + s1 = mkstr(m, len); + s2 = mkstr(s, len); + s3 = concat(s1, s2); + free(s2); + free(s1); + d = concat("(.?)", s3); + free(s3); + return d; +} + +static char * +p2(size_t len) +{ + return ps("((.*){0,255}", ")", len); +} + +static char * +p3(size_t len) +{ + return ps("(.\\{0,}", ")", len); +} + +static char * +p4(size_t len) +{ + return ps("((.*){1,255}", ")", len); +} + +static char * +p5(size_t len) +{ + ret
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: pgoyette Date: Sun Jan 9 05:44:47 UTC 2011 Modified Files: src/tests/lib/libc/regex: t_regex.in Log Message: Fix typo that got lost between my trial build and the final commit To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/t_regex.in Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_regex.in diff -u src/tests/lib/libc/regex/t_regex.in:1.1 src/tests/lib/libc/regex/t_regex.in:1.2 --- src/tests/lib/libc/regex/t_regex.in:1.1 Sat Jan 8 18:10:31 2011 +++ src/tests/lib/libc/regex/t_regex.in Sun Jan 9 05:44:46 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_regex.in,v 1.1 2011/01/08 18:10:31 pgoyette Exp $ +# $NetBSD: t_regex.in,v 1.2 2011/01/09 05:44:46 pgoyette Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -27,7 +27,7 @@ h_check() { - prog="$(atf_get_srcdir)/h_re" + prog="$(atf_get_srcdir)/h_regex" data="$(atf_get_srcdir)/data/$1.in" atf_check -x "${prog} <${data}"
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: pgoyette Date: Sun Jan 9 01:00:40 UTC 2011 Added Files: src/tests/lib/libc/regex: Makefile Log Message: Ouch - forgot the include this earlier. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/regex/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/lib/libc/regex/Makefile diff -u /dev/null src/tests/lib/libc/regex/Makefile:1.1 --- /dev/null Sun Jan 9 01:00:40 2011 +++ src/tests/lib/libc/regex/Makefile Sun Jan 9 01:00:40 2011 @@ -0,0 +1,43 @@ +# $NetBSD: Makefile,v 1.1 2011/01/09 01:00:40 pgoyette Exp $ + +MKMAN= no + +.include + +TESTSDIR= ${TESTSBASE}/lib/libc/regex + +BINDIR= ${TESTSDIR} +PROG= h_regex +SRCS= main.c split.c debug.c +CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex + +TESTS_SH= t_regex + +FILESDIR= ${TESTSDIR}/data +FILES+= README +FILES+= data/anchor.in +FILES+= data/backref.in +FILES+= data/basic.in +FILES+= data/bracket.in +FILES+= data/c_comments.in +FILES+= data/complex.in +FILES+= data/error.in +FILES+= data/meta.in +FILES+= data/nospec.in +FILES+= data/nul.in +FILES+= data/paren.in +FILES+= data/regress.in +FILES+= data/repet_bounded.in +FILES+= data/repet_multi.in +FILES+= data/repet_ordinary.in +FILES+= data/startend.in +FILES+= data/subexp.in +FILES+= data/subtle.in +FILES+= data/word_bound.in + +t_regex.sh: t_regex.awk t_regex.in + ${TOOL_AWK} -f ${.CURDIR}/t_regex.awk ${.CURDIR}/t_regex.in > ${.TARGET} + +CLEANFILES+= t_regex.sh + +.include