summaryrefslogtreecommitdiff
path: root/tests/rm
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 /tests/rm
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 'tests/rm')
-rwxr-xr-xtests/rm/many-dir-entries-vs-OOM.sh30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/rm/many-dir-entries-vs-OOM.sh b/tests/rm/many-dir-entries-vs-OOM.sh
index e9c95d5d5..8cc839bd1 100755
--- a/tests/rm/many-dir-entries-vs-OOM.sh
+++ b/tests/rm/many-dir-entries-vs-OOM.sh
@@ -19,21 +19,29 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ rm du chmod
-require_ulimit_v_
-
expensive_
+mkdir d2 \
+ && touch d2/f || framework_failure_
+
+# 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"
+
# With many files in a single directory...
-mkdir d && cd d || framework_failure_
-seq 200000|xargs touch || framework_failure_
+mkdir d || framework_failure_
+seq --format="d/%06g" 200000 | xargs touch || framework_failure_
-cd ..
+# Allow 35MiB more memory as for the trivial case above.
+(ulimit -v $(($vm + 35000)) && du -sh d) || fail=1
-# Restricted to 40MB, each of these coreutils-8.12 programs would fail
-# with a diagnostic like "rm: fts_read failed: Cannot allocate memory".
-ulimit -v 40000
-du -sh d || fail=1
-chmod -R 700 d || fail=1
-rm -rf d || fail=1
+vm=$(get_min_ulimit_v_ chmod -R 700 d2) \
+ || skip_ "this shell lacks ulimit support"
+(ulimit -v $(($vm + 35000)) && chmod -R 700 d) || fail=1
+
+vm=$(get_min_ulimit_v_ rm -rf d2) \
+ || skip_ "this shell lacks ulimit support"
+(ulimit -v $(($vm + 35000)) && rm -rf d) || fail=1
Exit $fail