]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid slow ulimit -v behavior
authorPádraig Brady <P@draigBrady.com>
Wed, 15 Jan 2025 15:13:00 +0000 (15:13 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 15 Jan 2025 17:07:13 +0000 (17:07 +0000)
* init.cfg (ulimit_supported_): skip_ if the ulimit -v
takes too long, which was seen with bash 5.2 on Solaris 11,
where fork() returned EAGAIN under memory constraints,
and bash retried for about 16 seconds.
(get_min_ulimit_v_): Break early if skipped.
* tests/misc/write-errors.sh: Be more conservative and
skip on failure to determine min ulimit.

init.cfg
tests/misc/write-errors.sh

index ae158c7a3bb5bf12d939f863babcb771fc7b4961..7e21f96c6a7cdc08a4d8e019cac7a5729610415c 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -178,6 +178,8 @@ ulimit_supported_()
   v="$1"
   shift
 
+  local ulimit_start_=$(date +%s) || skip_ 'ulimit: date error'
+
   (
     # Try to disable core dumps which may
     # occur with memory constraints
@@ -185,6 +187,16 @@ ulimit_supported_()
 
     ulimit -v $v && "$@"
   ) >/dev/null 2>&1
+
+  ret=$?
+
+  local ulimit_end_=$(date +%s) || skip_ 'ulimit: date error'
+
+  # This can happen on Solaris 11 at least where fork() can give EAGAIN
+  # and bash will retry for at least 16 seconds
+  test $(($ulimit_end_ - $ulimit_start_)) -ge 10 && skip_ 'ulimit too slow'
+
+  return $ret
 }
 
 # Determine the minimum required VM limit to run the given command.
@@ -200,11 +212,15 @@ get_min_ulimit_v_()
   page_size=$(($page_size / 1024))
 
   for v in $( seq 5000 5000 50000 ); do
-    if ulimit_supported_ $v "$@"; then
+    ulimit_supported_ $v "$@"; ret=$?
+    test $ret = 77 && break;
+    if test $ret = 0; then
       local prev_v
       prev_v=$v
       for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
-        ulimit_supported_ $v "$@" ||
+        ulimit_supported_ $v "$@"; ret=$?
+        test $ret = 77 && break 2;
+        test $ret = 0 ||
           {
             ret_v=$((prev_v + $page_size))
             echo $ret_v
index 78379b542cf2ef93df36bc630ce86ddc10aff965..13e6d11fab7d7aa7b2bac10469ef04e57d49028d 100755 (executable)
@@ -62,7 +62,7 @@ while read writer; do
   cmd=$(printf '%s\n' "$writer" | cut -d ' ' -f1) || framework_failure_
   base_mem=$(get_min_ulimit_v_ $cmd --version) \
     && ulimit="ulimit -v $(($base_mem+8000))" \
-    || ulimit='true'
+    || skip_ 'unable to determine ulimit -v'
 
   # Check /dev/full handling
   rm -f full.err || framework_failure_