[LTP] [PATCH 3/3] syscalls: select: Verify that data is available to read

Viresh Kumar viresh.kumar@linaro.org
Thu Sep 3 12:35:56 CEST 2020


On 03-09-20, 17:10, Li Wang wrote:
> On Thu, Sep 3, 2020 at 2:40 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> 
> > select() returns a positive value on success if timeout hasn't happened,
> > else returns 0. Check that and send some data to the write file
> > descriptor for the same.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> >
> > ---
> > Cyril,
> >
> > Is this what you were looking for ? I am not sure why, but the last
> > test (with named pipe) times out all the time.
> > ---
> >  testcases/kernel/syscalls/select/select01.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/select/select01.c
> > b/testcases/kernel/syscalls/select/select01.c
> > index 4367e7f3af3f..b3dcf1fff6f3 100644
> > --- a/testcases/kernel/syscalls/select/select01.c
> > +++ b/testcases/kernel/syscalls/select/select01.c
> > @@ -25,24 +25,31 @@ static struct select_info {
> >         int nfds;
> >         fd_set *readfds;
> >         fd_set *writefds;
> > +       int *writefd;
> >  } tests[] = {
> > -       {4, &readfds_reg, NULL},
> > -       {5, &readfds_pipe, &writefds_pipe},
> > -       {5, &readfds_npipe, &writefds_npipe},
> > +       {4, &readfds_reg, NULL, NULL},
> > +       {5, &readfds_pipe, &writefds_pipe, &fds_pipe[1]},
> > +       {5, &readfds_npipe, &writefds_npipe, &fd_npipe},
> >
> 
> The 'nfds' should be equal to 'fd + 1', otherwise, it gets timeout as you
> mentioned above.
> 
>   {7, &readfds_npipe, &writefds_npipe, &fd_npipe}

Thanks again Li. You were spot on once again.

I will wait for Cyril's review as well and then send V2.

-- 
viresh


More information about the ltp mailing list