Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/regex PR/51832: Ngie Cooper:



details:   https://anonhg.NetBSD.org/src/rev/017f00075c86
branches:  trunk
changeset: 820729:017f00075c86
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 14 00:50:56 2017 +0000

description:
PR/51832: Ngie Cooper:
- limit memory to 64M
- error msg fixes
- includes fixes

diffstat:

 tests/lib/libc/regex/debug.c       |   7 ++++---
 tests/lib/libc/regex/t_exhaust.c   |  18 +++++++++++-------
 tests/lib/libc/regex/t_regex_att.c |   6 +++---
 3 files changed, 18 insertions(+), 13 deletions(-)

diffs (103 lines):

diff -r f6edc445c2e9 -r 017f00075c86 tests/lib/libc/regex/debug.c
--- a/tests/lib/libc/regex/debug.c      Sat Jan 14 00:35:37 2017 +0000
+++ b/tests/lib/libc/regex/debug.c      Sat Jan 14 00:50:56 2017 +0000
@@ -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 <sys/types.h>
 #include <ctype.h>
 #include <limits.h>
 #include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#include <sys/types.h>
+#include <wchar.h>
+#include <wctype.h>
 
 /* Don't sort these! */
 #include "utils.h"
diff -r f6edc445c2e9 -r 017f00075c86 tests/lib/libc/regex/t_exhaust.c
--- a/tests/lib/libc/regex/t_exhaust.c  Sat Jan 14 00:35:37 2017 +0000
+++ b/tests/lib/libc/regex/t_exhaust.c  Sat Jan 14 00:50:56 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 <stdio.h>
+#include <sys/resource.h>
+#include <atf-c.h>
+#include <err.h>
 #include <regex.h>
-#include <string.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <err.h>
-#include <atf-c.h>
+#include <string.h>
 
 #ifndef REGEX_MAXSIZE
 #define REGEX_MAXSIZE  9999
@@ -176,14 +177,17 @@
            " 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);
diff -r f6edc445c2e9 -r 017f00075c86 tests/lib/libc/regex/t_regex_att.c
--- a/tests/lib/libc/regex/t_regex_att.c        Sat Jan 14 00:35:37 2017 +0000
+++ b/tests/lib/libc/regex/t_regex_att.c        Sat Jan 14 00:50:56 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
 
@@ -374,7 +374,7 @@
                    " 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);
 }
 



Home | Main Index | Thread Index | Old Index