(t *testing.T)
| 577 | } |
| 578 | |
| 579 | func 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 | |
| 606 | func TestNewProgramFromID(t *testing.T) { |
| 607 | prog := createBasicProgram(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…