Documentation ¶
Index ¶
- func CreateMntNsFilterMap(t testing.TB, mountNsIDs ...uint64) *ebpf.Map
- func Equal[T comparable](t *testing.T, expected, actual T, message string)
- func ExpectNoEvent[Event any, Extra any](t *testing.T, _ *RunnerInfo, _ Extra, events []Event)
- func HostInit(t *testing.T)
- func ReadFileAsUint32(t testing.TB, path string) uint32
- func RequireKernelVersion(t testing.TB, expectedVersion *kernel.VersionInfo)
- func RequireRoot(t testing.TB)
- func RunWithRunner(t testing.TB, runner *Runner, f func() error)
- type Runner
- type RunnerConfig
- type RunnerInfo
- type ValidateEventType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMntNsFilterMap ¶
CreateMntNsFilterMap creates and fills an eBPF map that can be used to filter by mount namespace in the different tracers.
func Equal ¶
func Equal[T comparable](t *testing.T, expected, actual T, message string)
Equal compares if two values are the same. Deprecated: Use require.Equal instead.
func ExpectNoEvent ¶
func ExpectNoEvent[Event any, Extra any](t *testing.T, _ *RunnerInfo, _ Extra, events []Event)
ExpectNoEvent doesn't expect any event to be captured by the tracer.
func HostInit ¶ added in v0.19.0
HostInit initializes the host package for testing without any automatic workarounds.
func RequireKernelVersion ¶
func RequireKernelVersion(t testing.TB, expectedVersion *kernel.VersionInfo)
func RequireRoot ¶
RequireRoot skips the test if the not running as root
Types ¶
type Runner ¶
type Runner struct { Info *RunnerInfo // contains filtered or unexported fields }
Runner is a helper type to execute tests in different conditions. It creates a go routine that is executed in a different mount namespace, user ID, etc. to simulate events hapenning inside containers.
func NewRunner ¶
func NewRunner(config *RunnerConfig) (*Runner, error)
func NewRunnerWithTest ¶
func NewRunnerWithTest(t testing.TB, config *RunnerConfig) *Runner
type RunnerConfig ¶
type RunnerConfig struct { // User ID to run under Uid int // Group ID to run under Gid int // HostNetwork prevents the runner from creating a new network namespace HostNetwork bool }
RunnerConfig defines how the runner should behave. TODO: We could implement more options like unsharing the network namespace, running on a different group ID, etc.
type RunnerInfo ¶
type RunnerInfo struct { Pid int Tid int Comm string Uid int Gid int MountNsID uint64 NetworkNsID uint64 UserNsID uint64 }
RunnerInfo contains information about the runner and it's used by the tests to verify that the generated events have the correct value for fields like PID, UID and MountNsID.
type ValidateEventType ¶
type ValidateEventType[Event any, Extra any] func(*testing.T, *RunnerInfo, Extra, []Event)
func ExpectAtLeastOneEvent ¶
func ExpectAtLeastOneEvent[Event any, Extra any](getEvent func(info *RunnerInfo, extra Extra) *Event) ValidateEventType[Event, Extra]
ExpectAtLeastOneEvent expects that at least one of the captures events matches.
func ExpectOneEvent ¶
func ExpectOneEvent[Event any, Extra any](getEvent func(info *RunnerInfo, extra Extra) *Event) ValidateEventType[Event, Extra]
ExpectOneEvent expects only matching event to be captured.