From 7b4003c8291c8eec661e77eaeca57361e7cbd20a Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 9 Oct 2023 11:29:48 +0000 Subject: [PATCH] tetragon: Cleanup tgids array before another round of events iteration 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 --- pkg/sensors/exec/exec_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/sensors/exec/exec_test.go b/pkg/sensors/exec/exec_test.go index 10dbb9ec788..fa206119e10 100644 --- a/pkg/sensors/exec/exec_test.go +++ b/pkg/sensors/exec/exec_test.go @@ -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 } @@ -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) {