This avoids a test hang seen with bash on Solaris 11
* init.cfg (ulimit_supported_): Change to a wrapper
that uses timeout(1) with ...
* tests/ulimit_supported: ... a separated helper.
* tests/misc/write-errors.sh: Be more conservative
and skip the test if we fail to determine an
appropriate vm limit with ulimit -v.
---
init.cfg | 20 ++++++++------------
tests/misc/write-errors.sh | 2 +-
tests/ulimit_supported | 15 +++++++++++++++
3 files changed, 24 insertions(+), 13 deletions(-)
create mode 100755 tests/ulimit_supported
diff --git a/init.cfg b/init.cfg
index ae158c7a3..bdd001384 100644
--- a/init.cfg
+++ b/init.cfg
@@ -170,21 +170,17 @@ require_openat_support_()
fi
}
-# Return true if command runs with the
-# ulimit specified in the first argument
+# Return with command status
+# with 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;
+ # Wrap with timeout as on some systems (like Solaris 11)
+ # fork() can return EAGAIN under vm constraints,
+ # causing bash at least to loop retrying the fork
+ timeout 1 true >/dev/null ||
+ skip_ 'ulimit -v cannot be safely checked'
- ulimit -v $v && "$@"
- ) >/dev/null 2>&1
+ timeout 10 $SHELL "$abs_srcdir"/tests/ulimit_supported "$@"
}
# Determine the minimum required VM limit to run the given command.
diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh
index 78379b542..13e6d11fa 100755
--- a/tests/misc/write-errors.sh
+++ b/tests/misc/write-errors.sh
@@ -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_
diff --git a/tests/ulimit_supported b/tests/ulimit_supported
new file mode 100755
index 000000000..cc89db871
--- /dev/null
+++ b/tests/ulimit_supported
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Return command status
+# with ulimit specified in the first argument
+
+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
--
2.47.1