[LTP] [PATCH] open04: add EMFILE check

Li Wang liwang@redhat.com
Fri Sep 16 03:36:31 CEST 2022


On Thu, Sep 15, 2022 at 10:19 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > > diff --git a/testcases/kernel/syscalls/open/open04.c
> b/testcases/kernel/syscalls/open/open04.c
> > > index d452405d4..01a8b12d6 100644
> > > --- a/testcases/kernel/syscalls/open/open04.c
> > > +++ b/testcases/kernel/syscalls/open/open04.c
> > > @@ -33,7 +33,12 @@ static void setup(void)
> >
> > >     for (i = first + 1; i < fds_limit; i++) {
> > >             sprintf(fname, FNAME ".%d", i);
> > > -           fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0777);
> > > +           fd = open(fname, O_RDWR | O_CREAT, 0777);
> > > +           if (fd == -1) {
> > > +                   if (errno != EMFILE)
> > > +                           tst_brk(TBROK, "Expected EMFILE but got
> %d", errno);
> > > +                   break;
> > > +           }
> > >             fds[i - first] = fd;
> > >     }
> > >  }
> >
> > LGTM.
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> I faintly remmeber a similar patch where we decided not to work around
> for a test harness leaking filedescriptors into testcases.
>

This also should be a solution, I searched the mailing list and got a
patch[1].
Do you mean adding that close-on-exec flag when opening fd in harness?

[1] https://lists.linux.it/pipermail/ltp/2020-November/019650.html

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20220916/6472622c/attachment.htm>


More information about the ltp mailing list