summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/csplit-heap.sh9
-rwxr-xr-xtests/misc/cut-huge-range.sh12
-rwxr-xr-xtests/misc/head-c.sh6
-rwxr-xr-xtests/misc/printf-surprise.sh5
4 files changed, 20 insertions, 12 deletions
diff --git a/tests/misc/csplit-heap.sh b/tests/misc/csplit-heap.sh
index 9e51cb15f..0ffe70ad4 100755
--- a/tests/misc/csplit-heap.sh
+++ b/tests/misc/csplit-heap.sh
@@ -19,11 +19,14 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ csplit
-require_ulimit_v_
+# Determine basic amount of memory needed.
+{ echo y; echo n; } > f || framework_failure_
+vm=$(get_min_ulimit_v_ csplit -z f %n%1) \
+ || skip_ "this shell lacks ulimit support"
(
- ulimit -v 20000
- { yes | head -n2500000; echo n; } | csplit -z - %n%1
+ ulimit -v $vm \
+ && { yes | head -n2500000; echo n; } | csplit -z - %n%1
) || fail=1
Exit $fail
diff --git a/tests/misc/cut-huge-range.sh b/tests/misc/cut-huge-range.sh
index 035d8d087..4df2fc066 100755
--- a/tests/misc/cut-huge-range.sh
+++ b/tests/misc/cut-huge-range.sh
@@ -18,9 +18,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cut
-require_ulimit_v_
getlimits_
+vm=$(get_min_ulimit_v_ cut -b1 /dev/null) \
+ || skip_ "this shell lacks ulimit support"
+
# 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.
@@ -49,15 +51,15 @@ 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.
-(ulimit -v 20000; : | cut -b$CUT_MAX- > err 2>&1) || fail=1
+(ulimit -v $vm && : | cut -b$CUT_MAX- > err 2>&1) || fail=1
# Up to and including coreutils-8.21, cut would allocate possibly needed
# memory upfront. Subsequently extra memory is no longer needed.
-(ulimit -v 20000; : | cut -b1-$CUT_MAX >> err 2>&1) || fail=1
+(ulimit -v $vm && : | cut -b1-$CUT_MAX >> err 2>&1) || fail=1
# Explicitly disallow values above CUT_MAX
-(ulimit -v 20000; : | returns_ 1 cut -b$SIZE_MAX 2>/dev/null) || fail=1
-(ulimit -v 20000; : | returns_ 1 cut -b$SIZE_OFLOW 2>/dev/null) || fail=1
+(ulimit -v $vm && : | returns_ 1 cut -b$SIZE_MAX 2>/dev/null) || fail=1
+(ulimit -v $vm && : | returns_ 1 cut -b$SIZE_OFLOW 2>/dev/null) || fail=1
compare /dev/null err || fail=1
diff --git a/tests/misc/head-c.sh b/tests/misc/head-c.sh
index a553a55bc..ab821ac61 100755
--- a/tests/misc/head-c.sh
+++ b/tests/misc/head-c.sh
@@ -18,9 +18,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ head
-require_ulimit_v_
getlimits_
+vm=$(get_min_ulimit_v_ head -c1 /dev/null) \
+ || skip_ "this shell lacks ulimit support"
+
# exercise the fix of 2001-08-18, based on test case from Ian Bruce
echo abc > in || framework_failure_
(head -c1; head -c1) < in > out || fail=1
@@ -40,7 +42,7 @@ esac
# Only allocate memory as needed.
# Coreutils <= 8.21 would allocate memory up front
# based on the value passed to -c
-(ulimit -v 20000; head --bytes=-$SSIZE_MAX < /dev/null) || fail=1
+(ulimit -v $vm && head --bytes=-$SSIZE_MAX < /dev/null) || fail=1
# Make sure it works on funny files in /proc and /sys.
diff --git a/tests/misc/printf-surprise.sh b/tests/misc/printf-surprise.sh
index 20e6b0988..8480693fc 100755
--- a/tests/misc/printf-surprise.sh
+++ b/tests/misc/printf-surprise.sh
@@ -20,8 +20,9 @@ prog=printf
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ printf
-require_ulimit_v_
+vm=$(get_min_ulimit_v_ env $prog %20f 0) \
+ || skip_ "this shell lacks ulimit support"
# Up to coreutils-6.9, "printf %.Nf 0" would encounter an ENOMEM internal
# error from glibc's printf(3) function whenever N was large relative to
@@ -60,7 +61,7 @@ head -c 10 fifo > out & pid=$!
# Choosing the virtual memory limit, 11000 is enough, but 10000 is too
# little and provokes a "memory exhausted" diagnostic on FreeBSD 9.0-p3.
-( ulimit -v 15000; env $prog %20000000f 0 2>err-msg > fifo )
+( ulimit -v $vm && env $prog %20000000f 0 2>err-msg > fifo )
exit=$?
# Map this longer, and rarer, diagnostic to the common one.