Skip to content

Commit

Permalink
testutils: improve loadGenericSensorTest
Browse files Browse the repository at this point in the history
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 <kornilios@isovalent.com>
  • Loading branch information
kkourt committed Aug 4, 2024
1 parent 454b3cf commit 5dde354
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/sensors/tracing/selectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down

0 comments on commit 5dde354

Please sign in to comment.