summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-05-18 16:26:39 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-05-18 16:29:57 -0700
commitc704573729b32bac9a816bcc1d4bdac0985beaa2 (patch)
treeb5bcc44e79c8ae8c4bd7ddeb11662564d2842980 /tests
parentbd001dcd4a2c75f583cce13405bf4ad10b464d4d (diff)
downloadcoreutils-c704573729b32bac9a816bcc1d4bdac0985beaa2.tar.xz
tests: don't assume expr was built with GMP
* tests/misc/cut-huge-range.sh (subtract_one): New string. (CUT_MAX): Don't pass a too-large integer to 'expr'.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/cut-huge-range.sh23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/misc/cut-huge-range.sh b/tests/misc/cut-huge-range.sh
index e9190a2c2..7816577b9 100755
--- a/tests/misc/cut-huge-range.sh
+++ b/tests/misc/cut-huge-range.sh
@@ -21,10 +21,31 @@ print_ver_ cut
require_ulimit_v_
getlimits_
+# sed script to subtract one from the input.
+# Each input line should consist of a positive decimal number.
+# Each output line's number is one less than the input's.
+# There's no limit (other than line length) on the number's magnitude.
+subtract_one='
+ s/$/@/
+ : again
+ s/0@/@9/
+ s/1@/0/
+ s/2@/1/
+ s/3@/2/
+ s/4@/3/
+ s/5@/4/
+ s/6@/5/
+ s/7@/6/
+ s/8@/7/
+ s/9@/8/
+ t again
+'
+
# Ensure we can cut up to our sentinel value.
# This is currently SIZE_MAX, but could be raised to UINTMAX_MAX
# if we didn't allocate memory for each line as a unit.
-CUT_MAX=$(expr $SIZE_MAX - 1)
+# Don't use expr to subtract one, since SIZE_MAX may exceed its maximum value.
+CUT_MAX=$(echo $SIZE_MAX | sed "$subtract_one")
# From coreutils-8.10 through 8.20, this would make cut try to allocate
# a 256MiB bit vector. With a 20MB limit on VM, the following would fail.