Extend inotify01 and inotify02 tests to verify cookie value returned by the kernel is sane (0 for all except rename events and matches for the two rename events). There has been a kernel bug caused by commit 7053aee26a35 which would be caught by these tests.
Signed-off-by: Jan Kara <[email protected]> --- testcases/kernel/syscalls/inotify/inotify01.c | 16 ++++++++++++---- testcases/kernel/syscalls/inotify/inotify02.c | 23 ++++++++++++++++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) Guys, can you please consider this patch for merging? Thanks! diff --git a/testcases/kernel/syscalls/inotify/inotify01.c b/testcases/kernel/syscalls/inotify/inotify01.c index aa82d596f313..835ca84fa936 100644 --- a/testcases/kernel/syscalls/inotify/inotify01.c +++ b/testcases/kernel/syscalls/inotify/inotify01.c @@ -160,10 +160,18 @@ int main(int ac, char **av) event->wd, event->mask, event->cookie, event->len); } else if (event_set[test_num] == event->mask) { - tst_resm(TPASS, "get event: wd=%d mask=%x" - " cookie=%u len=%u", - event->wd, event->mask, - event->cookie, event->len); + if (event->cookie != 0) { + tst_resm(TFAIL, + "get event: wd=%d mask=%x " + "cookie=%u (expected 0) len=%u", + event->wd, event->mask, + event->cookie, event->len); + } else { + tst_resm(TPASS, "get event: wd=%d " + "mask=%x cookie=%u len=%u", + event->wd, event->mask, + event->cookie, event->len); + } } else { tst_resm(TFAIL, "get event: wd=%d mask=%x " diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c index 5d4cbe06ca98..ee62c01f94fb 100644 --- a/testcases/kernel/syscalls/inotify/inotify02.c +++ b/testcases/kernel/syscalls/inotify/inotify02.c @@ -83,6 +83,7 @@ int main(int ac, char **av) { int lc; char *msg; + unsigned int stored_cookie = UINT_MAX; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); @@ -224,12 +225,31 @@ int main(int ac, char **av) (!strncmp (event_set[test_num].name, event->name, event->len))) { + if (event->mask == IN_MOVED_FROM) { + if (event->cookie == 0) + goto cookie_fail; + stored_cookie = event->cookie; + } else if (event->mask == IN_MOVED_TO) { + if (event->cookie != stored_cookie) + goto cookie_fail; + stored_cookie = UINT_MAX; + } else { + if (event->cookie != 0) + goto cookie_fail; + } tst_resm(TPASS, "get event: wd=%d mask=%x" " cookie=%u len=%u name=\"%s\"", event->wd, event->mask, event->cookie, event->len, event->name); - + goto next; +cookie_fail: + tst_resm(TFAIL, + "get event: wd=%d mask=%x cookie=%u " + "(wrong) len=%u name=\"%s\"", + event->wd, event->mask, + event->cookie, event->len, + event->name); } else { tst_resm(TFAIL, "get event: wd=%d mask=%x " "(expected %x) cookie=%u len=%u " @@ -241,6 +261,7 @@ int main(int ac, char **av) strcmp(event_set[test_num].name, event->name)); } +next: test_num++; i += EVENT_SIZE + event->len; } -- 1.8.1.4 ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
