[LTP] [PATCH v2] getcwd01: Implement .test_variants
Wei Gao
wegao@suse.com
Wed Jan 3 09:39:45 CET 2024
On Wed, Dec 27, 2023 at 02:21:44PM +0100, Petr Vorel wrote:
> Hi Wei,
>
> > +{
> > + char *res;
> > +
> > + errno = 0;
> > + res = getcwd(buf, size);
> Why so complicated code? Why not just use TST_EXP_FAIL2() as you do in
> tst_getcwd()? That would be way fewer lines of code. There is no problem to use
> TST_EXP_FAIL2() with libc syscall wrappers.
Current TST_EXP_FAIL2 can not handle getcwd (will return NULL). I remember in another
email thread you mention maybe we need TST_EXP_FAIL_PTR.
>
> > + TST_ERR = errno;
> > + if (res) {
> > + tst_res(TFAIL, "getcwd() succeeded unexpectedly");
> > + return;
> > + }
> > +
> > + if (TST_ERR != exp_err) {
> > + tst_res(TFAIL | TTERRNO, "getcwd() failed unexpectedly, expected %s",
> > + tst_strerrno(exp_err));
> > + return;
> > + }
> > +
> > + tst_res(TPASS | TTERRNO, "getcwd() failed as expected");
> > +}
> > +
> > diff --git a/testcases/kernel/syscalls/getcwd/getcwd01.c b/testcases/kernel/syscalls/getcwd/getcwd01.c
> > index 218bf4ef2..6decb961f 100644
> > --- a/testcases/kernel/syscalls/getcwd/getcwd01.c
> > +++ b/testcases/kernel/syscalls/getcwd/getcwd01.c
> > @@ -13,18 +13,26 @@
> > * 5) getcwd(2) fails if buf points to NULL and the size is set to 1.
> > *
> > * Expected Result:
> > + * linux syscall
> Well, I told you several times, that list requires separating by blank line
> otherwise it breaks formatting. Could you please add it and check generated
> docparse before sending a patch:
> cd metadata && make && chromium ../docparse/*.html
> We should check for it in metaparse.c or in testinfo.pl.
The original code seems can not correctly handled by docparse since format is wrong,
so acutally no any description item will appear in metadata file, same issue for
getcwd02/03/04. I will update to correct format in getcwd01 next patch.
> > * 1) getcwd(2) should return NULL and set errno to EFAULT.
> > * 2) getcwd(2) should return NULL and set errno to EFAULT.
> > * 3) getcwd(2) should return NULL and set errno to ERANGE.
> > * 4) getcwd(2) should return NULL and set errno to ERANGE.
> > * 5) getcwd(2) should return NULL and set errno to ERANGE.
> > + *
> > + * glibc
> FYI #ifdef __GLIBC__ means glibc and uclibc{,-ng}.
> Also, again missing blank line before list.
> > + * 1) getcwd(2) should return NULL and set errno to EFAULT.
> > + * 2) getcwd(2) should return NULL and set errno to ENOMEM.
> > + * 3) getcwd(2) should return NULL and set errno to EINVAL.
> > + * 4) getcwd(2) should return NULL and set errno to ERANGE.
> > + * 5) getcwd(2) should return NULL and set errno to ERANGE.
> > */
More information about the ltp
mailing list