~michel-slm/coreutils

aa50ea55ea68aa5f5475bf46357bcf5febcde1bb — Pádraig Brady 7 months ago c4c5ed8
tests: make ulimit -v interact better with ASAN

ulimit -v is generally not supported with ASAN, giving errors like:
  "ReserveShadowMemoryRange failed while trying to map 0x... bytes.
   Perhaps you're using ulimit -v"

* tests/cp/link-heap.sh: Mention ASAN as a possible reason for skipping.
* tests/csplit/csplit-heap.sh: Likewise.
* tests/cut/cut-huge-range.sh: Likewise.
* tests/dd/no-allocate.sh: Likewise.
* tests/printf/printf-surprise.sh: Likewise.
* tests/rm/many-dir-entries-vs-OOM.sh: Likewise.
* tests/head/head-c.sh: Only skip the part of the test needing ulimit.
* tests/split/line-bytes.sh: Likewise.
M tests/cp/link-heap.sh => tests/cp/link-heap.sh +1 -1
@@ 23,7 23,7 @@ expensive_
# Determine basic amount of memory needed for 'cp -al'.
touch f || framework_failure_
vm=$(get_min_ulimit_v_ cp -al f f2) \
  || skip_ "this shell lacks ulimit support"
  || skip_ 'shell lacks ulimit, or ASAN enabled'
rm f f2 || framework_failure_

a=$(printf %031d 0)

M tests/csplit/csplit-heap.sh => tests/csplit/csplit-heap.sh +1 -1
@@ 22,7 22,7 @@ print_ver_ csplit
# 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"
  || skip_ 'shell lacks ulimit, or ASAN enabled'

(
 ulimit -v $(($vm + 4000)) \

M tests/cut/cut-huge-range.sh => tests/cut/cut-huge-range.sh +1 -1
@@ 21,7 21,7 @@ print_ver_ cut
getlimits_

vm=$(get_min_ulimit_v_ returns_ 0 cut -b1 /dev/null) \
  || skip_ "this shell lacks ulimit support"
  || skip_ 'shell lacks ulimit, or ASAN enabled'

# Ensure we can cut up to our sentinel value.
# Don't use expr to subtract one,

M tests/dd/no-allocate.sh => tests/dd/no-allocate.sh +1 -1
@@ 22,7 22,7 @@ print_ver_ dd
# Determine basic amount of memory needed.
echo . > f || framework_failure_
vm=$(get_min_ulimit_v_ timeout 10 dd if=f of=f2 status=none) \
  || skip_ "this shell lacks ulimit support"
  || skip_ 'shell lacks ulimit, or ASAN enabled'
rm f f2 || framework_failure_

# count and skip are zero, we don't need to allocate memory

M tests/head/head-c.sh => tests/head/head-c.sh +3 -4
@@ 20,9 20,6 @@
print_ver_ head
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


@@ 42,7 39,9 @@ esac
# Only allocate memory as needed.
# Coreutils <= 8.21 would allocate memory up front
# based on the value passed to -c
(ulimit -v $(($vm+8000)) && head --bytes=-$SSIZE_MAX < /dev/null) || fail=1
vm=$(get_min_ulimit_v_ head -c1 /dev/null) && {
  (ulimit -v $(($vm+8000)) && head --bytes=-$SSIZE_MAX < /dev/null) || fail=1
}

# Make sure it works on funny files in /proc and /sys.


M tests/printf/printf-surprise.sh => tests/printf/printf-surprise.sh +1 -1
@@ 22,7 22,7 @@ prog=printf
print_ver_ printf

vm=$(get_min_ulimit_v_ env $prog %20f 0) \
  || skip_ "this shell lacks ulimit support"
  || skip_ 'shell lacks ulimit, or ASAN enabled'

# 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

M tests/rm/many-dir-entries-vs-OOM.sh => tests/rm/many-dir-entries-vs-OOM.sh +1 -1
@@ 27,7 27,7 @@ mkdir d2 \
# Restrict memory.  Each of these coreutils-8.12 programs would fail
# with a diagnostic like "rm: fts_read failed: Cannot allocate memory".
vm=$(get_min_ulimit_v_ du -sh d2) \
  || skip_ "this shell lacks ulimit support"
  || skip_ 'shell lacks ulimit, or ASAN enabled'

# With many files in a single directory...
mkdir d || framework_failure_

M tests/split/line-bytes.sh => tests/split/line-bytes.sh +4 -4
@@ 19,11 19,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ split

vm=$(get_min_ulimit_v_ split -C 'K' /dev/null) \
  || skip_ "this shell lacks ulimit support"

# Ensure memory is not allocated up front
(ulimit -v $vm && split -C 'G' /dev/null) || fail=1

vm=$(get_min_ulimit_v_ split -C 'K' /dev/null) && {
  (ulimit -v $vm && split -C 'G' /dev/null) || fail=1
}


# Ensure correct operation with various split and buffer size combinations