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

Function TestProgramGetNextID

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

Source from the content-addressed store, hash-verified

577}
578
579func TestProgramGetNextID(t *testing.T) {
580 testutils.SkipOnOldKernel(t, "4.13", "bpf_prog_get_next_id")
581
582 // Ensure there is at least one program loaded
583 _ = createBasicProgram(t)
584
585 // As there can be multiple eBPF programs, we loop over all of them and
586 // make sure, the IDs increase and the last call will return ErrNotExist
587 last := ProgramID(0)
588 for {
589 next, err := ProgramGetNextID(last)
590 if errors.Is(err, os.ErrNotExist) {
591 if last == 0 {
592 t.Fatal("Got ErrNotExist on the first iteration")
593 }
594 break
595 }
596 if err != nil {
597 t.Fatal("Unexpected error:", err)
598 }
599 if next <= last {
600 t.Fatalf("Expected next ID (%d) to be higher than the last ID (%d)", next, last)
601 }
602 last = next
603 }
604}
605
606func TestNewProgramFromID(t *testing.T) {
607 prog := createBasicProgram(t)

Callers

nothing calls this directly

Calls 5

SkipOnOldKernelFunction · 0.92
createBasicProgramFunction · 0.85
ProgramIDTypeAlias · 0.85
ProgramGetNextIDFunction · 0.85
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…