[LTP] [PATCH 2/4] fanotify03: Add test cases for permission events on children

Amir Goldstein amir73il@gmail.com
Mon Feb 10 17:55:50 CET 2025


On Mon, Feb 10, 2025 at 4:25 PM Jan Kara <jack@suse.cz> wrote:
>
> On Mon 10-02-25 16:13:14, Amir Goldstein wrote:
> > Verify that permission events are delivered iff parent is watching
> > children.
> >
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>
> Overall looks ok but:
>
> > -     if (read(fd, buf, BUF_SIZE) != -1)
> > +     exp_ret = exp_errno ? -1 : 1;
> > +     errno = 0;
> > +     if (read(fd, buf, BUF_SIZE) != exp_ret || errno != exp_errno) {
> > +             tst_res(TFAIL, "read() got errno %d (expected %d)", errno, exp_errno);
> >               exit(3);
> > +     } else if (errno == exp_errno) {
>                 ^^ Why is this condition needed? It is always true AFAICT.
>
> > +             tst_res(TINFO, "read() got errno %d as expected", errno);
> > +     }
> >
> >       SAFE_CLOSE(fd);
> >
> > -     if (execve(FILE_EXEC_PATH, argv, environ) != -1)
> > +     exp_ret = exp_errno ? -1 : 0;
> > +     errno = 0;
> > +     if (execve(FILE_EXEC_PATH, argv, environ) != exp_ret || errno != exp_errno) {
> > +             tst_res(TFAIL, "execve() got errno %d (expected %d)", errno, exp_errno);
> >               exit(5);
> > +     } else if (errno == exp_errno) {
>                 ^^^ and here as well...
>
> > +             tst_res(TINFO, "execve() got errno %d as expected", errno);

You are right.
I was "backported" from the pre-content test.
The two else statements can be removed in this patch.

Thanks,
Amir.


More information about the ltp mailing list