@@ -1816,6 +1816,22 @@ test_lazy_prereq ULIMIT_FILE_DESCRIPTORS '
run_with_limited_open_files true
'
+run_with_limited_processses () {
+ # bash and ksh use "ulimit -u", dash uses "ulimit -p"
+ if test -n "$BASH_VERSION"
+ then
+ ulimit_max_process="-u"
+ elif test -n "$KSH_VERSION"
+ then
+ ulimit_max_process="-u"
+ fi
+ (ulimit ${ulimit_max_process-"-p"} 512 && "$@")
+}
+
+test_lazy_prereq ULIMIT_PROCESSES '
+ run_with_limited_processses true
+'
+
build_option () {
git version --build-options |
sed -ne "s/^$1: //p"
We will use the lazy prerequisite ULIMIT_PROCESSES in a follow-up commit. With run_with_limited_processses() we can limit forking subprocesses and fail reliably in some test cases. Signed-off-by: Han Xin <hanxin.hx@bytedance.com> --- t/test-lib.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)