Documentation ¶
Overview ¶
Package perfring provides utilities to do tests using the perf ringbuffer directly
Index ¶
- func FilterTestMessages(n notify.Message) bool
- func ProcessEvents(t *testing.T, ctx context.Context, eventFn EventFn, wgStarted *sync.WaitGroup)
- func RunSubTest(t *testing.T, ctx context.Context, name string, ...) bool
- func RunTest(t *testing.T, ctx context.Context, selfOperations func(), eventFn EventFn)
- func RunTestEventReduce[K any, V any](t *testing.T, ctx context.Context, selfOperations func(), ...) V
- func RunTestEventReduceCount[K comparable](t *testing.T, ctx context.Context, selfOperations func(), ...) map[K]int
- func RunTestEvents(t *testing.T, ctx context.Context, selfOperations func()) []notify.Message
- type EventFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterTestMessages ¶ added in v0.9.0
func ProcessEvents ¶
ProcessEvents will open the perf ringbuffer and process events.
It will complete, whenever it sees a number of MsgTestEventUnix on _all_ cpus or when the ctx is done. Hence, callers need to load the test sensor before they call it or use the ctx to cancel its operation.
Example code to load the test sensor:
import testsensor "github.com/cilium/tetragon/pkg/sensors/test" import tus "github.com/cilium/tetragon/pkg/testutils/sensors" tus.LoadSensor(t, testsensor.GetTestSensor())
If the test sensor is loaded, users can use TestCheckerMarkEnd to generate the appropriate MsgTestEventUnix.
func RunSubTest ¶
func RunSubTest(t *testing.T, ctx context.Context, name string, selfOperations func(t *testing.T), eventFn EventFn) bool
similar to RunTest, but uses t.Run()
func RunTest ¶
RunTest is a convinience wrapper around ProcessEvents it will:
- run ProcessEvents on a different goroutinem using eventFn
- execute selfOperations provided by the user
- execute TestCheckerMarkEnd so that ProcessEvents returns
- wait for ProcessEvents to finish, and return
func RunTestEventReduce ¶ added in v0.9.0
func RunTestEventReduceCount ¶ added in v1.3.0
Types ¶
Click to show internal directories.
Click to hide internal directories.