Re: Re: [PATCH v2 1/2] test-lib.sh: add limited processes to test-lib
- From
Han Xin <hanxin.hx@bytedance.com>
- Date
- Jun 25, 2022, 01:35 UTC
- Message-ID
- <CAKgqsWVAy8RTSCwG=LVHPoeF5ECSzeNfK4mPacLo=dTeUkc6SA@mail.gmail.com>
- In-Reply-To
- <xmqqfsjuvyjz.fsf@gitster.g>
On Sat, Jun 25, 2022 at 12:03 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 44 quoted lines
>
> Han Xin <hanxin.hx@bytedance.com> writes:
>
> > 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 | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 8ba5ca1534..f920e3b0ae 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -1816,6 +1816,15 @@ test_lazy_prereq ULIMIT_FILE_DESCRIPTORS '
> > run_with_limited_open_files true
> > '
> >
> > +run_with_limited_processses () {
> > + (ulimit -u 512 && "$@")
>
> The "-u" presumably is a way to say that the current user can have
> only 512 processes at once that is supported by bash and ksh? dash
> seems to use "-p" for this but "-p" of course means something
> completely different to other shells (and is read-only), which is a
> mess X-<.
>
> I suspect that it is OK to make it practically bash-only, but then ...
>
> > +}
> > +
> > +test_lazy_prereq ULIMIT_PROCESSES '
> > + test_have_prereq !HPPA,!MINGW,!CYGWIN &&
> > + run_with_limited_processses true
>
> ... as this lazy-prereq makes a trial run that would fail when the
> system does not allow "ulimit -u 512", do we need the platform
> specific prereq check? I am wondering if the second line alone is
> sufficient.
>Yes,the second line alone is sufficient.
Show 5 quoted lines
> Also, 512 is not a number I would exactly call "limit forking". > Does it have to be so high, I wonder. Of course it cannot be so low > like 3 or 8 or even 32, as per-user limitation counts your window > manager and shells running in other windows. >
It's hard to say. I've tried adjusting it to 256, but the test cases in next patch will always fail with the following "err":
./test-lib.sh: fork: Resource temporarily unavailable
> What you ideally want is an option that lets you limit the number of > processes the shell that issued the ulimit call can spawn > simultaneously, but I didn't find it in "man bash/dash/ksh". >
Maybe I should use "lib-bash.sh" instead of "test-lib.sh" just like t9902 and t9903? The different meanings of "-p" in bash and dash really make this tricky.
Thanks. -Han Xin
Show 5 quoted lines
> > +'
> > +
> > build_option () {
> > git version --build-options |
> > sed -ne "s/^$1: //p"