sensors

package
v0.8.20 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 17 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(ctx context.Context, 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 StartTestSensorManager

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

StartTestSensorManager starts a new sensor mananger. 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

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

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

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