summaryrefslogtreecommitdiff
path: root/integrationtests/expectations.go
diff options
context:
space:
mode:
Diffstat (limited to 'integrationtests/expectations.go')
-rw-r--r--integrationtests/expectations.go20
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