git: 333f668468f0 - main - path_test: Correct the kevent test
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Apr 2022 15:47:43 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=333f668468f0675e1e001f6fcc506e901e58c36e commit 333f668468f0675e1e001f6fcc506e901e58c36e Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-04-18 15:45:45 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-04-18 15:45:45 +0000 path_test: Correct the kevent test Perhaps surprisingly, and contrary to the expectations of path_test:path_event, NOTE_LINK events are not raised when a file is unlinked. Prior to commit bf13db086b84, the test happened to work because unlinking the file would cause the vnode to be recycled, and EVFILT_VNODE knotes deliver an event with EV_EOF set when the vnode is doomed. Since the test did not verify the note type, the test succeeded. After commit bf13db086b84, the vnode is not recycled after being unlinked and so the test hangs. Fix the test by waiting for NOTE_DELETE instead, and check that we got the note that we expected. Reported by: Jenkins MFC after: 3 days Sponsored by: The FreeBSD Foundation --- tests/sys/file/path_test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c index 39c653a07c1b..e8c8410a0bdf 100644 --- a/tests/sys/file/path_test.c +++ b/tests/sys/file/path_test.c @@ -452,14 +452,17 @@ ATF_TC_BODY(path_event, tc) ATF_REQUIRE_MSG(kevent(kq, &ev, 1, NULL, 0, NULL) == 0, FMT_ERR("kevent")); - /* Try to get a EVFILT_VNODE/NOTE_LINK event through a path fd. */ - EV_SET(&ev, pathfd, EVFILT_VNODE, EV_ADD | EV_ENABLE, NOTE_LINK, 0, 0); + /* Try to get a EVFILT_VNODE/NOTE_DELETE event through a path fd. */ + EV_SET(&ev, pathfd, EVFILT_VNODE, EV_ADD | EV_ENABLE, NOTE_DELETE, 0, + 0); ATF_REQUIRE_MSG(kevent(kq, &ev, 1, NULL, 0, NULL) == 0, FMT_ERR("kevent")); ATF_REQUIRE_MSG(funlinkat(AT_FDCWD, path, pathfd, 0) == 0, FMT_ERR("funlinkat")); ATF_REQUIRE_MSG(kevent(kq, NULL, 0, &ev, 1, NULL) == 1, FMT_ERR("kevent")); + ATF_REQUIRE_MSG(ev.fflags == NOTE_DELETE, + "unexpected fflags %#x", ev.fflags); EV_SET(&ev, pathfd, EVFILT_VNODE, EV_DELETE, 0, 0, 0); ATF_REQUIRE_MSG(kevent(kq, &ev, 1, NULL, 0, NULL) == 0, FMT_ERR("kevent"));