From 5adecbeab584c6af468327eafd233c1391b4d002 Mon Sep 17 00:00:00 2001 From: Kornilios Kourtis Date: Wed, 24 Jul 2024 11:02:28 +0200 Subject: [PATCH] testutils: improve loadGenericSensorTest loadGenericSensorTest is a helper function to load a generic sensor. With the addition of the tg_mbset_map in the previous commits, when using a matchBinaries with followChildren: true because for the latter, we need to base sensor to be loaded. This fixes the above issue by initializing the base (exec) sensor before running SensorsFromPolicy. Signed-off-by: Kornilios Kourtis --- pkg/sensors/tracing/selectors_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/sensors/tracing/selectors_test.go b/pkg/sensors/tracing/selectors_test.go index a77ac3905c1..329d6fe767b 100644 --- a/pkg/sensors/tracing/selectors_test.go +++ b/pkg/sensors/tracing/selectors_test.go @@ -46,6 +46,10 @@ func loadGenericSensorTest(t *testing.T, spec *v1alpha1.TracingPolicySpec) *sens Metadata: v1.ObjectMeta{Name: "name"}, Spec: *spec, } + + tus.LoadSensor(t, base.GetInitialSensor()) + tus.LoadSensor(t, testsensor.GetTestSensor()) + ret, err := sensors.SensorsFromPolicy(tp, policyfilter.NoFilterID) if err != nil { t.Fatalf("GetSensorsFromParserPolicy failed: %v", err) @@ -54,8 +58,6 @@ func loadGenericSensorTest(t *testing.T, spec *v1alpha1.TracingPolicySpec) *sens } tpSensor := ret[0] option.Config.HubbleLib = tus.Conf().TetragonLib - tus.LoadSensor(t, base.GetInitialSensor()) - tus.LoadSensor(t, testsensor.GetTestSensor()) tus.LoadSensor(t, tpSensor) return tpSensor.(*sensors.Sensor) }