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=9999)
        - It truncates the pattern with rep=9999


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 <sys/cdefs.h>
-__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 <stdio.h>
 #include <regex.h>
@@ -46,6 +46,9 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.3 2011
 #include <err.h>
 #include <atf-c.h>
 
+#ifndef REGEX_MAXSIZE
+#define REGEX_MAXSIZE	9999
+#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)(9999);
+		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, "aaaaaaaaaaa", 0, NULL, 0);
 		regfree(&re);
 	}

Reply via email to