From cd516e1577ad97d5c8b1603657b13d110557e1b2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 21 Feb 2026 20:53:07 +0200 Subject: Add negative integration tests for open syscalls - openEnoent: verifies ior captures enter_openat even when syscall fails (ENOENT) - openRdonlyWrite: verifies tracing of open + failed write to read-only fd - openPidFilter: verifies child process I/O is excluded by PID filtering - AssertEventsAbsent helper with zero-value guard and 6 unit tests Task: 348 Amp-Thread-ID: https://ampcode.com/threads/T-019c8185-55f4-72f0-8ddb-3be5e4002c0d Co-authored-by: Amp --- integrationtests/expectations.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'integrationtests/expectations.go') diff --git a/integrationtests/expectations.go b/integrationtests/expectations.go index 6a816e6..21a5bda 100644 --- a/integrationtests/expectations.go +++ b/integrationtests/expectations.go @@ -81,6 +81,26 @@ func AssertNoUnexpectedPID(t *testing.T, result TestResult, expectedPID int) { } } +// AssertEventsAbsent verifies that none of the specified events appear in the test result. +// Each ExpectedEvent must have at least one filter field set to avoid accidentally +// matching all records. +func AssertEventsAbsent(t *testing.T, result TestResult, absent []ExpectedEvent) { + t.Helper() + for _, exp := range absent { + if exp.PathContains == "" && exp.Tracepoint == "" && exp.Comm == "" { + t.Errorf("AssertEventsAbsent: ExpectedEvent must have at least one filter field set: %+v", exp) + continue + } + for _, rec := range result.Records { + if matchesExpectation(rec, exp) { + t.Errorf("event should be absent but was found: %+v (path=%q tracepoint=%s comm=%q)", + exp, rec.Path, rec.TraceID.String(), rec.Comm) + break + } + } + } +} + func matchesExpectation(rec flamegraph.IterRecord, exp ExpectedEvent) bool { if exp.PathContains != "" && !strings.Contains(rec.Path, exp.PathContains) { return false -- cgit v1.2.3