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

Function TestProgramSpecCompatible

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

Source from the content-addressed store, hash-verified

669}
670
671func TestProgramSpecCompatible(t *testing.T) {
672 arr := createMap(t, Array, 2)
673
674 spec := &ProgramSpec{
675 Type: SocketFilter,
676 Instructions: asm.Instructions{
677 asm.LoadImm(asm.R0, -1, asm.DWord),
678 asm.LoadMapPtr(asm.R1, arr.FD()),
679 asm.Mov.Imm32(asm.R0, 0),
680 asm.Return(),
681 },
682 License: "MIT",
683 }
684
685 prog := mustNewProgram(t, spec, nil)
686
687 info, err := prog.Info()
688 testutils.SkipIfNotSupported(t, err)
689 qt.Assert(t, qt.IsNil(err))
690
691 err = spec.Compatible(info)
692 testutils.SkipIfNotSupportedOnOS(t, err)
693 qt.Assert(t, qt.IsNil(err))
694}
695
696func TestProgramAttachToKernel(t *testing.T) {
697 // See https://github.com/torvalds/linux/commit/290248a5b7d829871b3ea3c62578613a580a1744

Callers

nothing calls this directly

Calls 12

CompatibleMethod · 0.95
LoadImmFunction · 0.92
LoadMapPtrFunction · 0.92
ReturnFunction · 0.92
SkipIfNotSupportedFunction · 0.92
SkipIfNotSupportedOnOSFunction · 0.92
mustNewProgramFunction · 0.85
IsNilMethod · 0.80
createMapFunction · 0.70
FDMethod · 0.65
InfoMethod · 0.65
Imm32Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…