All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups
Date: Fri, 18 Dec 2020 09:06:30 +0200	[thread overview]
Message-ID: <20201218070631.1182292-3-amir73il@gmail.com> (raw)
In-Reply-To: <20201218070631.1182292-1-amir73il@gmail.com>

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/inotify/inotify10.c | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index baa955a0a..17aafc773 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -44,10 +44,24 @@ static struct tcase {
 	unsigned int parent_mask;
 	unsigned int subdir_mask;
 	unsigned int child_mask;
+	unsigned int parent_mask_other;
+	unsigned int subdir_mask_other;
+	unsigned int child_mask_other;
 } tcases[] = {
 	{
 		"Group with parent and child watches",
 		IN_ATTRIB, IN_ATTRIB, IN_ATTRIB,
+		0, 0, 0,
+	},
+	{
+		"Group with child watches and other group with parent watch",
+		0, IN_ATTRIB, IN_ATTRIB,
+		IN_ATTRIB, 0, 0,
+	},
+	{
+		"Group with parent watch and other group with child watches",
+		IN_ATTRIB, 0, 0,
+		0, IN_ATTRIB, IN_ATTRIB,
 	},
 };
 
@@ -55,7 +69,7 @@ struct event_t event_set[EVENT_MAX];
 
 char event_buf[EVENT_BUF_LEN];
 
-int fd_notify;
+int fd_notify, fd_notify_other;
 
 static void verify_inotify(unsigned int n)
 {
@@ -67,6 +81,7 @@ static void verify_inotify(unsigned int n)
 	tst_res(TINFO, "Test #%d: %s", n, tc->tname);
 
 	fd_notify = SAFE_MYINOTIFY_INIT();
+	fd_notify_other = SAFE_MYINOTIFY_INIT();
 
 	/* Setup watches on parent dir and children */
 	if (tc->parent_mask)
@@ -75,6 +90,16 @@ static void verify_inotify(unsigned int n)
 		wd_subdir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, tc->subdir_mask);
 	if (tc->child_mask)
 		wd_child = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, tc->child_mask);
+	/*
+	 * Setup watches on "other" group to verify no intereferecne with our group.
+	 * We do not check events reported to the "other" group.
+	 */
+	if (tc->parent_mask_other)
+		SAFE_MYINOTIFY_ADD_WATCH(fd_notify_other, ".", tc->parent_mask_other);
+	if (tc->subdir_mask_other)
+		SAFE_MYINOTIFY_ADD_WATCH(fd_notify_other, TEST_DIR, tc->subdir_mask_other);
+	if (tc->child_mask_other)
+		SAFE_MYINOTIFY_ADD_WATCH(fd_notify_other, TEST_FILE, tc->child_mask_other);
 
 	/*
 	 * Generate IN_ATTRIB events on file and subdir that should be reported to parent
@@ -151,6 +176,7 @@ static void verify_inotify(unsigned int n)
 	}
 
 	SAFE_CLOSE(fd_notify);
+	SAFE_CLOSE(fd_notify_other);
 }
 
 static void setup(void)
@@ -163,6 +189,8 @@ static void cleanup(void)
 {
 	if (fd_notify > 0)
 		SAFE_CLOSE(fd_notify);
+	if (fd_notify_other > 0)
+		SAFE_CLOSE(fd_notify_other);
 }
 
 static struct tst_test test = {
-- 
2.25.1


  parent reply	other threads:[~2020-12-18  7:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-18  7:06 [LTP] [PATCH 0/3] inotify tests for v5.9 regression Amir Goldstein
2020-12-18  7:06 ` [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases Amir Goldstein
2020-12-18  8:32   ` Petr Vorel
2020-12-18  7:06 ` Amir Goldstein [this message]
2020-12-18  8:36   ` [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups Petr Vorel
2020-12-18  7:06 ` [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches Amir Goldstein
2020-12-18  8:53   ` Petr Vorel
2020-12-18  9:01 ` [LTP] [PATCH 0/3] inotify tests for v5.9 regression Petr Vorel
2020-12-18 16:23   ` 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=20201218070631.1182292-3-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.