diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-01 15:05:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-01 15:05:52 +0300 |
| commit | 877cc685fe550f2c53a9dbdf230eaa28feaf3a16 (patch) | |
| tree | e2c39419c01fae322772e868ad564c416a1c88e3 /integrationtests/ipc_sysv_test.go | |
| parent | 6a872804d93b822d530e9df93547f2fec0a8ea50 (diff) | |
test(integration): add SysV msg/sem tracing coverage
Add sysv-msg-basic and sysv-sem-basic ioworkload scenarios that exercise
the SysV message-queue and semaphore families end-to-end via raw syscalls,
mirroring the existing sysv-shm-basic scenario.
sysv-msg-basic: msgget(IPC_PRIVATE) -> msgsnd -> msgrcv -> msgctl(IPC_RMID),
using a struct msgbuf {int64 mtype; [16]byte mtext} and msgsz = body length
(excluding mtype). sysv-sem-basic: semget(IPC_PRIVATE, 1) -> semop(+1) ->
semop(-1) -> semctl(IPC_RMID), incrementing before decrementing so the
operation can never block. Both defer IPC_RMID right after the get so no
kernel IPC object leaks even on partial failure.
Add TestSysVMsgBasic and TestSysVSemBasic asserting the enter_ events for
msgget/msgsnd/msgrcv/msgctl and semget/semop/semctl are traced with
MinCount>=1 and positive duration, plus PID/comm hermetic guards.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'integrationtests/ipc_sysv_test.go')
| -rw-r--r-- | integrationtests/ipc_sysv_test.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/integrationtests/ipc_sysv_test.go b/integrationtests/ipc_sysv_test.go index 6983c08..d5f4fa9 100644 --- a/integrationtests/ipc_sysv_test.go +++ b/integrationtests/ipc_sysv_test.go @@ -36,3 +36,68 @@ func TestSysVShmBasic(t *testing.T) { assertEventDurationPositive(t, result, ExpectedEvent{Tracepoint: tp, Comm: "ioworkload"}) } } + +// sysvMsgTraceArgs restricts tracing to the SysV message-queue family so the +// captured output is dominated by the lifecycle calls the workload issues. +var sysvMsgTraceArgs = []string{ + "-trace-syscalls", + "msgget,msgsnd,msgrcv,msgctl", +} + +// TestSysVMsgBasic verifies the SysV message-queue family is traced end-to-end. +// The workload runs msgget(IPC_PRIVATE) -> msgsnd -> msgrcv -> msgctl(IPC_RMID); +// each call must appear as an enter event with a positive duration (proving the +// enter/exit pair was correlated). The workload always issues IPC_RMID, so no +// kernel message queue leaks. +func TestSysVMsgBasic(t *testing.T) { + h := newTestHarness(t) + result, pid, err := h.RunWithIorArgs("sysv-msg-basic", defaultDuration, sysvMsgTraceArgs) + if err != nil { + t.Fatalf("run scenario sysv-msg-basic: %v", err) + } + + AssertNoUnexpectedPID(t, result, pid) + AssertNoUnexpectedComm(t, result, "ioworkload") + AssertEventsPresent(t, result, []ExpectedEvent{ + {Tracepoint: "enter_msgget", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_msgsnd", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_msgrcv", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_msgctl", Comm: "ioworkload", MinCount: 1}, + }) + + for _, tp := range []string{"enter_msgget", "enter_msgsnd", "enter_msgrcv", "enter_msgctl"} { + assertEventDurationPositive(t, result, ExpectedEvent{Tracepoint: tp, Comm: "ioworkload"}) + } +} + +// sysvSemTraceArgs restricts tracing to the SysV semaphore family so the +// captured output is dominated by the lifecycle calls the workload issues. +var sysvSemTraceArgs = []string{ + "-trace-syscalls", + "semget,semop,semctl", +} + +// TestSysVSemBasic verifies the SysV semaphore family is traced end-to-end. The +// workload runs semget(IPC_PRIVATE) -> semop(+1) -> semop(-1) -> +// semctl(IPC_RMID); each distinct syscall must appear as an enter event with a +// positive duration (proving the enter/exit pair was correlated). The workload +// always issues IPC_RMID, so no kernel semaphore set leaks. +func TestSysVSemBasic(t *testing.T) { + h := newTestHarness(t) + result, pid, err := h.RunWithIorArgs("sysv-sem-basic", defaultDuration, sysvSemTraceArgs) + if err != nil { + t.Fatalf("run scenario sysv-sem-basic: %v", err) + } + + AssertNoUnexpectedPID(t, result, pid) + AssertNoUnexpectedComm(t, result, "ioworkload") + AssertEventsPresent(t, result, []ExpectedEvent{ + {Tracepoint: "enter_semget", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_semop", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_semctl", Comm: "ioworkload", MinCount: 1}, + }) + + for _, tp := range []string{"enter_semget", "enter_semop", "enter_semctl"} { + assertEventDurationPositive(t, result, ExpectedEvent{Tracepoint: tp, Comm: "ioworkload"}) + } +} |
