From 9a232e99e888e160aa25169fd5f07dbc91c911bf Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 4 Nov 2010 13:04:52 +0100 Subject: 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 --- tests/backref-multibyte-slow | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') 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 -- cgit v1.2.1