[PATCH v7 4/4] tests: replace fgets by xfgets

Joseph Myers joseph@codesourcery.com
Tue Jun 13 18:25:35 GMT 2023


On Tue, 13 Jun 2023, Siddhesh Poyarekar wrote:

> > diff --git a/assert/test-assert-perr.c b/assert/test-assert-perr.c
> > index 8496db6ffd..09a4fcb6ef 100644
> > --- a/assert/test-assert-perr.c
> > +++ b/assert/test-assert-perr.c
> > @@ -11,6 +11,8 @@
> >   #include <string.h>
> >   #include <setjmp.h>
> >   +#include <support/xstdio.h>
> > +
> >   jmp_buf rec;
> >   char buf[160];
> >   @@ -70,15 +72,15 @@ main(void)
> >       failed = 1; /* should not happen */
> >       rewind (stderr);
> > -  fgets (buf, 160, stderr);
> > +  xfgets (buf, 160, stderr);
> 
> Joseph, would you apply the same rationale for these tests too, i.e. since the
> test involves interaction with stdio and signals, would you avoid adding an
> xstdio abstraction here to test stdio directly?

I think this test is using fgets to check file contents rather than 
testing particular things about how fgets behaves.

> Likewise for the stdio-common test here and in patch 3/4, what do you think?

And those look they are using fread to check contents while testing some 
other stdio functions.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Libc-alpha mailing list