Subject: bug#18425: test for new glibc regex bug

From: Paul Eggert <[email-masked]>
Date: Mon, 08 Sep 2014 09:51:31 -0700

Thanks.  How about the attached simpler patch instead?  Since grep 
always uses glibc-compatible regex (and supplies its own substitute when 
the system lacks one), and since all known glibc-compatible 
implementations fail, it should be safe to assume that grep will fail on 
the new test.  We can worry about dealing with test successes later, 
when the bug gets fixed (and presumably grep's substitute regex 
implementation will get fixed too).
>From c0fa2415dab47d336d93bcd65dc5b7c61dbe0593 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Mon, 8 Sep 2014 07:52:19 -0700
Subject: [PATCH] tests: add expect-to-fail test for a glibc regexp bug

* tests/triple-backref: New file.
* tests/Makefile.am (TESTS): Add it.
(XFAIL_TESTS): List it as a known, always-failing test.
Based on the bug report from Paul Eggert:
        https://sourceware.org/bugzilla/show_bug.cgi?id=17356
---
 tests/Makefile.am    |  3 ++-
 tests/triple-backref | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100755 tests/triple-backref

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 31e2a81..d47978f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,7 +22,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
 LDADD = ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a
 
-XFAIL_TESTS =
+XFAIL_TESTS = triple-backref
 
 # Equivalence classes are only supported when using the system
 # matcher (which means only with glibc).
@@ -104,6 +104,7 @@ TESTS =						\
   status					\
   surrogate-pair				\
   symlink					\
+  triple-backref				\
   turkish-eyes					\
   turkish-I					\
   turkish-I-without-dot				\
diff --git a/tests/triple-backref b/tests/triple-backref
new file mode 100755
index 0000000..38550d0
--- /dev/null
+++ b/tests/triple-backref
@@ -0,0 +1,18 @@
+#! /bin/sh
+# Test for a bug in glibc's regex code as of September 7, 2014.
+#
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+echo a > in || framework_failure_
+
+fail=0
+grep -E '(.?)(.?)(.?)\3\2\1' in > out || fail=1
+compare out in || fail=1
+
+Exit $fail
-- 
1.9.3