inotify tests for v5.9 regression
cover inotify tests for v5.9 regression
Hi Petr,
Here is the test for the other v5.9 regression that I mentioned earlier. The fix commit has just been merged to master.
History:
Originally, inotify10 was written to cover a bug that was detected during the review of the fsnotify changes for v5.9, but was not merged to v5.9. Later, I wrote test case #3 to cover another bug that was merged to v5.9. While testing the v5.9-bug-fix in linux-next, Hugh Dickins reported [1] a bug introduced by the v5.9-bug-fix, so I added two more test cases to cover the bug-in-the-bug-fix.
The bug-in-the-bug-fix was fixed before the v5.9-bug-fix was merged.
Long story short, the only test case expected to fail is test case #3 on kernel >= v5.9 and now fixed in master :-)
Thanks,
Amir.
[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
Amir Goldstein (3):
syscalls/inotify10: Generalize for more test cases syscalls/inotify10: Add test cases with two groups syscalls/inotify10: Test two inotify groups with parent and child
watches
testcases/kernel/syscalls/inotify/inotify10.c | 126 ++++++++++++++---- 1 file changed, 98 insertions(+), 28 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 syscalls/inotify10: Generalize for more test cases
Generalize the parent and child watches test to allow adding new parent and child watch related test cases.
--- testcases/kernel/syscalls/inotify/inotify10.c | 81 +++++++++++++------ 1 file changed, 55 insertions(+), 26 deletions(-)
testcases/kernel/syscalls/inotify/inotify10.c +55 -26
@@ -5,7 +5,9 @@* Started by Amir Goldstein <[email protected]> * * DESCRIPTION -* Check that event is reported to both watching parent and watching child +* Check that event is reported to watching parent and watching child +* based on their interest +* */ #include "config.h"
@@ -37,48 +39,74 @@ struct event_t {#define TEST_DIR "test_dir"#define TEST_FILE "test_file" +static struct tcase { +const char *tname; +unsigned int parent_mask; +unsigned int subdir_mask; +unsigned int child_mask; +} tcases[] = { + { +"Group with parent and child watches" , +IN_ATTRIB ,IN_ATTRIB ,IN_ATTRIB , + }, +}; +struct event_t event_set[EVENT_MAX ];char event_buf[EVENT_BUF_LEN ];int fd_notify; -static void verify_inotify (void ) +static void verify_inotify (unsigned int n) { +struct tcase *tc = &tcases[n];int i =0 , test_num =0 , len; -int wd_parent, wd_dir, wd_file; +int wd_parent =0 , wd_subdir =0 , wd_child =0 ;int test_cnt =0 ; +tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); + fd_notify =SAFE_MYINOTIFY_INIT (); -/* Set watch on both parent dir and children */ - wd_parent =SAFE_MYINOTIFY_ADD_WATCH (fd_notify,"." ,IN_ATTRIB ); - wd_dir =SAFE_MYINOTIFY_ADD_WATCH (fd_notify,TEST_DIR ,IN_ATTRIB ); - wd_file =SAFE_MYINOTIFY_ADD_WATCH (fd_notify,TEST_FILE ,IN_ATTRIB ); +/* Setup watches on parent dir and children */ +if (tc->parent_mask) + wd_parent =SAFE_MYINOTIFY_ADD_WATCH (fd_notify,"." , tc->parent_mask); +if (tc->subdir_mask) + 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);/* -* Generate events on file and subdir that should be reported to parent -* dir with name and to children without name. +* Generate IN_ATTRIB events on file and subdir that should be reported to parent +* dir with name and to children without name if they have IN_ATTRIB in their mask. */ SAFE_CHMOD (TEST_DIR ,0755 );SAFE_CHMOD (TEST_FILE ,0644 ); - event_set[test_cnt].wd = wd_parent; - event_set[test_cnt].mask =IN_ATTRIB |IN_ISDIR ; -strcpy (event_set[test_cnt].name,TEST_DIR ); - test_cnt++; - event_set[test_cnt].wd = wd_dir; - event_set[test_cnt].mask =IN_ATTRIB |IN_ISDIR ; -strcpy (event_set[test_cnt].name,"" ); - test_cnt++; - event_set[test_cnt].wd = wd_parent; - event_set[test_cnt].mask =IN_ATTRIB ; -strcpy (event_set[test_cnt].name,TEST_FILE ); - test_cnt++; - event_set[test_cnt].wd = wd_file; - event_set[test_cnt].mask =IN_ATTRIB ; -strcpy (event_set[test_cnt].name,"" ); - test_cnt++; +if (wd_parent && (tc->parent_mask &IN_ATTRIB )) { + event_set[test_cnt].wd = wd_parent; + event_set[test_cnt].mask = tc->parent_mask |IN_ISDIR ; +strcpy (event_set[test_cnt].name,TEST_DIR ); + test_cnt++; + } +if (wd_subdir && (tc->subdir_mask &IN_ATTRIB )) { + event_set[test_cnt].wd = wd_subdir; + event_set[test_cnt].mask = tc->subdir_mask |IN_ISDIR ; +strcpy (event_set[test_cnt].name,"" ); + test_cnt++; + } +if (wd_parent && (tc->parent_mask &IN_ATTRIB )) { + event_set[test_cnt].wd = wd_parent; + event_set[test_cnt].mask = tc->parent_mask; +strcpy (event_set[test_cnt].name,TEST_FILE ); + test_cnt++; + } +if (wd_child && (tc->child_mask &IN_ATTRIB )) { + event_set[test_cnt].wd = wd_child; + event_set[test_cnt].mask = tc->child_mask; +strcpy (event_set[test_cnt].name,"" ); + test_cnt++; + } len =read (fd_notify, event_buf,EVENT_BUF_LEN );if (len ==-1 )
@@ -141,7 +169,8 @@ static struct tst_test test = { .needs_tmpdir = 1, .setup = setup, .cleanup = cleanup, - .test_all = verify_inotify, + .test = verify_inotify, + .tcnt = ARRAY_SIZE(tcases), };#else
Signature · 1 line
2.25.1
PATCH 1/3 syscalls/inotify10: Generalize for more test cases
Hi Amir,
Quoted 2 lines
Generalize the parent and child watches test to allow adding new parent and child watch related test cases.
Kind regards,
Petr
PATCH 2/3 syscalls/inotify10: Add test cases with two groups
In reply to Amir Goldstein--- testcases/kernel/syscalls/inotify/inotify10.c | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/inotify/inotify10.c +29 -1
@@ -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 = {
Signature · 1 line
2.25.1
PATCH 2/3 syscalls/inotify10: Add test cases with two groups
PATCH 3/3 syscalls/inotify10: Test two inotify groups with parent and child watches
In reply to Amir GoldsteinAdd a test case for commit fecc4559780d that fixes a bug introduced in kernel v5.9:
fsnotify: fix events reported to watching parent and child
--- testcases/kernel/syscalls/inotify/inotify10.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
testcases/kernel/syscalls/inotify/inotify10.c +13 -0
@@ -8,6 +8,10 @@* Check that event is reported to watching parent and watching child * based on their interest * +* Test case #3 is a regression test for commit fecc4559780d that fixes +* a bug introduced in kernel v5.9: +* +* fsnotify: fix events reported to watching parent and child */ #include "config.h"
@@ -63,6 +67,11 @@ static struct tcase { IN_ATTRIB, 0, 0, 0, IN_ATTRIB, IN_ATTRIB, }, + { +"Two Groups with parent and child watches for different events" , +IN_ATTRIB ,IN_OPEN ,IN_OPEN , + IN_OPEN, IN_ATTRIB, IN_ATTRIB, + }, };struct event_t event_set[EVENT_MAX ];
@@ -199,6 +208,10 @@ static struct tst_test test = { .cleanup = cleanup, .test = verify_inotify, .tcnt = ARRAY_SIZE(tcases), + .tags = (const struct tst_tag []) { + {"linux-git" ,"fecc4559780d" }, + {} + } };#else
Signature · 1 line
2.25.1
PATCH 3/3 syscalls/inotify10: Test two inotify groups with parent and child watches
cover inotify tests for v5.9 regression
In reply to Amir GoldsteinHi Amir,
Quoted 4 lines
Hi Petr,
Here is the test for the other v5.9 regression that I mentioned earlier. The fix commit has just been merged to master.
Thanks for your patch, LGTM. I'll probably merge it later today.
Quoted 11 lines
History:
Originally, inotify10 was written to cover a bug that was detected during the review of the fsnotify changes for v5.9, but was not merged to v5.9. Later, I wrote test case #3 to cover another bug that was merged to v5.9. While testing the v5.9-bug-fix in linux-next, Hugh Dickins reported [1] a bug introduced by the v5.9-bug-fix, so I added two more test cases to cover the bug-in-the-bug-fix.
The bug-in-the-bug-fix was fixed before the v5.9-bug-fix was merged.Long story short, the only test case expected to fail is test case #3 on kernel >= v5.9 and now fixed in master :-)
Correct, it fails on my openSUSE 5.10.0-rc5 kernel.
I tested it on someold kernels (patched 4.4; 4.9) and on some newer ones (5.8.14 and on current devel SLES kernel).
BTW interesting (nothing to be fixed in the test) that second commit slower down on newer kernels (0,200s), while on old kernels is the same (0.010s).
Kind regards,
Petr
Quoted 13 lines
Thanks,
Amir.[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
Amir Goldstein (3):
syscalls/inotify10: Generalize for more test cases syscalls/inotify10: Add test cases with two groups syscalls/inotify10: Test two inotify groups with parent and child
watchestestcases/kernel/syscalls/inotify/inotify10.c | 126 ++++++++++++++---- 1 file changed, 98 insertions(+), 28 deletions(-)
cover inotify tests for v5.9 regression
Hi Amir,
Quoted 5 lines
Quoted 4 lines
Hi Petr,
Here is the test for the other v5.9 regression that I mentioned earlier. The fix commit has just been merged to master.
Thanks for your patch, LGTM. I'll probably merge it later today.
Merged.
Thanks for your pathset. I wish other kernel subsystems were getting the same care as {fa,i}notify.
Kind regards,
Petr