From 9db234ad09c12d34d2086057fd92ae448e931ac4 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Tue, 22 Sep 2015 23:23:26 +0200 Subject: 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. --- tests/dd/no-allocate.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/dd') diff --git a/tests/dd/no-allocate.sh b/tests/dd/no-allocate.sh index 99e0542ac..d122e3544 100755 --- a/tests/dd/no-allocate.sh +++ b/tests/dd/no-allocate.sh @@ -18,12 +18,17 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ dd -require_ulimit_v_ + +# Determine basic amount of memory needed. +echo . > f || framework_failure_ +vm=$(get_min_ulimit_v_ dd if=f of=f2 status=none) \ + || skip_ "this shell lacks ulimit support" +rm -f f || framework_failure_ # count and skip are zero, we don't need to allocate memory -(ulimit -v 20000; dd bs=30M count=0) || fail=1 -(ulimit -v 20000; dd ibs=30M count=0) || fail=1 -(ulimit -v 20000; dd obs=30M count=0) || fail=1 +(ulimit -v $vm && dd bs=30M count=0) || fail=1 +(ulimit -v $vm && dd ibs=30M count=0) || fail=1 +(ulimit -v $vm && dd obs=30M count=0) || fail=1 check_dd_seek_alloc() { local file="$1" @@ -38,7 +43,8 @@ check_dd_seek_alloc() { timeout 10 dd count=1 if=/dev/zero of=tape& # Allocate buffer and read from the "tape" - (ulimit -v 20000; timeout 10 dd $dd_buf=30M $dd_op=1 count=0 $dd_file=tape) + (ulimit -v $(($vm+4000)) \ + && timeout 10 dd $dd_buf=30M $dd_op=1 count=0 $dd_file=tape) local ret=$? # Be defensive in case the tape reader is blocked for some reason -- cgit v1.2.3-54-g00ecf