2024-06-24 14:08:33 +02:00
|
|
|
//go:build unix
|
2023-10-04 19:33:12 +02:00
|
|
|
|
|
|
|
package nfsmount
|
|
|
|
|
|
|
|
import (
|
2024-06-24 14:08:33 +02:00
|
|
|
"os/exec"
|
|
|
|
"runtime"
|
2023-10-04 19:33:12 +02:00
|
|
|
"testing"
|
|
|
|
|
2024-08-27 17:49:42 +02:00
|
|
|
"github.com/rclone/rclone/cmd/serve/nfs"
|
2023-10-04 19:33:12 +02:00
|
|
|
"github.com/rclone/rclone/vfs/vfscommon"
|
|
|
|
"github.com/rclone/rclone/vfs/vfstest"
|
2024-06-25 17:15:21 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-10-04 19:33:12 +02:00
|
|
|
)
|
|
|
|
|
2024-06-24 14:08:33 +02:00
|
|
|
// Return true if the command ran without error
|
|
|
|
func commandOK(name string, arg ...string) bool {
|
|
|
|
cmd := exec.Command(name, arg...)
|
|
|
|
_, err := cmd.CombinedOutput()
|
|
|
|
return err == nil
|
|
|
|
}
|
|
|
|
|
2023-10-04 19:33:12 +02:00
|
|
|
func TestMount(t *testing.T) {
|
2024-06-24 14:08:33 +02:00
|
|
|
if runtime.GOOS != "darwin" {
|
|
|
|
if !commandOK("sudo", "-n", "mount", "--help") {
|
|
|
|
t.Skip("Can't run sudo mount without a password")
|
|
|
|
}
|
|
|
|
if !commandOK("sudo", "-n", "umount", "--help") {
|
|
|
|
t.Skip("Can't run sudo umount without a password")
|
|
|
|
}
|
|
|
|
sudo = true
|
|
|
|
}
|
2024-08-27 17:49:42 +02:00
|
|
|
nfs.Opt.HandleCacheDir = t.TempDir()
|
|
|
|
require.NoError(t, nfs.Opt.HandleCache.Set("disk"))
|
2024-06-25 10:20:43 +02:00
|
|
|
vfstest.RunTests(t, false, vfscommon.CacheModeWrites, false, mount)
|
2023-10-04 19:33:12 +02:00
|
|
|
}
|