From 9fc26381ac29bfbf48fe0ad8312faa240aafcae8 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 29 Dec 2024 20:15:57 +0000 Subject: [PATCH] tetragon: Adjust TestMissedProgStatsKprobeMulti test for session Signed-off-by: Jiri Olsa --- pkg/sensors/tracing/kprobe_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/sensors/tracing/kprobe_test.go b/pkg/sensors/tracing/kprobe_test.go index ea8025cf10d..3689160d025 100644 --- a/pkg/sensors/tracing/kprobe_test.go +++ b/pkg/sensors/tracing/kprobe_test.go @@ -7013,14 +7013,24 @@ spec: fmt.Printf("Failed to execute test binary: %s\n", err) } - expected := strings.NewReader(` # HELP tetragon_missed_prog_probes_total The total number of Tetragon probe missed by program. + s := ` # HELP tetragon_missed_prog_probes_total The total number of Tetragon probe missed by program. # TYPE tetragon_missed_prog_probes_total counter tetragon_missed_prog_probes_total{attach="acct_process",policy="__base__"} 0 -tetragon_missed_prog_probes_total{attach="kprobe_multi (2 functions)",policy="syswritefollowfdpsswd"} 1 +tetragon_missed_prog_probes_total{attach="%s (2 functions)",policy="syswritefollowfdpsswd"} %d tetragon_missed_prog_probes_total{attach="sched/sched_process_exec",policy="__base__"} 0 tetragon_missed_prog_probes_total{attach="security_bprm_committing_creds",policy="__base__"} 0 tetragon_missed_prog_probes_total{attach="wake_up_new_task",policy="__base__"} 0 -`) +` + + // Session programs get accounted missed counts also for return + // probe even if it's not executed (plus type name). + cnt := 1 + typ := "kprobe_multi" + if bpf.HasKprobeSession() { + cnt = 2 + typ = "kprobe_session" + } + expected := strings.NewReader(fmt.Sprintf(s, typ, cnt)) assert.NoError(t, testutil.GatherAndCompare(metricsconfig.GetRegistry(), expected, prometheus.BuildFQName(consts.MetricsNamespace, "", "missed_prog_probes_total")))