diff --git a/test/fuse_integration/mounted_unix.go b/test/fuse_integration/mounted_unix.go index 85889b9ac4..471b8bb655 100644 --- a/test/fuse_integration/mounted_unix.go +++ b/test/fuse_integration/mounted_unix.go @@ -17,8 +17,10 @@ func deviceID(path string) (uint64, error) { } // mountedAt reports whether something is actually mounted at path: a plain -// directory shares its parent's device, a mount point does not. +// directory shares its parent's device, a mount point does not. The path is +// cleaned first so a trailing slash does not make Dir return the mount itself. func mountedAt(path string) bool { + path = filepath.Clean(path) dev, err := deviceID(path) if err != nil { return false diff --git a/test/fuse_integration/mounted_unix_test.go b/test/fuse_integration/mounted_unix_test.go new file mode 100644 index 0000000000..ed47185519 --- /dev/null +++ b/test/fuse_integration/mounted_unix_test.go @@ -0,0 +1,19 @@ +//go:build unix + +package fuse + +import "testing" + +func TestMountedAt(t *testing.T) { + for _, p := range []string{"/proc", "/proc/"} { + if !mountedAt(p) { + t.Errorf("mountedAt(%q) = false, want true", p) + } + } + plain := t.TempDir() + for _, p := range []string{plain, plain + "/"} { + if mountedAt(p) { + t.Errorf("mountedAt(%q) = true, want false", p) + } + } +}