summaryrefslogtreecommitdiff
path: root/init.cfg
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2015-09-22 23:23:26 +0200
committerBernhard Voelker <mail@bernhard-voelker.de>2015-09-22 23:23:26 +0200
commit9db234ad09c12d34d2086057fd92ae448e931ac4 (patch)
treeaa72ec7b895c3aec9d6a72c986586547768b96cc /init.cfg
parent50e61bfdb9d2df30e1db97ae4ebec7044e087d29 (diff)
downloadcoreutils-9db234ad09c12d34d2086057fd92ae448e931ac4.tar.xz
maint: use adaptive approach for `ulimit -v` based tests
When configured with either 'symlinks' or 'shebangs' as value for the --enable-single-binary option, tests based on `ulimit -v` are skipped. The reason is that the multicall 'coreutils' binary requires much more memory due to shared libraries being loaded, and the size of the 'date' binary (~290KiB) compared to the multicall binary (~5MiB), of course. Finally, in the case of 'shebangs', the starting shell requires more memory, too Instead of using hard-coded values for the memory limit, use an adaptive approach: first determine the amount of memory for a similar, yet more trivial invocation of the command, and then do the real test run using that limit (plus some buffer in some cases). * init.cfg (require_ulimit_v_): Remove function. (get_min_ulimit_v_): Add function to determine the minimum memory limit required for a given command in an adaptive way. * cfg.mk (sc_prohibit_test_ulimit_without_require_): Change the name of the above function in the syntax-check rule. * tests/cp/link-heap.sh: Use the above function to determine the minimum memory required to run a command simpler than in the real test run. Use that limit plus a buffer there. While at it, change to list of commands in the subshell to fail also if the beginning `ulimit -v` fails. * tests/dd/no-allocate.sh: Likewise. * tests/misc/csplit-heap.sh: Likewise. * tests/misc/cut-huge-range.sh: Likewise. * tests/misc/head-c.sh: Likewise. * tests/misc/printf-surprise.sh: Likewise. * tests/split/line-bytes.sh: Likewise. * tests/rm/many-dir-entries-vs-OOM.sh: Likewise - doing it separately for each program under test.
Diffstat (limited to 'init.cfg')
-rw-r--r--init.cfg36
1 files changed, 19 insertions, 17 deletions
diff --git a/init.cfg b/init.cfg
index 3beba5a9a..f71f94c7a 100644
--- a/init.cfg
+++ b/init.cfg
@@ -144,24 +144,26 @@ require_openat_support_()
fi
}
-require_ulimit_v_()
-{
- 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.
+# Determine the minimum required VM limit to run the given command.
+# Output that value to stdout ... to be used by the caller.
+# Return 0 in case of success, and a non-Zero value otherwise.
+get_min_ulimit_v_()
+{
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"
+ for v in $( seq 5000 5000 50000 ); do
+ if ( ulimit -v $v && "$@" ) >/dev/null; then
+ local vm_prev
+ prev_v=$v
+ for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
+ ( ulimit -v $v && "$@" ) >/dev/null \
+ || { echo $prev_v; return 0; }
+ prev_v=$v
+ done
+ fi
+ done
+ # The above did not find a working limit. Echo a very small number - just
+ # in case the caller does not handle the non-Zero return value.
+ echo 1; return 1
}
require_readable_root_()