diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-08-09 02:05:29 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-08-09 02:05:55 -0700 |
commit | 5c628c7074ae4a90a62165502afe5e7cb6a7eaa5 (patch) | |
tree | 9b7031425df4f4bac263f374db12b3d105777d3e | |
parent | 20b408ac0892b53ea55bc79acc0e98cd52840992 (diff) | |
download | grep-5c628c7074ae4a90a62165502afe5e7cb6a7eaa5.tar.gz |
tests: use awk, not seq
Portability problem reported by Dagobert Michelsen in:
https://lists.gnu.org/r/grep-devel/2021-08/msg00004.html
* tests/hash-collision-perf, tests/long-pattern-perf:
Don’t assume seq is installed; use awk instead.
-rwxr-xr-x | tests/hash-collision-perf | 6 | ||||
-rwxr-xr-x | tests/long-pattern-perf | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/tests/hash-collision-perf b/tests/hash-collision-perf index 898b496d..52266b63 100755 --- a/tests/hash-collision-perf +++ b/tests/hash-collision-perf @@ -28,7 +28,8 @@ fail=0 # for digits, which never exhibited a problem with hash collisions. n_pat=40000 while :; do - seq $n_pat > in || framework_failure_ + script="BEGIN { for (i = 1; i <= $n_pat; i++) print i }" + ${AWK-awk} "$script" < /dev/null > in || framework_failure_ small_ms=$(LC_ALL=C user_time_ 1 grep --file=in empty) || fail=1 test $small_ms -ge 200 && break n_pat=$(expr $n_pat '*' 2) @@ -36,7 +37,8 @@ done # Now, search for those same digits mapped to A-J. # With the PJW-based hash function, this became O(N^2). -seq $n_pat | tr 0-9 A-J > in || framework_failure_ +script="BEGIN { for (i = 1; i <= $n_pat; i++) print i }" +${AWK-awk} "$script" </dev/null | tr 0-9 A-J > in || framework_failure_ large_ms=$(LC_ALL=C user_time_ 1 grep --file=in empty) || fail=1 # Deliberately recording in an unused variable so it diff --git a/tests/long-pattern-perf b/tests/long-pattern-perf index 757bc943..a4cb089f 100755 --- a/tests/long-pattern-perf +++ b/tests/long-pattern-perf @@ -26,10 +26,9 @@ fail=0 expensive_ echo x > in || framework_failure_ -# We could use seq -s '' (avoiding the tr filter), but I -# suspect some version of seq does not honor that option. # Note that we want 10x the byte count (not line count) in the larger file. -seq 10000 50000 | tr -d '\012' > r || framework_failure_ +script='BEGIN { for (i=10000; i<=50000; i++) printf "%d", i }' +${AWK-awk} "$script" < /dev/null > r || framework_failure_ cat r r r r r r r r r r > re-10x || framework_failure_ mv r re || framework_failure_ |