|
Packit |
709fb3 |
#!/bin/sh
|
|
Packit |
709fb3 |
# grep-2.21 would incur a 100x penalty for 10x increase in regexp length
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# Copyright 2015-2017 Free Software Foundation, Inc.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# This program is free software: you can redistribute it and/or modify
|
|
Packit |
709fb3 |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
709fb3 |
# the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
709fb3 |
# (at your option) any later version.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# This program is distributed in the hope that it will be useful,
|
|
Packit |
709fb3 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
709fb3 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
709fb3 |
# GNU General Public License for more details.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# You should have received a copy of the GNU General Public License
|
|
Packit |
709fb3 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
fail=0
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# This test is susceptible to failure due to differences in
|
|
Packit |
709fb3 |
# system load during the two test runs, so we'll mark it as
|
|
Packit |
709fb3 |
# "expensive", making it less likely to be run by regular users.
|
|
Packit |
709fb3 |
expensive_
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
echo x > in || framework_failure_
|
|
Packit |
709fb3 |
# We could use seq -s '' (avoiding the tr filter), but I
|
|
Packit |
709fb3 |
# suspect some version of seq does not honor that option.
|
|
Packit |
709fb3 |
# Note that we want 10x the byte count (not line count) in the larger file.
|
|
Packit |
709fb3 |
seq 10000 50000 | tr -d '\012' > r || framework_failure_
|
|
Packit |
709fb3 |
cat r r r r r r r r r r > re-10x || framework_failure_
|
|
Packit |
709fb3 |
mv r re || framework_failure_
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
base_ms=$(user_time_ 1 grep -f re in ) || fail=1
|
|
Packit |
709fb3 |
b10x_ms=$(user_time_ 1 grep -f re-10x in) || fail=1
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# Increasing the length of the regular expression by a factor
|
|
Packit |
709fb3 |
# of 10 should cause no more than a 10x increase in duration.
|
|
Packit |
709fb3 |
# However, we'll draw the line at 20x to avoid false-positives.
|
|
Packit |
709fb3 |
returns_ 1 expr $base_ms '<' $b10x_ms / 20 || fail=1
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
Exit $fail
|