Blame tests/backref-multibyte-slow

Packit 709fb3
#!/bin/sh
Packit 709fb3
# This was approximately quadratic up to grep-2.6.3
Packit 709fb3
. "${srcdir=.}/init.sh"; path_prepend_ ../src
Packit 709fb3
Packit 709fb3
require_en_utf8_locale_
Packit 709fb3
require_timeout_
Packit 709fb3
Packit 709fb3
fail=0
Packit 709fb3
Packit 709fb3
# Create a 13000-line input
Packit 709fb3
$AWK 'BEGIN {for (i=0; i<13000; i++) print "aba"}' /dev/null > in || fail=1
Packit 709fb3
Packit 709fb3
# Use 10 times the duration of running grep in the C locale as the timeout
Packit 709fb3
# when running in en_US.UTF-8.  Round up to whole seconds, since timeout
Packit 709fb3
# can't deal with fractional seconds.
Packit 709fb3
max_seconds=$(LC_ALL=C perl -le 'use Time::HiRes qw(time); my $s = time();
Packit 709fb3
              system q,grep -E '\''^([a-z]).\1$'\'' in > junk,;
Packit 709fb3
              my $elapsed = time() - $s; print int (1 + 10 * $elapsed)') \
Packit 709fb3
  || { max_seconds=5;
Packit 709fb3
       warn_ "$ME_: warning: no perl? using default of 5s timeout"; }
Packit 709fb3
Packit 709fb3
# If the above finished so quickly that we'd have a 1-second timeout,
Packit 709fb3
# increase it to a duration less likely to arise in a parallel test run.
Packit 709fb3
test $max_seconds = 1 && max_seconds=5
Packit 709fb3
Packit 709fb3
for LOC in en_US.UTF-8; do
Packit 709fb3
  out=out-$LOC
Packit 709fb3
  LC_ALL=$LOC timeout ${max_seconds}s grep -aE '^([a-z]).\1$' in > $out 2>&1 \
Packit 709fb3
    || fail=1
Packit 709fb3
  compare $out in || fail=1
Packit 709fb3
done
Packit 709fb3
Packit 709fb3
Exit $fail