Skip to content

Commit

Permalink
tetragon: Cleanup tgids array before another round of events iteration
Browse files Browse the repository at this point in the history
We might not get all events immediately on the first events iteration,
so there needs to be another round.

In that case we need to zero tgids array and return an error, so the
checker knows we failed and starts another events iteration.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Oct 11, 2023
1 parent 08b79a9 commit 6746c85
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/sensors/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ func TestEventExitThreads(t *testing.T) {
finalCheck := func(l *logrus.Logger) error {
// Make sure we saw all pids
for pid, used := range tgids {
assert.True(t, used, "did not see exit event for pid %d", pid)
if !assert.True(t, used, "did not see exit event for pid %d", pid) {
// Cleanup the 'seen' tgids, because we are starting over
for pid, _ := range tgids {

Check warning on line 217 in pkg/sensors/exec/exec_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

range: should omit 2nd value from range; this loop is equivalent to `for pid := range ...` (revive)
tgids[pid] = false
}
return fmt.Errorf("final check failed")
}
}
return nil
}
Expand Down

0 comments on commit 6746c85

Please sign in to comment.