summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2010-11-04 13:04:52 +0100
committerJim Meyering <meyering@redhat.com>2010-11-04 21:44:33 +0100
commit9a232e99e888e160aa25169fd5f07dbc91c911bf (patch)
tree1da164d44a93b62ce79afcb9329950d9920f13b6 /tests
parentb90fc3e5c6739018f27419c1b5c2839031adacf0 (diff)
downloadgrep-9a232e99e888e160aa25169fd5f07dbc91c911bf.tar.gz
tests: don't hard-code a 5-second timeout; that's not always enough
Instead, time the command in the C locale and use 10 times that duration -- rounded up to whole seconds -- as the timeout when running it in the UTF-8 locale. * tests/backref-multibyte-slow: Compute a performance-relative timeout. Reported by Gilles Espinasse, regarding an imac 400. For more details, see http://thread.gmane.org/gmane.comp.gnu.grep.bugs/3360
Diffstat (limited to 'tests')
-rw-r--r--tests/backref-multibyte-slow11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/backref-multibyte-slow b/tests/backref-multibyte-slow
index eb32b43f..ffebb6b2 100644
--- a/tests/backref-multibyte-slow
+++ b/tests/backref-multibyte-slow
@@ -10,9 +10,18 @@ fail=0
# Create a 13000-line input
$AWK 'BEGIN {for (i=0; i<13000; i++) print "aba"}' /dev/null > in || fail=1
+# Use 10 times the duration of running grep in the C locale as the timeout
+# when running in en_US.UTF-8. Round up to whole seconds, since timeout
+# can't deal with fractional seconds.
+max_seconds=$(LC_ALL=C perl -le 'use Time::HiRes qw(time); my $s = time();
+ system q,grep -E '\''^([a-z]).\1$'\'' in > /dev/null,;
+ my $elapsed = time() - $s; print int (1 + 10 * $elapsed)') \
+ || { max_seconds=5;
+ warn_ "$ME_: warning: no perl? using default of 5s timeout"; }
+
for LOC in en_US.UTF-8; do
out=out-$LOC
- LC_ALL=$LOC timeout 5s grep -E '^([a-z]).\1$' in > $out 2>&1
+ LC_ALL=$LOC timeout ${max_seconds}s grep -E '^([a-z]).\1$' in > $out 2>&1
test $? = 0 || fail=1
compare $out in || fail=1
done