Skip to content

Commit

Permalink
link/kprobe: move kprobe offset test to kprobe_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mmat11 committed Jul 20, 2022
1 parent 84b5ddc commit 2a39fd8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
32 changes: 0 additions & 32 deletions link/kprobe_amd64_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion link/kprobe_multi.go
Expand Up @@ -148,7 +148,7 @@ var haveBPFLinkKprobeMulti = internal.FeatureTest("bpf_link_kprobe_multi", "5.18
License: "MIT",
})
if err != nil {
return err
return internal.ErrNotSupported
}
defer prog.Close()

Expand Down
20 changes: 20 additions & 0 deletions link/kprobe_test.go
Expand Up @@ -428,3 +428,23 @@ func TestKprobeToken(t *testing.T) {
})
}
}

func TestKprobeOffset(t *testing.T) {
prog := mustLoadProgram(t, ebpf.Kprobe, 0, "")

for i := uint64(2); i < 10; i++ {
k, err := Kprobe("inet6_release", prog, &KprobeOptions{Offset: i})
if err != nil {
continue
}
k.Close()

_, err = Kprobe("inet6_release", prog, &KprobeOptions{Offset: i - 1})
if !errors.Is(err, os.ErrNotExist) {
t.Fatalf("expected 'os.ErrNotExist', got: '%v'", err)
}
return
}

t.Fatal("no valid offsets found")
}

0 comments on commit 2a39fd8

Please sign in to comment.