sensors

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefaults = Config{
	TetragonLib: filepath.Join(TetragonBpfPath(), "objs"),
	SelfBinary:  filepath.Base(os.Args[0]),

	CmdWaitTime:         60000 * time.Millisecond,
	DisableTetragonLogs: false,
	Debug:               false,
	Trace:               false,
}

Functions

func CheckSensorLoad

func CheckSensorLoad(sensors []*sensors.Sensor, sensorMaps []SensorMap, sensorProgs []SensorProg, t *testing.T)

func LoadSensor

func LoadSensor(t *testing.T, sensor *sensors.Sensor)

LoadSensor is a helper for loading a sensor in tests

func TestSensorsRun

func TestSensorsRun(m *testing.M, sensorName string) int

func TetragonBpfPath

func TetragonBpfPath() string

TetragonBpfPath retrieves bpf code path

Types

type Config

type Config struct {
	TetragonLib         string
	SelfBinary          string
	CmdWaitTime         time.Duration
	DisableTetragonLogs bool
	Debug               bool
	Trace               bool
}

Conf is configuration for testing sensors. It is intialized in TestSensorsRun() so all sensors test should call this function in their TestMain

func Conf

func Conf() *Config

type SensorMap

type SensorMap struct {
	Name  string
	Progs []uint
}

type SensorProg

type SensorProg struct {
	Name  string
	Type  ebpf.ProgramType
	NotIn bool
}

type TestSensorManager

type TestSensorManager struct {
	Manager *sensors.Manager
}

TestSensorManager sensor manager used in tests

func GetTestSensorManager added in v1.0.0

func GetTestSensorManager(ctx context.Context, t *testing.T) *TestSensorManager

GetTestSensorManager returns a new test sensor manager. Some tests require an observer running, some do not. To support both, the function checks if a sensor manager has already been setup in the observer, and uses it if so. Otherwise, it creates a new one. If it creates a new one it will use the test name to create a unqique directory for maps/etc, and will also register the necessary cleanup functions using t.Cleanup()

func (*TestSensorManager) AddAndEnableSensor

func (tsm *TestSensorManager) AddAndEnableSensor(
	ctx context.Context,
	t *testing.T,
	sensor *sensors.Sensor,
	sensorName string,
)

AddAndEnableSensor is a helper function that adds and enables a new sensor

func (*TestSensorManager) AddAndEnableSensors added in v0.9.0

func (tsm *TestSensorManager) AddAndEnableSensors(
	ctx context.Context,
	t *testing.T,
	targets []*sensors.Sensor,
)

AddAndEnableSensor is a helper function that adds and enables a new sensor

func (*TestSensorManager) DisableSensors added in v0.8.4

func (tsm *TestSensorManager) DisableSensors(
	ctx context.Context,
	t *testing.T,
	targets []*sensors.Sensor,
)

EnableSensors is a helper function that enables a list of sensors

func (*TestSensorManager) EnableSensors added in v0.8.4

func (tsm *TestSensorManager) EnableSensors(
	ctx context.Context,
	t *testing.T,
	targets []*sensors.Sensor,
)

EnableSensors is a helper function that enables a list of sensors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL