From 8e8cad2f1a085366eff89f6299d49637cb4d425f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 2 Jun 2026 21:29:42 +0300 Subject: test(integration): add inotify family tracing coverage Add an inotify-basic ioworkload scenario and an end-to-end integration test covering the inotify IPC family, which previously had no integration coverage (only inotify_init1 had a unit-level eventloop test). The scenario issues inotify_init1(IN_CLOEXEC) -> inotify_add_watch on a temp file (IN_CREATE|IN_DELETE|IN_MODIFY) -> inotify_rm_watch -> close. It is non-blocking: it registers and removes the watch without reading events, and cleans up the temp dir on return. TestInotifyBasic asserts enter_inotify_init1, enter_inotify_add_watch, enter_inotify_rm_watch and enter_close each fire at least once, with positive durations and PID/comm hermetic guards. The init1 instance fd resolves to the inotifyfd: path label; add_watch/rm_watch capture the instance fd@arg0 which resolves to the same registered label. Co-Authored-By: Claude Opus 4.8 --- integrationtests/ipc_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'integrationtests') diff --git a/integrationtests/ipc_test.go b/integrationtests/ipc_test.go index 9c1efcc..8420b9b 100644 --- a/integrationtests/ipc_test.go +++ b/integrationtests/ipc_test.go @@ -9,6 +9,8 @@ const mqPayloadLen = uint64(14) var ipcDescriptorTraceArgs = []string{"-trace-syscalls", "pipe,pipe2,eventfd,eventfd2,close"} +var inotifyTraceArgs = []string{"-trace-syscalls", "inotify_init1,inotify_add_watch,inotify_rm_watch,close"} + func TestPipeBasic(t *testing.T) { result, _ := runScenarioResultWithIorArgs(t, "pipe-basic", []ExpectedEvent{ {Tracepoint: "enter_pipe", MinCount: 1}, @@ -77,6 +79,37 @@ func TestFdFromAirEventfdUsers(t *testing.T) { assertTracepointPathPrefix(t, result, "enter_timerfd_create", "timerfd:") } +// TestInotifyBasic asserts end-to-end tracing of the inotify IPC family. +// The inotify-basic scenario issues inotify_init1(IN_CLOEXEC) -> +// inotify_add_watch(fd, file, IN_CREATE|IN_DELETE|IN_MODIFY) -> +// inotify_rm_watch(fd, wd) -> close(fd). We assert all three inotify enter +// tracepoints fire at least once, with positive durations and the hermetic +// PID/comm guards already applied by runScenarioResultWithIorArgs. The +// inotify_init1 instance fd resolves to the "inotifyfd:" path label, and the +// close on that same fd carries the same label. +func TestInotifyBasic(t *testing.T) { + result, _ := runScenarioResultWithIorArgs(t, "inotify-basic", []ExpectedEvent{ + {Tracepoint: "enter_inotify_init1", MinCount: 1}, + {Tracepoint: "enter_inotify_add_watch", MinCount: 1}, + {Tracepoint: "enter_inotify_rm_watch", MinCount: 1}, + {Tracepoint: "enter_close", MinCount: 1}, + }, inotifyTraceArgs) + + // inotify_init1 returns a registered fd labelled inotifyfd:, and the + // subsequent close of that fd resolves to the same tracked label. + assertTracepointPathPrefix(t, result, "enter_inotify_init1", "inotifyfd:") + assertTracepointPathPrefix(t, result, "enter_close", "inotifyfd:") + + // inotify_add_watch / inotify_rm_watch capture the inotify instance fd + // (kind=fd@arg0), so they too resolve to the tracked inotifyfd: label. + assertTracepointPathPrefix(t, result, "enter_inotify_add_watch", "inotifyfd:") + assertTracepointPathPrefix(t, result, "enter_inotify_rm_watch", "inotifyfd:") + + assertEventDurationPositive(t, result, ExpectedEvent{Tracepoint: "enter_inotify_init1", Comm: "ioworkload"}) + assertEventDurationPositive(t, result, ExpectedEvent{Tracepoint: "enter_inotify_add_watch", Comm: "ioworkload"}) + assertEventDurationPositive(t, result, ExpectedEvent{Tracepoint: "enter_inotify_rm_watch", Comm: "ioworkload"}) +} + func TestPosixMqBasic(t *testing.T) { enableParallelIfRequested(t) h := newTestHarness(t) -- cgit v1.2.3