Debian Codegraph @

internal/testutils/bpffs_other.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 //go:build !windows
2
3 package testutils
4
5 import (
6 "os"
•7 "strings"
8 "testing"
9 )
10
11 // TempBPFFS creates a temporary directory on a BPF FS.
12 //
13 // The directory is automatically cleaned up at the end of the test run.
14 func TempBPFFS(tb testing.TB) string {
15 tb.Helper()
16
17 tmp, err := os.MkdirTemp("/sys/fs/bpf", "ebpf-test")
18 if err != nil {
•19 if strings.Contains(err.Error(), "permission denied") {
20 tb.Skipf("Skipping test: %v", err)
21 }
22 tb.Fatal("Create temporary directory on BPFFS:", err)
23 }
24 tb.Cleanup(func() { os.RemoveAll(tmp) })
25
26 return tmp
27 }