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

Function TestStructOpsMapSpecSimpleLoadAndAssign

collection_test.go:710–838  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

708}
709
710func TestStructOpsMapSpecSimpleLoadAndAssign(t *testing.T) {
711 requireTestmodOps(t)
712
713 makeProg := func(attachTo string) map[string]*ProgramSpec {
714 return map[string]*ProgramSpec{
715 "test_1": {
716 Name: "test_1",
717 Type: StructOps,
718 AttachTo: attachTo,
719 License: "GPL",
720 Instructions: asm.Instructions{
721 asm.Mov.Imm(asm.R0, 0),
722 asm.Return(),
723 },
724 },
725 }
726 }
727
728 funcPtr := &btf.Pointer{
729 Target: &btf.FuncProto{
730 Return: &btf.Int{Name: "int", Size: 4, Encoding: btf.Signed},
731 },
732 }
733
734 type testCase struct {
735 name string
736 withProg bool
737 attachTo string
738 valueType *btf.Struct
739 valueBytes []byte
740 }
741
742 cases := []testCase{
743 {
744 name: "ops_with_data",
745 withProg: true,
746 attachTo: "bpf_testmod_ops:test_1",
747 valueType: &btf.Struct{
748 Name: "bpf_testmod_ops",
749 Size: 16,
750 Members: []btf.Member{
751 {
752 Name: "test_1",
753 Type: funcPtr,
754 Offset: 0,
755 },
756 {
757 Name: "data",
758 Type: &btf.Int{Name: "int", Size: 4},
759 Offset: 64, // bits
760 },
761 },
762 },
763 valueBytes: []byte{
764 // test_1 func ptr (8B)
765 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
766 // data (4B) + padding (4B)
767 0xde, 0xed, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00,

Callers

nothing calls this directly

Calls 6

ReturnFunction · 0.92
requireTestmodOpsFunction · 0.85
mustNewCollectionFunction · 0.85
RunMethod · 0.65
ImmMethod · 0.45
CloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…