MCPcopy
hub / github.com/cilium/ebpf / TestProgramRunWithOptions

Function TestProgramRunWithOptions

prog_test.go:88–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestProgramRunWithOptions(t *testing.T) {
89 testutils.SkipOnOldKernel(t, "5.15", "XDP ctx_in/ctx_out")
90
91 buf := internal.EmptyBPFContext
92 var prog *Program
93 var in, out any
94 if platform.IsWindows {
95 type winSampleProgramContext struct {
96 _ uint64 // data_start (currently leaks kernel pointer)
97 _ uint64 // data_end (currently leaks kernel pointer)
98 Uint32Data uint32
99 Uint16Data uint16
100 _ uint16
101 HelperData1 uint32
102 HelperData2 uint32
103 }
104 prog = createProgram(t, WindowsSample, 0)
105 in = &winSampleProgramContext{Uint32Data: 23, HelperData2: 42}
106 out = &winSampleProgramContext{Uint32Data: 23, HelperData2: 42}
107 } else {
108 prog = createProgram(t, XDP, int64(sys.XDP_ABORTED))
109 in = &sys.XdpMd{Data: 0, DataEnd: uint32(len(buf))}
110 out = &sys.XdpMd{}
111 }
112
113 opts := RunOptions{
114 Data: buf,
115 Context: in,
116 ContextOut: out,
117 }
118 ret, err := prog.Run(&opts)
119 testutils.SkipIfNotSupported(t, err)
120 if err != nil {
121 t.Fatal(err)
122 }
123
124 if ret != 0 {
125 t.Error("Expected return value to be 0, got", ret)
126 }
127
128 qt.Assert(t, qt.DeepEquals(out, in))
129}
130
131func TestProgramRunRawTracepoint(t *testing.T) {
132 testutils.SkipOnOldKernel(t, "5.10", "RawTracepoint test run")

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
SkipOnOldKernelFunction · 0.92
SkipIfNotSupportedFunction · 0.92
createProgramFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…