From 64d7da63575bc6cb0bbcf7ac5ed81d51ea2a3a74 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sun, 17 Feb 2019 17:47:30 -0800
Subject: [PATCH] tests: avoid false positive upon stack overflow

* tests/pcre-jitstack: Don't let a stack overflow evoke a false
failure.  This test is to ensure there is no internal PCRE error.
Reported by Andres Schwab in http://bugs.gnu.org/34370
---
 tests/pcre-jitstack | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/pcre-jitstack b/tests/pcre-jitstack
index a6c9c21..8f738f0 100755
--- a/tests/pcre-jitstack
+++ b/tests/pcre-jitstack
@@ -52,8 +52,11 @@ if test $? != 1; then

     # Rerun that same test, but now with no limit on stack size:
     (ulimit -s unlimited;
-     returns_ 1 env LC_ALL=C grep -P -n '^([/](?!/)|[^/])*~/.*' pcrejit.txt) \
+     returns_ 1 env LC_ALL=C grep -P -n '^([/](?!/)|[^/])*~/.*' pcrejit.txt 2> err) \
        || fail=1
+
+    # If that failed due to stack overflow, don't cry foul.
+    test $fail = 1 && grep -q 'stack overflow' err && fail=0
 fi

 Exit $fail
-- 
2.20.1.2.gb21ebb671b

