summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2014-02-20 16:06:13 -0800
committerJim Meyering <meyering@fb.com>2014-02-20 16:06:31 -0800
commitd5bfcc2daa123fa0e8660909052f7ca2ec6b7649 (patch)
tree8dc4dbb308892db897187e3858d65e334c696632
parentc7c8bcdefe7be5f59a242eea63df7f64eacb6a09 (diff)
downloadgrep-d5bfcc2daa123fa0e8660909052f7ca2ec6b7649.tar.gz
tests: test for the non-UTF8 multi-byte performance regression
Test for the just-fixed performance regression. With a 100-200x differential, it is reasonable to expect that a very slow system will be able to complete the designated task in a few seconds, while with the bug, even a very fast system would exceed the timeout. * tests/mb-non-UTF8-performance: New file. * tests/Makefile.am (TESTS): Add it. * tests/init.cfg (require_JP_EUC_locale_): New function.
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/init.cfg16
-rwxr-xr-xtests/mb-non-UTF8-performance32
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 331467ab..4ffea850 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -72,6 +72,7 @@ TESTS = \
khadafy \
long-line-vs-2GiB-read \
max-count-vs-context \
+ mb-non-UTF8-performance \
multibyte-white-space \
empty-line-mb \
unibyte-bracket-expr \
diff --git a/tests/init.cfg b/tests/init.cfg
index ee5d537d..5555e2d0 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -103,6 +103,22 @@ require_unibyte_locale()
skip_ 'no unibyte locale found'
}
+require_JP_EUC_locale_()
+{
+ local locale=ja_JP.eucJP
+ path_prepend_ .
+ case $(get-mb-cur-max $locale) in
+ [23])
+ LC_ALL=$locale &&
+ export LC_ALL &&
+ return
+ ;;
+ *) ;;
+ esac
+
+ skip_ "$loc locale not found"
+}
+
expensive_()
{
if test "$RUN_EXPENSIVE_TESTS" != yes; then
diff --git a/tests/mb-non-UTF8-performance b/tests/mb-non-UTF8-performance
new file mode 100755
index 00000000..282f0c4a
--- /dev/null
+++ b/tests/mb-non-UTF8-performance
@@ -0,0 +1,32 @@
+#!/bin/sh
+# grep-2.17 would take nearly 200x longer to run the command below.
+
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_timeout_
+
+fail=0
+
+require_JP_EUC_locale_
+
+yes $(printf '%078d' 0) | head -50000 > in || framework_failure_
+
+# Expect no match, i.e., exit status of 1. Anything else is an error.
+timeout 4 grep -i foobar in; st=$?
+test $st = 1 || fail=1
+
+Exit $fail