Skip to content

Commit

Permalink
tetragon: Add missing calls to DeleteTracingPolicy in kprobe tests
Browse files Browse the repository at this point in the history
We're missing cleanup in some kprobe tests, so we get leftovers
in the tetragon directory, like:

  time="2024-08-17T18:01:54Z" level=info msg="`gkp-sensor-3-multi_kprobe-string_maps_5` still exists after test"
  time="2024-08-17T18:01:54Z" level=info msg="`gkp-sensor-3-multi_kprobe-string_maps_6` still exists after test"
  time="2024-08-17T18:01:54Z" level=info msg="`gkp-sensor-3-multi_kprobe-string_maps_7` still exists after test"

Adding missing DeleteTracingPolicy cleanup call.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Aug 20, 2024
1 parent 707db37 commit 9a42e1f
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pkg/sensors/tracing/kprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4001,7 +4001,11 @@ func matchBinariesPerfringTest(t *testing.T, operator string, values []string) {
}

err := sm.Manager.AddTracingPolicy(ctx, &matchBinariesTracingPolicy)
assert.NoError(t, err)
if assert.NoError(t, err) {
t.Cleanup(func() {
sm.Manager.DeleteTracingPolicy(ctx, "match-binaries", "")
})
}

var tailPID, headPID int
ops := func() {
Expand Down Expand Up @@ -4112,7 +4116,11 @@ func TestKprobeMatchBinariesEarlyExec(t *testing.T) {
}

err = sm.Manager.AddTracingPolicy(ctx, &matchBinariesTracingPolicy)
assert.NoError(t, err)
if assert.NoError(t, err) {
t.Cleanup(func() {
sm.Manager.DeleteTracingPolicy(ctx, "match-binaries", "")
})
}

ops := func() {
file.WriteString("trigger!")
Expand Down Expand Up @@ -4188,7 +4196,11 @@ func TestKprobeMatchBinariesPrefixMatchArgs(t *testing.T) {
}

err := sm.Manager.AddTracingPolicy(ctx, &matchBinariesTracingPolicy)
assert.NoError(t, err)
if assert.NoError(t, err) {
t.Cleanup(func() {
sm.Manager.DeleteTracingPolicy(ctx, "match-binaries", "")
})
}

var tailEtcPID, tailProcPID, headPID int
ops := func() {
Expand Down Expand Up @@ -6123,7 +6135,11 @@ func TestLinuxBinprmExtractPath(t *testing.T) {
}

err := sm.Manager.AddTracingPolicy(ctx, &bprmTracingPolicy)
assert.NoError(t, err)
if assert.NoError(t, err) {
t.Cleanup(func() {
sm.Manager.DeleteTracingPolicy(ctx, "bprm-extract-path", "")
})
}

targetCommand := exec.Command("/usr/bin/id")
filteredCommand := exec.Command("/usr/bin/uname")
Expand Down

0 comments on commit 9a42e1f

Please sign in to comment.