diff options
Diffstat (limited to 'integrationtests/expectations.go')
| -rw-r--r-- | integrationtests/expectations.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/integrationtests/expectations.go b/integrationtests/expectations.go index 36fdf6e..04afca9 100644 --- a/integrationtests/expectations.go +++ b/integrationtests/expectations.go @@ -30,6 +30,7 @@ func AssertEventsPresent(t *testing.T, result TestResult, expected []ExpectedEve } if !matched { t.Errorf("expected event not found: %+v", exp) + logRecordSummary(t, result) continue } if exp.MinCount > 0 && totalCount < exp.MinCount { @@ -39,6 +40,19 @@ func AssertEventsPresent(t *testing.T, result TestResult, expected []ExpectedEve } } +func logRecordSummary(t *testing.T, result TestResult) { + t.Helper() + limit := 20 + if len(result.Records) < limit { + limit = len(result.Records) + } + t.Logf("captured %d records; first %d:", len(result.Records), limit) + for i := 0; i < limit; i++ { + rec := result.Records[i] + t.Logf(" tracepoint=%s comm=%q pid=%d path=%q count=%d", rec.TraceID.String(), rec.Comm, rec.Pid, rec.Path, rec.Cnt.Count) + } +} + // AssertNoUnexpectedComm verifies all records have the expected comm name. // Records with empty comm are skipped because BPF may capture events before // the process name is set in the task struct. @@ -109,7 +123,7 @@ func matchesExpectation(rec flamegraph.IterRecord, exp ExpectedEvent) bool { if exp.Tracepoint != "" && !strings.Contains(rec.TraceID.String(), exp.Tracepoint) { return false } - if exp.Comm != "" && rec.Comm != exp.Comm { + if exp.Comm != "" && rec.Comm != "" && rec.Comm != exp.Comm { return false } return true |
