Documentation ¶
Overview ¶
Package ebpftest is utilities for tests against eBPF
Index ¶
- func DumpMapsTestHelper(t *testing.T, dumpfunc func(io.Writer, ...string) error, maps ...string)
- func FailLogLevel(t testing.TB, level string)
- func LogLevel(t testing.TB, level string)
- func LogTracePipe(t *testing.T)
- func LogTracePipeFilter(t *testing.T, filterFn func(ev *TraceEvent) bool)
- func LogTracePipeProcess(t *testing.T, pid uint32)
- func LogTracePipeSelf(t *testing.T)
- func RequireKernelVersion(tb testing.TB, version kernel.Version)
- func TestBuildMode(t *testing.T, mode BuildMode, name string, fn func(t *testing.T))
- func TestBuildModes(t *testing.T, modes []BuildMode, name string, fn func(t *testing.T))
- type BuildMode
- type TraceEvent
- type TracePipe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpMapsTestHelper ¶
DumpMapsTestHelper dumps the content of the given maps to the test log, handling errors if any.
func FailLogLevel ¶
FailLogLevel sets the logger level for this test only and only outputs if the test fails
func LogTracePipe ¶
LogTracePipe logs all messages read from /sys/kernel/[debug/]/tracing/trace_pipe during the test. This function will set the environment variable BPF_DEBUG=true for the duration of the test.
func LogTracePipeFilter ¶
func LogTracePipeFilter(t *testing.T, filterFn func(ev *TraceEvent) bool)
LogTracePipeFilter logs only messages that pass `filterFn` read from /sys/kernel/[debug/]/tracing/trace_pipe during the test. This function will set the environment variable BPF_DEBUG=true for the duration of the test.
func LogTracePipeProcess ¶
LogTracePipeProcess logs only messages from the provided process read from /sys/kernel/[debug/]/tracing/trace_pipe during the test. This function will set the environment variable BPF_DEBUG=true for the duration of the test.
func LogTracePipeSelf ¶
LogTracePipeSelf logs only messages from the current process read from /sys/kernel/[debug/]/tracing/trace_pipe during the test. This function will set the environment variable BPF_DEBUG=true for the duration of the test.
func RequireKernelVersion ¶
RequireKernelVersion skips a test if the minimum kernel version is not met
func TestBuildMode ¶
TestBuildMode runs the test under the provided build mode
Types ¶
type BuildMode ¶
BuildMode is an eBPF build mode
var ( Prebuilt BuildMode RuntimeCompiled BuildMode CORE BuildMode Fentry BuildMode Ebpfless BuildMode )
TODO I don't love fentry as a buildmode here...
func GetBuildMode ¶
func GetBuildMode() BuildMode
GetBuildMode returns which build mode the current environment matches, if any
func SupportedBuildModes ¶
func SupportedBuildModes() []BuildMode
SupportedBuildModes returns the build modes supported on the current host
type TraceEvent ¶
type TraceEvent struct { Raw string Task string PID uint32 CPU string Flags string Timestamp string Function string Message string }
TraceEvent contains the raw event as well as the contents of every field as string, as defined under "Output format" in https://www.kernel.org/doc/Documentation/trace/ftrace.txt
func (TraceEvent) String ¶
func (t TraceEvent) String() string
type TracePipe ¶
type TracePipe struct {
// contains filtered or unexported fields
}
TracePipe to read from /sys/kernel/[debug/]tracing/trace_pipe Note that data can be read only once, i.e. if you have more than one tracer / channel, only one will receive an event: "Once data is read from this file, it is consumed, and will not be read again with a sequential read." https://www.kernel.org/doc/Documentation/trace/ftrace.txt
func NewTracePipe ¶
NewTracePipe instantiates a new trace pipe
func (*TracePipe) Channel ¶
func (t *TracePipe) Channel() (<-chan *TraceEvent, <-chan error)
Channel returns a channel of events and another for errors
func (*TracePipe) ReadLine ¶
func (t *TracePipe) ReadLine() (*TraceEvent, error)
ReadLine reads a line