Blob Blame History Raw
From aad5428ee639eb9c462097022a0954e8a2bcfb90 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Sun, 23 Nov 2008 17:24:13 +0100
Subject: [PATCH] Fedora Grep regression test suite

---
 tests/Makefile.am |    2 +-
 tests/fedora.sh   |  113 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 1 deletions(-)
 create mode 100644 tests/fedora.sh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6ac60e6..02f30ac 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,7 +4,7 @@ AWK=@AWK@
 
 TESTS = warning.sh khadafy.sh spencer1.sh bre.sh ere.sh pcre.sh \
         status.sh empty.sh options.sh backref.sh file.sh foad1.sh \
-        fmbtest.sh yesno.sh
+        fmbtest.sh yesno.sh fedora.sh
 EXTRA_DIST = $(TESTS) \
              khadafy.lines khadafy.regexp \
              spencer1.awk spencer1.tests \
diff --git a/tests/fedora.sh b/tests/fedora.sh
new file mode 100644
index 0000000..9a140b7
--- /dev/null
+++ b/tests/fedora.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+# GREP Regression test suite for Fedora bugs and fixes
+# (c) 2008 Lubomir Rintel
+# Licensed under the same terms as GNU Grep itself
+
+if [ -t 1 ]
+then
+	# Colored output on terimal
+	G='\033[32m'
+	R='\033[31m'
+	D='\033[0m'
+fi
+
+ok ()	{ echo -e "${G}OK${D}"; }
+fail () { echo -e "${R}FAIL${D} (See ${U})"; failures=1; }
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=116909
+echo -n "fgrep false negatives: "
+diff <(${GREP} -F -w -f \
+<(cat <<EOF
+a
+b
+c
+EOF
+) \
+<(cat <<EOF
+a
+barn
+c
+EOF
+)) \
+<(cat <<EOF
+a
+c
+EOF
+) && ok || fail
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=123362
+echo -n "bad handling of brackets in UTF-8: "
+diff <(echo Y | LC_ALL=de_DE.UTF-8 ${GREP} -i '[y,Y]') \
+<(cat <<EOF
+Y
+EOF
+) && ok || fail
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=112869
+echo -n "crash with \W: "
+diff <(echo '<form>' | LANG=it_IT ${GREP} -iE '\Wform\W') \
+<(cat <<EOF
+<form>
+EOF
+) && ok || fail
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=189580
+echo -n "grep -D skip opening a special file: "
+${GREP} -D skip foo /dev/zero &
+sleep 1
+kill $! 2>/dev/null && fail || ok
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=169524
+echo -n "grep -Fw looping infinitely: "
+echo foobar | ${GREP} -Fw "" &
+sleep 1
+kill $! 2>/dev/null && fail || ok
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=140781
+echo -n "fgrep hangs on binary files: "
+${GREP} -F grep $(which ${GREP}) >/dev/null &
+sleep 1
+kill $! 2>/dev/null && fail || ok
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=161700
+echo -n "grep -Fw fails to match anything: "
+diff <(${GREP} -Fw test <(cat <<EOF
+test
+EOF
+)) \
+<(cat <<EOF
+test
+EOF
+) && ok || fail
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=179698
+echo -n "grep -w broken in non-utf8 multibyte locales"
+diff <(echo za a | LANG=ja_JP.eucjp grep -w a) \
+<(cat <<EOF
+za a
+EOF
+) && ok || fail
+
+# Skip the rest of tests in compiled without PCRE
+echo a |grep -P a >/dev/null || exit $failures
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=171379
+echo -n "grep -P crashes on whitespace lines: "
+diff <(${GREP} -P '^\s+$' <(echo "   ")) \
+<(echo "   ") && ok || fail
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=204255
+echo -n "-e '' does not work if not a first parameter: "
+diff <(echo test | grep -e 'HighlightThis' -e '') \
+     <(echo test | grep -e '' -e 'HighlightThis') && ok || fail
+
+U=https://bugzilla.redhat.com/show_bug.cgi?id=324781
+echo -n "bad handling of line breaks with grep -P #1: "
+echo -ne "a\na" | ${GREP} -P '[^a]' >/dev/null && fail || ok
+
+# This is mostly a check that fix for above doesn't break -P further
+echo -n "bad handling of line breaks with grep -P #2: "
+echo -ne "a\na" | ${GREP} -P '[^b].[^b]' >/dev/null && fail || ok
+
+exit $failures
-- 
1.5.5.1