[PATCH v3 1/2] test-lib.sh: add limited processes to test-lib
- From
Han Xin <hanxin.hx@bytedance.com>
- Date
- Jun 28, 2022, 02:02 UTC
- Message-ID
- <ad0a539759ab79adb7a5b4c87f1a1548012ffbbe.1656381667.git.hanxin.hx@bytedance.com>
- In-Reply-To
- <cover.1656381667.git.hanxin.hx@bytedance.com>
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(+)
diff --git a/t/test-lib.sh b/t/test-lib.sh index 8ba5ca1534..655d6d543f 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -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"
-- 2.36.1