Files
LearnGO/go/pkg/mod/github.com/cilium/ebpf@v0.11.0/internal/testutils/bpffs.go
T
2024-09-19 21:38:24 -04:00

22 lines
420 B
Go

package testutils
import (
"os"
"testing"
)
// TempBPFFS creates a temporary directory on a BPF FS.
//
// The directory is automatically cleaned up at the end of the test run.
func TempBPFFS(tb testing.TB) string {
tb.Helper()
tmp, err := os.MkdirTemp("/sys/fs/bpf", "ebpf-test")
if err != nil {
tb.Fatal("Create temporary directory on BPFFS:", err)
}
tb.Cleanup(func() { os.RemoveAll(tmp) })
return tmp
}