| 1 |
#! /bin/sh |
| 2 |
# Test for back-references and other things. |
| 3 |
# |
| 4 |
# Copyright (C) 2001, 2006, 2009-2025 Free Software Foundation, Inc. |
| 5 |
# |
| 6 |
# Copying and distribution of this file, with or without modification, |
| 7 |
# are permitted in any medium without royalty provided the copyright |
| 8 |
# notice and this notice are preserved. |
| 9 |
|
| 10 |
. "${srcdir=.}/init.sh"; path_prepend_ ../src |
| 11 |
|
| 12 |
failures=0 |
| 13 |
|
| 14 |
# checking for a palindrome |
| 15 |
echo "radar" | grep -e '\(.\)\(.\).\2\1' > /dev/null 2>&1 |
| 16 |
if test $? -ne 0 ; then |
| 17 |
echo "Backref: palindrome, test #1 failed" |
| 18 |
failures=1 |
| 19 |
fi |
| 20 |
|
| 21 |
# hit hard with the 'Bond' tests |
| 22 |
# For now, remove the '?' in the last parentheses, so that new glibc can do it. |
| 23 |
# --Stepan |
| 24 |
echo "civic" \ |
| 25 |
| grep -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\9\8\7\6\5\4\3\2\1$' \ |
| 26 |
> /dev/null 2>&1 |
| 27 |
if test $? -ne 0 ; then |
| 28 |
echo "Options: Bond, test #2 failed" |
| 29 |
failures=1 |
| 30 |
fi |
| 31 |
|
| 32 |
# backref are local should be error |
| 33 |
echo "123" | grep -e 'a\(.\)' -e 'b\1' > /dev/null 2>&1 |
| 34 |
if test $? -ne 2 ; then |
| 35 |
echo "Backref: Backref not local, test #3 failed" |
| 36 |
failures=1 |
| 37 |
fi |
| 38 |
|
| 39 |
# Pattern should fail |
| 40 |
echo "123" | grep -e '[' -e ']' > /dev/null 2>&1 |
| 41 |
if test $? -ne 2 ; then |
| 42 |
echo "Backref: Compiled not local, test #4 failed" |
| 43 |
failures=1 |
| 44 |
fi |
| 45 |
|
| 46 |
# https://bugs.gnu.org/36148#13 |
| 47 |
echo 'Total failed: 2 (1 ignored)' | |
| 48 |
grep -e '^Total failed: 0$' -e '^Total failed: \([0-9]*\) (\1 ignored)$' |
| 49 |
if test $? -ne 1 ; then |
| 50 |
echo "Backref: Multiple -e test, test #5 failed" |
| 51 |
failures=1 |
| 52 |
fi |
| 53 |
|
| 54 |
Exit $failures |