MCPcopy Index your code
hub / github.com/cilium/ebpf / TestCreateStructOpsMapSpecSimple

Function TestCreateStructOpsMapSpecSimple

struct_ops_test.go:13–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestCreateStructOpsMapSpecSimple(t *testing.T) {
14 requireTestmodOps(t)
15
16 btfSpec, err := btf.LoadKernelModuleSpec("bpf_testmod")
17 qt.Assert(t, qt.IsNil(err))
18
19 var outerValueType *btf.Struct
20 qt.Assert(t, qt.IsNil(btfSpec.TypeByName(structOpsValuePrefix+"bpf_testmod_ops", &outerValueType)))
21
22 ms := &MapSpec{
23 Name: "testmod_ops",
24 Type: StructOpsMap,
25 Flags: sys.BPF_F_LINK,
26 Key: &btf.Int{Size: 4},
27 KeySize: 4,
28 Value: &btf.Struct{Name: "bpf_testmod_ops"},
29 MaxEntries: 1,
30 Contents: []MapKV{
31 {
32 Key: uint32(0),
33 Value: make([]byte, outerValueType.Size),
34 },
35 },
36 }
37
38 m, err := NewMap(ms)
39 testutils.SkipIfNotSupported(t, err)
40 qt.Assert(t, qt.IsNil(err))
41 t.Cleanup(func() { _ = m.Close() })
42}

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
LoadKernelModuleSpecFunction · 0.92
SkipIfNotSupportedFunction · 0.92
requireTestmodOpsFunction · 0.85
NewMapFunction · 0.85
IsNilMethod · 0.80
TypeByNameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…