From: Jan Kara <jack@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/5] syscalls/fanotify09: Add test case with two non-dir children
Date: Mon, 7 Dec 2020 12:01:29 +0100 [thread overview]
Message-ID: <20201207110129.GF28106@quack2.suse.cz> (raw)
In-Reply-To: <20201204095930.866421-5-amir73il@gmail.com>
On Fri 04-12-20 11:59:29, Amir Goldstein wrote:
> The existing test cases generate FAN_MODIFY event on a non-dir child
> and FAN_CLOSE_NOWRITE event the parent or sibling subdir.
>
> Add a test case that generates FAN_CLOSE_NOWRITE on a sibling non-dir
> child.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> .../kernel/syscalls/fanotify/fanotify09.c | 38 ++++++++++++++-----
> 1 file changed, 28 insertions(+), 10 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify09.c b/testcases/kernel/syscalls/fanotify/fanotify09.c
> index 7bb901cf3..0f1923981 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify09.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify09.c
> @@ -55,13 +55,14 @@ static char event_buf[EVENT_BUF_LEN];
>
> #define MOUNT_NAME "mntpoint"
> #define DIR_NAME "testdir"
> +#define FILE2_NAME "testfile"
> static int mount_created;
>
> static struct tcase {
> const char *tname;
> struct fanotify_mark_type mark;
> unsigned int ondir;
> - const char *testdir;
> + const char *close_nowrite;
> int nevents;
> } tcases[] = {
> {
> @@ -92,6 +93,13 @@ static struct tcase {
> DIR_NAME,
> 2,
> },
> + {
> + "Events on non-dir children with both parent and mount marks",
> + INIT_FANOTIFY_MARK_TYPE(MOUNT),
> + 0,
> + FILE2_NAME,
> + 2,
> + },
> };
>
> static void create_fanotify_groups(struct tcase *tc)
> @@ -112,7 +120,7 @@ static void create_fanotify_groups(struct tcase *tc)
> SAFE_FANOTIFY_MARK(fd_notify[i],
> FAN_MARK_ADD | mark->flag,
> FAN_CLOSE_NOWRITE | onchild,
> - AT_FDCWD, tc->testdir);
> + AT_FDCWD, tc->close_nowrite);
>
> /*
> * Add inode mark on parent for each group with MODIFY event,
> @@ -216,9 +224,9 @@ static void test_fanotify(unsigned int n)
> */
> SAFE_FILE_PRINTF(fname, "1");
> /*
> - * generate FAN_CLOSE_NOWRITE event on a testdir (subdir or ".")
> + * generate FAN_CLOSE_NOWRITE event on a child, subdir or "."
> */
> - dirfd = SAFE_OPEN(tc->testdir, O_RDONLY);
> + dirfd = SAFE_OPEN(tc->close_nowrite, O_RDONLY);
> if (dirfd >= 0)
> SAFE_CLOSE(dirfd);
>
> @@ -243,7 +251,7 @@ static void test_fanotify(unsigned int n)
> event = (struct fanotify_event_metadata *)event_buf;
> verify_event(0, event, FAN_MODIFY, "");
> event = FAN_EVENT_NEXT(event, ret);
> - if (tc->ondir) {
> + if (tc->nevents > 1) {
> verify_event(0, event, FAN_CLOSE_NOWRITE, "");
> event = FAN_EVENT_NEXT(event, ret);
> }
> @@ -260,14 +268,23 @@ static void test_fanotify(unsigned int n)
>
> /*
> * Then verify the rest of the groups did not get the MODIFY event and
> - * did not get the FAN_CLOSE_NOWRITE event on testdir.
> + * got the FAN_CLOSE_NOWRITE event only on a non-directory.
> */
> for (i = 1; i < NUM_GROUPS; i++) {
> - ret = read(fd_notify[i], event_buf, FAN_EVENT_METADATA_LEN);
> + ret = read(fd_notify[i], event_buf, EVENT_BUF_LEN);
> if (ret > 0) {
> - event_res(TFAIL, i, event, "");
> - if (event->fd != FAN_NOFD)
> - SAFE_CLOSE(event->fd);
> + uint32_t expect = 0;
> +
> + if (tc->nevents > 1 && !tc->ondir)
> + expect = FAN_CLOSE_NOWRITE;
> +
> + event = (struct fanotify_event_metadata *)event_buf;
> + verify_event(i, event, expect, "");
> +
> + for (; FAN_EVENT_OK(event, ret); FAN_EVENT_NEXT(event, ret)) {
> + if (event->fd != FAN_NOFD)
> + SAFE_CLOSE(event->fd);
> + }
> continue;
> }
>
> @@ -295,6 +312,7 @@ static void setup(void)
>
> sprintf(fname, "tfile_%d", getpid());
> SAFE_FILE_PRINTF(fname, "1");
> + SAFE_FILE_PRINTF(FILE2_NAME, "1");
> }
>
> static void cleanup(void)
> --
> 2.25.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-12-07 11:01 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 9:59 [LTP] [PATCH 0/5] Fanotify cleanup and test for v5.9 regression Amir Goldstein
2020-12-04 9:59 ` [LTP] [PATCH 1/5] syscalls/fanotify: Generalize check for FAN_REPORT_FID support Amir Goldstein
2020-12-04 13:52 ` Petr Vorel
2020-12-07 10:48 ` Jan Kara
2020-12-04 9:59 ` [LTP] [PATCH 2/5] syscalls/fanotify: Use generic checks for fanotify_init flags Amir Goldstein
2020-12-04 13:55 ` Petr Vorel
2020-12-07 10:52 ` Jan Kara
2020-12-04 9:59 ` [LTP] [PATCH 3/5] syscalls/fanotify09: Read variable length events Amir Goldstein
2020-12-04 14:16 ` Petr Vorel
2020-12-07 10:55 ` Jan Kara
2020-12-07 11:44 ` Petr Vorel
2020-12-07 11:57 ` Petr Vorel
2020-12-07 14:07 ` Amir Goldstein
2020-12-07 14:22 ` Petr Vorel
2020-12-07 16:17 ` Amir Goldstein
2020-12-08 7:30 ` Petr Vorel
2020-12-04 9:59 ` [LTP] [PATCH 4/5] syscalls/fanotify09: Add test case with two non-dir children Amir Goldstein
2020-12-04 14:19 ` Petr Vorel
2020-12-07 11:01 ` Jan Kara [this message]
2020-12-04 9:59 ` [LTP] [PATCH 5/5] syscalls/fanotify09: Add test case for events with filename info Amir Goldstein
2020-12-04 14:22 ` Petr Vorel
2020-12-07 11:11 ` Jan Kara
2020-12-04 14:27 ` [LTP] [PATCH 0/5] Fanotify cleanup and test for v5.9 regression Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201207110129.GF28106@quack2.suse.cz \
--to=jack@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox