diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-21 20:53:07 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-21 20:53:07 +0200 |
| commit | cd516e1577ad97d5c8b1603657b13d110557e1b2 (patch) | |
| tree | af13921fff67f173d4e9ff97e48c54812dc1ca81 /integrationtests/expectations.go | |
| parent | 4e287fd01d5057d0345183b6845dcc58683a46e4 (diff) | |
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 <amp@ampcode.com>
Diffstat (limited to 'integrationtests/expectations.go')
| -rw-r--r-- | integrationtests/expectations.go | 20 |
1 files changed, 20 insertions, 0 deletions
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 |
