summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-01-14 01:52:34 +0000
committerPádraig Brady <P@draigBrady.com>2016-01-15 14:14:02 +0000
commit89f7adb158aa3cb8f217d18ed895d02bc37753eb (patch)
treeb1d3e85e1567c2bef7d19376fdf82bce87dd9a00
parent611e7e02bff8898e622d6ad582a92f2de746b614 (diff)
downloadcoreutils-89f7adb158aa3cb8f217d18ed895d02bc37753eb.tar.xz
tests: avoid coredumps when determining memory limits
* init.cfg (get_min_ulimit_v_): Refactor ulimit call to... (ulimit_supported_): ...here, and add calls to avoid coredumps.
-rw-r--r--init.cfg21
1 files changed, 19 insertions, 2 deletions
diff --git a/init.cfg b/init.cfg
index e0ee1bc67..108fd206b 100644
--- a/init.cfg
+++ b/init.cfg
@@ -153,6 +153,23 @@ require_openat_support_()
fi
}
+# Return true if command runs with the
+# ulimit specified in the first argument
+ulimit_supported_()
+{
+ local v
+ v="$1"
+ shift
+
+ (
+ # Try to disable core dumps which may
+ # occur with memory constraints
+ trap '' SEGV; ulimit -c 0;
+
+ ulimit -v $v && "$@"
+ ) >/dev/null 2>&1
+}
+
# 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.
@@ -166,11 +183,11 @@ get_min_ulimit_v_()
page_size=$(($page_size / 1024))
for v in $( seq 5000 5000 50000 ); do
- if ( ulimit -v $v && "$@" ) >/dev/null; then
+ if ulimit_supported_ $v "$@"; then
local prev_v
prev_v=$v
for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
- ( ulimit -v $v && "$@" ) >/dev/null || \
+ ulimit_supported_ $v "$@" ||
{
ret_v=$((prev_v + $page_size))
echo $ret_v