From 272d23e1e255275a61952ea9f13d1fbdd5069433 Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Thu, 8 Feb 2024 19:36:11 -0800 Subject: [PATCH] Fix inotify_test_native on Buildkite. PiperOrigin-RevId: 605496604 --- test/syscalls/linux/inotify.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/syscalls/linux/inotify.cc b/test/syscalls/linux/inotify.cc index b64c8d87e..193f78031 100644 --- a/test/syscalls/linux/inotify.cc +++ b/test/syscalls/linux/inotify.cc @@ -1871,11 +1871,26 @@ TEST(Inotify, SpliceOnWatchTarget) { EXPECT_THAT(splice(pipefds[0], nullptr, fd.get(), nullptr, 1, /*flags=*/0), SyscallSucceedsWithValue(1)); + // On Linux, between 983652c69199 ("splice: report related fsnotify events") + // and d53471ba6f7a ("splice: remove permission hook from + // iter_file_splice_write()"), splice(2) generates two modification events in + // many cases, by calling fsnotify_modify() in both fs/splice.c:do_splice() + // and fs/splice.c:iter_file_splice_write() => + // fs/read_write.c:vfs_iter_write() => do_iter_write(). events = ASSERT_NO_ERRNO_AND_VALUE(DrainEvents(inotify_fd.get())); - ASSERT_THAT(events, Are({ - Event(IN_MODIFY, dir_wd, Basename(file.path())), - Event(IN_MODIFY, file_wd), - })); + if (events.size() == 4) { + EXPECT_THAT(events, Are({ + Event(IN_MODIFY, dir_wd, Basename(file.path())), + Event(IN_MODIFY, file_wd), + Event(IN_MODIFY, dir_wd, Basename(file.path())), + Event(IN_MODIFY, file_wd), + })); + } else { + EXPECT_THAT(events, Are({ + Event(IN_MODIFY, dir_wd, Basename(file.path())), + Event(IN_MODIFY, file_wd), + })); + } } // Watches on a parent should not be triggered by actions on a hard link to one