forked from cloudflare/artifact-fs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e_setup_linux_test.go
More file actions
36 lines (32 loc) · 892 Bytes
/
Copy pathe2e_setup_linux_test.go
File metadata and controls
36 lines (32 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"os"
"os/exec"
"strings"
"testing"
)
// skipIfNoFUSE skips the test if the FUSE kernel module is not available.
func skipIfNoFUSE(t *testing.T) {
t.Helper()
if _, err := os.Stat("/dev/fuse"); err != nil {
t.Skip("skipping: /dev/fuse not available")
}
}
// configGitSafeDir adds a safe.directory entry for the mount path.
func configGitSafeDir(t *testing.T, path string) {
t.Helper()
exec.Command("git", "config", "--global", "--add", "safe.directory", path).Run()
}
// isMounted checks whether the given path is a FUSE mount point by reading /proc/mounts.
func isMounted(path string) bool {
data, err := os.ReadFile("/proc/mounts")
if err != nil {
// Fall back to mount(8)
out, err := exec.Command("mount").Output()
if err != nil {
return false
}
return strings.Contains(string(out), path)
}
return strings.Contains(string(data), path)
}