summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNorihiro Tanaka <noritnk@kcn.ne.jp>2010-03-28 17:56:22 +0200
committerJim Meyering <meyering@redhat.com>2010-03-28 20:59:44 +0200
commit46c97344bac16916352b198ac5fbe14c5cd2bf2c (patch)
treedd583d137e2eddaa4b1034d521d8956b1d8ffb64 /tests
parentdb9d6340b42a7774fae526f6a90eea3ce834e2d0 (diff)
downloadgrep-46c97344bac16916352b198ac5fbe14c5cd2bf2c.tar.gz
tests: add tests for the fgrep-infloop bug
* tests/init.cfg (require_timeout_): New function. * tests/fgrep-infloop: New file. Test for the above fix. * tests/Makefile.am (TESTS): Add it.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/fgrep-infloop20
-rw-r--r--tests/init.cfg6
3 files changed, 27 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f9ba21be..9e0224fc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,6 +29,7 @@ TESTS = \
ere.sh \
euc-mb \
fedora \
+ fgrep-infloop \
file.sh \
fmbtest \
foad1 \
diff --git a/tests/fgrep-infloop b/tests/fgrep-infloop
new file mode 100644
index 00000000..159baca5
--- /dev/null
+++ b/tests/fgrep-infloop
@@ -0,0 +1,20 @@
+#!/bin/sh
+# This would infloop for grep-2.6.1
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ ../src
+
+require_timeout_
+
+encode() { echo "$1" | tr ABC '\357\274\241'; }
+
+fail=0
+
+for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do
+ out=out1-$LOC
+ encode ABC \
+ | LC_ALL=$LOC timeout 10s grep -F "$(encode BC)" > $out 2>&1
+ test $? = 1 || fail=1
+ compare $out /dev/null || fail=1
+done
+
+Exit $fail
diff --git a/tests/init.cfg b/tests/init.cfg
index 0ec60f1c..6f957b30 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -32,3 +32,9 @@ do
done
test "$envvar_check_fail" = 1 && fail_ "failed to unset the above envvars"
+
+require_timeout_()
+{
+ ( timeout --version ) > /dev/null 2>&1 \
+ || skip_ your system lacks the timeout program
+}