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 <jolsa@kernel.org>
  • Loading branch information
olsajiri committed Oct 11, 2023
1 parent 08b79a9 commit 7b4003c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/sensors/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,22 @@ func TestEventExitThreads(t *testing.T) {
}
}

var seenAll bool

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 !used {
t.Logf("Did not see exit event for pid %d", pid)

// Cleanup the 'seen' tgids for one more events iteration
for pid := range tgids {
tgids[pid] = false
}
return fmt.Errorf("final check failed")
}
}
seenAll = true
return nil
}

Expand All @@ -226,6 +237,8 @@ func TestEventExitThreads(t *testing.T) {

err = jsonchecker.JsonTestCheck(t, checker)
assert.NoError(t, err)

assert.True(t, seenAll, "did not see all exit events")
}

func TestEventExecve(t *testing.T) {
Expand Down

0 comments on commit 7b4003c

Please sign in to comment.