coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coreutils] Re: tests/backref-multibyte-slow timeout 5s is too short for


From: Jim Meyering
Subject: [coreutils] Re: tests/backref-multibyte-slow timeout 5s is too short for my imac 400
Date: Thu, 04 Nov 2010 13:08:08 +0100

Gilles Espinasse wrote:
> Selon Jim Meyering <address@hidden>:
...
>> Gilles, does that work for you?
>>
> Will test tonight.
> At least perl is always available on LFS build style.
>
> If perl is not available, probably test should be skipped.

Actually, giving a warning and using the old default of 5 seconds
should be good enough if perl doesn't work:

>From 93015c3bebeca0cf2ed17ac0b561b7c3453864d8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 4 Nov 2010 13:04:52 +0100
Subject: [PATCH] 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 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/tests/backref-multibyte-slow b/tests/backref-multibyte-slow
index eb32b43..80ac197 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 zerl -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
--
1.7.3.2.193.g78bbb



reply via email to

[Prev in Thread] Current Thread [Next in Thread]