Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pin/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pin

import (
"fmt"
"io"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/internal/sys"
Expand All @@ -11,6 +12,7 @@ import (
// Pinner is an interface implemented by all eBPF objects that support pinning
// to a bpf virtual filesystem.
type Pinner interface {
io.Closer
Pin(string) error
}

Expand Down
7 changes: 7 additions & 0 deletions pin/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/internal/testutils"
"github.com/cilium/ebpf/internal/testutils/fdtrace"
)

func mustPinnedProgram(t *testing.T, path string) *ebpf.Program {
Expand Down Expand Up @@ -77,9 +78,15 @@ func TestLoad(t *testing.T) {

m, err := Load(mpath, nil)
qt.Assert(t, qt.IsNil(err))
defer m.Close()
qt.Assert(t, qt.Satisfies(m, testutils.Contains[*ebpf.Map]))

p, err := Load(ppath, nil)
qt.Assert(t, qt.IsNil(err))
defer p.Close()
qt.Assert(t, qt.Satisfies(p, testutils.Contains[*ebpf.Program]))
}

func TestMain(m *testing.M) {
fdtrace.TestMain(m)
}
4 changes: 4 additions & 0 deletions pin/walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func TestWalkDir(t *testing.T) {
bpffn := func(path string, d fs.DirEntry, obj Pinner, err error) error {
qt.Assert(t, qt.IsNil(err))

if obj != nil {
defer obj.Close()
}

if path == "." {
return nil
}
Expand Down
Loading