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

Function TestProgramInstructions

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

Source from the content-addressed store, hash-verified

812}
813
814func TestProgramInstructions(t *testing.T) {
815 name := "test_prog"
816 spec := &ProgramSpec{
817 Type: SocketFilter,
818 Name: name,
819 Instructions: asm.Instructions{
820 asm.LoadImm(asm.R0, -1, asm.DWord).WithSymbol(name),
821 asm.Return(),
822 },
823 License: "MIT",
824 }
825
826 prog := mustNewProgram(t, spec, nil)
827
828 pi, err := prog.Info()
829 testutils.SkipIfNotSupported(t, err)
830 if err != nil {
831 t.Fatal(err)
832 }
833
834 if platform.IsWindows {
835 t.Skip("prog.Info() does not return a valid Tag on Windows")
836 }
837
838 ok, err := spec.Instructions.HasTag(pi.Tag, internal.NativeEndian)
839 qt.Assert(t, qt.IsNil(err))
840 qt.Assert(t, qt.IsTrue(ok), qt.Commentf("ProgramSpec tag differs from xlated instructions"))
841}
842
843func TestProgramLoadErrors(t *testing.T) {
844 testutils.SkipOnOldKernel(t, "4.10", "stable verifier log output")

Callers

nothing calls this directly

Calls 8

LoadImmFunction · 0.92
ReturnFunction · 0.92
SkipIfNotSupportedFunction · 0.92
mustNewProgramFunction · 0.85
WithSymbolMethod · 0.80
HasTagMethod · 0.80
IsNilMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…