[LTP] [PATCH 2/4] fanotify03: Add test cases for permission events on children
Petr Vorel
pvorel@suse.cz
Tue Feb 11 18:56:39 CET 2025
Hi Amir, Jan,
> 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.
FYI I'm going to merge with the diff below (discussed change).
Jan, may I add your RBT?
Kind regards,
Petr
> Thanks,
> Amir.
diff --git testcases/kernel/syscalls/fanotify/fanotify03.c testcases/kernel/syscalls/fanotify/fanotify03.c
index 4b2f6e45e1..a19f49d131 100644
--- testcases/kernel/syscalls/fanotify/fanotify03.c
+++ testcases/kernel/syscalls/fanotify/fanotify03.c
@@ -158,8 +158,6 @@ static void generate_events(struct tcase *tc)
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) {
- tst_res(TINFO, "read() got errno %d as expected", errno);
}
SAFE_CLOSE(fd);
@@ -169,8 +167,6 @@ static void generate_events(struct tcase *tc)
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) {
- tst_res(TINFO, "execve() got errno %d as expected", errno);
}
}
More information about the ltp
mailing list