[PATCH v7 1/4] tests: replace read by xread

Frederic Berat fberat@redhat.com
Tue Jun 13 14:22:28 GMT 2023


On Mon, Jun 12, 2023 at 6:58 PM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Mon, 12 Jun 2023, Frédéric Bérat via Libc-alpha wrote:
>
> > @@ -56,7 +58,7 @@ tf (void *arg)
> >
> >    /* This call should block and be cancelable.  */
> >    char buf[20];
> > -  read (fd[0], buf, sizeof (buf));
> > +  xread (fd[0], buf, sizeof (buf));
>
> Since the comment suggests this code is actually testing a property of the
> read function, it seems doubtful whether it's appropriate to change it to
> call xread - which would impose an API requirement on xread that it calls
> read in exactly the way under test.  Calling x* functions is fine in
> testcases when the function in question is not under test - for example,
> when the point of calling xread is just to read some data, with the
> details of how that's done being irrelevant - but questionable when the
> test is a test of read itself.
>

My understanding is that's not really a property of read that is
tested here, since it could be theoretically replaced by anything that
blocks and is a cancellation point. So in principle, the way it is
done is still irrelevant.

That said, I see your point. The wrapper may bring opacity that is not
wanted here.


> > @@ -32,7 +34,7 @@ tf (void *arg)
> >      }
> >
> >    char buf[10];
> > -  read (fds[0], buf, sizeof (buf));
> > +  xread (fds[0], buf, sizeof (buf));
> >
> >    puts ("read returned");
>
> The same might apply here.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com



More information about the Libc-alpha mailing list