require_ulimit_()
{
- ulimit_works=yes
- # Expect to be able to exec a program in 10MB of virtual memory,
- # but not in 20KB. I chose "date". It must not be a shell built-in
+ local ulimit_works=yes
+ # Expect to be able to exec a program in 10MiB of virtual memory,
+ # (10MiB is usually plenty, but valgrind-wrapped date requires 19000KiB,
+ # so allow more in that case)
+ # but not in 20KiB. I chose "date". It must not be a shell built-in
# function, so you can't use echo, printf, true, etc.
# Of course, in coreutils, I could use $top_builddir/src/true,
# but this should be able to work for other projects, too.
- ( ulimit -v 10000; date ) > /dev/null 2>&1 || ulimit_works=no
- ( ulimit -v 20; date ) > /dev/null 2>&1 && ulimit_works=no
+ local vm
+ case $(printenv LD_PRELOAD) in */valgrind/*) vm=22000;; *) vm=10000;; esac
+
+ ( ulimit -v $vm; date ) > /dev/null 2>&1 || ulimit_works=no
+ ( ulimit -v 20; date ) > /dev/null 2>&1 && ulimit_works=no
test $ulimit_works = no \
&& skip_ "this shell lacks ulimit support"