2016-07-18 00:03:23 +02:00
|
|
|
// Test suite for rclonefs
|
|
|
|
|
2020-04-16 14:33:46 +02:00
|
|
|
package vfstest
|
2016-07-18 00:03:23 +02:00
|
|
|
|
|
|
|
import (
|
2022-06-16 13:08:11 +02:00
|
|
|
"bufio"
|
2019-06-17 10:34:30 +02:00
|
|
|
"context"
|
2016-07-18 00:03:23 +02:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
2020-01-08 18:14:35 +01:00
|
|
|
"io"
|
2016-07-18 00:03:23 +02:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"path"
|
2017-11-18 12:59:56 +01:00
|
|
|
"path/filepath"
|
2017-11-17 11:30:35 +01:00
|
|
|
"reflect"
|
2017-05-08 15:55:05 +02:00
|
|
|
"runtime"
|
2016-07-18 00:03:23 +02:00
|
|
|
"strings"
|
2022-06-16 13:08:11 +02:00
|
|
|
"sync"
|
2016-07-18 00:03:23 +02:00
|
|
|
"testing"
|
2017-06-13 11:52:10 +02:00
|
|
|
"time"
|
2016-07-18 00:03:23 +02:00
|
|
|
|
2019-07-28 19:47:38 +02:00
|
|
|
_ "github.com/rclone/rclone/backend/all" // import all the backends
|
2020-07-23 18:17:01 +02:00
|
|
|
"github.com/rclone/rclone/cmd/mountlib"
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/fs"
|
|
|
|
"github.com/rclone/rclone/fs/walk"
|
|
|
|
"github.com/rclone/rclone/fstest"
|
2020-02-28 15:44:15 +01:00
|
|
|
"github.com/rclone/rclone/vfs/vfscommon"
|
2016-07-18 00:03:23 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-10-20 18:24:58 +02:00
|
|
|
const (
|
|
|
|
waitForWritersDelay = 30 * time.Second // time to wait for existing writers
|
|
|
|
)
|
|
|
|
|
2018-04-08 12:18:15 +02:00
|
|
|
// RunTests runs all the tests against all the VFS cache modes
|
2020-04-16 14:33:46 +02:00
|
|
|
//
|
2022-06-16 13:08:11 +02:00
|
|
|
// If useVFS is set then it runs the tests against a VFS rather than a
|
|
|
|
// mount
|
|
|
|
//
|
|
|
|
// If useVFS is not set then it runs the mount in a subprocess in
|
|
|
|
// order to avoid kernel deadlocks.
|
2023-10-04 19:33:12 +02:00
|
|
|
func RunTests(t *testing.T, useVFS bool, minimumRequiredCacheMode vfscommon.CacheMode, enableCacheTests bool, mountFn mountlib.MountFn) {
|
2016-07-18 00:03:23 +02:00
|
|
|
flag.Parse()
|
2022-06-16 13:08:11 +02:00
|
|
|
if isSubProcess() {
|
|
|
|
startMount(mountFn, useVFS, *runMount)
|
|
|
|
return
|
|
|
|
}
|
2020-04-17 12:18:58 +02:00
|
|
|
tests := []struct {
|
|
|
|
cacheMode vfscommon.CacheMode
|
2024-07-02 18:31:51 +02:00
|
|
|
writeBack fs.Duration
|
2020-04-17 12:18:58 +02:00
|
|
|
}{
|
|
|
|
{cacheMode: vfscommon.CacheModeOff},
|
|
|
|
{cacheMode: vfscommon.CacheModeMinimal},
|
|
|
|
{cacheMode: vfscommon.CacheModeWrites},
|
|
|
|
{cacheMode: vfscommon.CacheModeFull},
|
2024-07-02 18:31:51 +02:00
|
|
|
{cacheMode: vfscommon.CacheModeFull, writeBack: fs.Duration(100 * time.Millisecond)},
|
2017-11-07 19:03:23 +01:00
|
|
|
}
|
2020-04-17 12:18:58 +02:00
|
|
|
for _, test := range tests {
|
2023-10-04 19:33:12 +02:00
|
|
|
if test.cacheMode < minimumRequiredCacheMode {
|
|
|
|
continue
|
|
|
|
}
|
2024-07-03 12:34:29 +02:00
|
|
|
vfsOpt := vfscommon.Opt
|
2022-06-16 13:08:11 +02:00
|
|
|
vfsOpt.CacheMode = test.cacheMode
|
|
|
|
vfsOpt.WriteBack = test.writeBack
|
|
|
|
run = newRun(useVFS, &vfsOpt, mountFn)
|
2020-04-17 12:18:58 +02:00
|
|
|
what := fmt.Sprintf("CacheMode=%v", test.cacheMode)
|
|
|
|
if test.writeBack > 0 {
|
|
|
|
what += fmt.Sprintf(",WriteBack=%v", test.writeBack)
|
|
|
|
}
|
2024-08-18 16:58:35 +02:00
|
|
|
fs.Logf(nil, "Starting test run with %s", what)
|
2020-04-17 12:18:58 +02:00
|
|
|
ok := t.Run(what, func(t *testing.T) {
|
2018-05-24 20:45:11 +02:00
|
|
|
t.Run("TestTouchAndDelete", TestTouchAndDelete)
|
|
|
|
t.Run("TestRenameOpenHandle", TestRenameOpenHandle)
|
2018-04-08 12:18:15 +02:00
|
|
|
t.Run("TestDirLs", TestDirLs)
|
|
|
|
t.Run("TestDirCreateAndRemoveDir", TestDirCreateAndRemoveDir)
|
|
|
|
t.Run("TestDirCreateAndRemoveFile", TestDirCreateAndRemoveFile)
|
|
|
|
t.Run("TestDirRenameFile", TestDirRenameFile)
|
|
|
|
t.Run("TestDirRenameEmptyDir", TestDirRenameEmptyDir)
|
|
|
|
t.Run("TestDirRenameFullDir", TestDirRenameFullDir)
|
|
|
|
t.Run("TestDirModTime", TestDirModTime)
|
2023-10-04 19:33:12 +02:00
|
|
|
if enableCacheTests {
|
|
|
|
t.Run("TestDirCacheFlush", TestDirCacheFlush)
|
|
|
|
}
|
2018-04-08 12:18:15 +02:00
|
|
|
t.Run("TestDirCacheFlushOnDirRename", TestDirCacheFlushOnDirRename)
|
|
|
|
t.Run("TestFileModTime", TestFileModTime)
|
|
|
|
t.Run("TestFileModTimeWithOpenWriters", TestFileModTimeWithOpenWriters)
|
|
|
|
t.Run("TestMount", TestMount)
|
|
|
|
t.Run("TestRoot", TestRoot)
|
|
|
|
t.Run("TestReadByByte", TestReadByByte)
|
|
|
|
t.Run("TestReadChecksum", TestReadChecksum)
|
|
|
|
t.Run("TestReadFileDoubleClose", TestReadFileDoubleClose)
|
|
|
|
t.Run("TestReadSeek", TestReadSeek)
|
|
|
|
t.Run("TestWriteFileNoWrite", TestWriteFileNoWrite)
|
|
|
|
t.Run("TestWriteFileWrite", TestWriteFileWrite)
|
|
|
|
t.Run("TestWriteFileOverwrite", TestWriteFileOverwrite)
|
|
|
|
t.Run("TestWriteFileDoubleClose", TestWriteFileDoubleClose)
|
|
|
|
t.Run("TestWriteFileFsync", TestWriteFileFsync)
|
2019-10-06 22:05:21 +02:00
|
|
|
t.Run("TestWriteFileDup", TestWriteFileDup)
|
2019-10-15 02:57:15 +02:00
|
|
|
t.Run("TestWriteFileAppend", TestWriteFileAppend)
|
2018-04-08 12:18:15 +02:00
|
|
|
})
|
2024-08-18 16:58:35 +02:00
|
|
|
fs.Logf(nil, "Finished test run with %s (ok=%v)", what, ok)
|
2022-06-16 13:08:11 +02:00
|
|
|
run.Finalise()
|
2018-04-08 12:18:15 +02:00
|
|
|
if !ok {
|
2017-11-07 19:03:23 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run holds the remotes for a test run
|
|
|
|
type Run struct {
|
2022-04-21 21:28:09 +02:00
|
|
|
os Oser
|
2022-06-16 13:08:11 +02:00
|
|
|
vfsOpt *vfscommon.Options
|
2022-04-21 21:28:09 +02:00
|
|
|
useVFS bool // set if we are testing a VFS not a mount
|
|
|
|
mountPath string
|
|
|
|
fremote fs.Fs
|
|
|
|
fremoteName string
|
|
|
|
cleanRemote func()
|
|
|
|
skip bool
|
2022-06-16 13:08:11 +02:00
|
|
|
// For controlling the subprocess running the mount
|
|
|
|
cmdMu sync.Mutex
|
|
|
|
cmd *exec.Cmd
|
|
|
|
in io.ReadCloser
|
|
|
|
out io.WriteCloser
|
|
|
|
scanner *bufio.Scanner
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// run holds the master Run data
|
|
|
|
var run *Run
|
|
|
|
|
|
|
|
// newRun initialise the remote mount for testing and returns a run
|
|
|
|
// object.
|
|
|
|
//
|
|
|
|
// r.fremote is an empty remote Fs
|
|
|
|
//
|
|
|
|
// Finalise() will tidy them away when done.
|
2022-06-16 13:08:11 +02:00
|
|
|
func newRun(useVFS bool, vfsOpt *vfscommon.Options, mountFn mountlib.MountFn) *Run {
|
2016-07-18 00:03:23 +02:00
|
|
|
r := &Run{
|
2022-04-21 21:28:09 +02:00
|
|
|
useVFS: useVFS,
|
2022-06-16 13:08:11 +02:00
|
|
|
vfsOpt: vfsOpt,
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
2022-06-16 13:08:11 +02:00
|
|
|
r.vfsOpt.Init()
|
2017-07-24 23:46:43 +02:00
|
|
|
fstest.Initialise()
|
|
|
|
|
2016-07-18 00:03:23 +02:00
|
|
|
var err error
|
2019-08-08 20:58:02 +02:00
|
|
|
r.fremote, r.fremoteName, r.cleanRemote, err = fstest.RandomRemote()
|
2016-07-18 00:03:23 +02:00
|
|
|
if err != nil {
|
2024-08-18 16:58:35 +02:00
|
|
|
fs.Fatalf(nil, "Failed to open remote %q: %v", *fstest.RemoteName, err)
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
2019-06-17 10:34:30 +02:00
|
|
|
err = r.fremote.Mkdir(context.Background(), "")
|
2016-11-05 10:57:45 +01:00
|
|
|
if err != nil {
|
2024-08-18 16:58:35 +02:00
|
|
|
fs.Fatalf(nil, "Failed to open mkdir %q: %v", *fstest.RemoteName, err)
|
2016-11-05 10:57:45 +01:00
|
|
|
}
|
|
|
|
|
2022-06-16 13:08:11 +02:00
|
|
|
r.startMountSubProcess()
|
2018-05-28 17:49:26 +02:00
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2016-08-20 13:43:33 +02:00
|
|
|
func (r *Run) skipIfNoFUSE(t *testing.T) {
|
|
|
|
if r.skip {
|
|
|
|
t.Skip("FUSE not found so skipping test")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 14:33:46 +02:00
|
|
|
func (r *Run) skipIfVFS(t *testing.T) {
|
|
|
|
if r.useVFS {
|
|
|
|
t.Skip("Not running under VFS")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-18 00:03:23 +02:00
|
|
|
// Finalise cleans the remote and unmounts
|
|
|
|
func (r *Run) Finalise() {
|
2022-06-16 13:08:11 +02:00
|
|
|
if !r.useVFS {
|
|
|
|
r.sendMountCommand("exit")
|
|
|
|
_, err := r.cmd.Process.Wait()
|
|
|
|
if err != nil {
|
2024-08-18 16:58:35 +02:00
|
|
|
fs.Fatalf(nil, "mount sub process failed: %v", err)
|
2022-06-16 13:08:11 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-18 00:03:23 +02:00
|
|
|
r.cleanRemote()
|
2022-06-16 13:08:11 +02:00
|
|
|
if !r.useVFS {
|
2020-04-16 14:33:46 +02:00
|
|
|
err := os.RemoveAll(r.mountPath)
|
|
|
|
if err != nil {
|
2024-08-18 16:58:35 +02:00
|
|
|
fs.Logf(nil, "Failed to clean mountPath %q: %v", r.mountPath, err)
|
2020-04-16 14:33:46 +02:00
|
|
|
}
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-18 12:59:56 +01:00
|
|
|
// path returns an OS local path for filepath
|
|
|
|
func (r *Run) path(filePath string) string {
|
2020-04-16 14:33:46 +02:00
|
|
|
if r.useVFS {
|
|
|
|
return filePath
|
|
|
|
}
|
2017-11-18 12:59:56 +01:00
|
|
|
// return windows drive letter root as E:\
|
|
|
|
if filePath == "" && runtime.GOOS == "windows" {
|
2022-06-16 13:08:11 +02:00
|
|
|
return r.mountPath + `\`
|
2017-05-08 15:55:05 +02:00
|
|
|
}
|
2022-06-16 13:08:11 +02:00
|
|
|
return filepath.Join(r.mountPath, filepath.FromSlash(filePath))
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type dirMap map[string]struct{}
|
|
|
|
|
|
|
|
// Create a dirMap from a string
|
|
|
|
func newDirMap(dirString string) (dm dirMap) {
|
|
|
|
dm = make(dirMap)
|
|
|
|
for _, entry := range strings.Split(dirString, "|") {
|
|
|
|
if entry != "" {
|
|
|
|
dm[entry] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dm
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a dirmap with only the files in
|
|
|
|
func (dm dirMap) filesOnly() dirMap {
|
|
|
|
newDm := make(dirMap)
|
|
|
|
for name := range dm {
|
|
|
|
if !strings.HasSuffix(name, "/") {
|
|
|
|
newDm[name] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newDm
|
|
|
|
}
|
|
|
|
|
|
|
|
// reads the local tree into dir
|
2017-11-18 12:59:56 +01:00
|
|
|
func (r *Run) readLocal(t *testing.T, dir dirMap, filePath string) {
|
|
|
|
realPath := r.path(filePath)
|
2020-04-16 14:33:46 +02:00
|
|
|
files, err := r.os.ReadDir(realPath)
|
2016-07-18 00:03:23 +02:00
|
|
|
require.NoError(t, err)
|
|
|
|
for _, fi := range files {
|
2017-11-18 12:59:56 +01:00
|
|
|
name := path.Join(filePath, fi.Name())
|
2016-07-18 00:03:23 +02:00
|
|
|
if fi.IsDir() {
|
|
|
|
dir[name+"/"] = struct{}{}
|
|
|
|
r.readLocal(t, dir, name)
|
2024-07-03 12:34:29 +02:00
|
|
|
assert.Equal(t, os.FileMode(r.vfsOpt.DirPerms)&os.ModePerm, fi.Mode().Perm())
|
2016-07-18 00:03:23 +02:00
|
|
|
} else {
|
|
|
|
dir[fmt.Sprintf("%s %d", name, fi.Size())] = struct{}{}
|
2024-07-03 12:34:29 +02:00
|
|
|
assert.Equal(t, os.FileMode(r.vfsOpt.FilePerms)&os.ModePerm, fi.Mode().Perm())
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// reads the remote tree into dir
|
|
|
|
func (r *Run) readRemote(t *testing.T, dir dirMap, filepath string) {
|
2019-06-17 10:34:30 +02:00
|
|
|
objs, dirs, err := walk.GetAll(context.Background(), r.fremote, filepath, true, 1)
|
2016-07-18 00:03:23 +02:00
|
|
|
if err == fs.ErrorDirNotFound {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
require.NoError(t, err)
|
|
|
|
for _, obj := range objs {
|
|
|
|
dir[fmt.Sprintf("%s %d", obj.Remote(), obj.Size())] = struct{}{}
|
|
|
|
}
|
|
|
|
for _, d := range dirs {
|
|
|
|
name := d.Remote()
|
|
|
|
dir[name+"/"] = struct{}{}
|
|
|
|
r.readRemote(t, dir, name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// checkDir checks the local and remote against the string passed in
|
|
|
|
func (r *Run) checkDir(t *testing.T, dirString string) {
|
2017-11-17 11:30:35 +01:00
|
|
|
var retries = *fstest.ListRetries
|
2017-11-18 12:59:56 +01:00
|
|
|
sleep := time.Second / 5
|
2017-11-17 11:30:35 +01:00
|
|
|
var remoteOK, fuseOK bool
|
2017-11-18 12:59:56 +01:00
|
|
|
var dm, localDm, remoteDm dirMap
|
2017-11-17 11:30:35 +01:00
|
|
|
for i := 1; i <= retries; i++ {
|
2017-11-18 12:59:56 +01:00
|
|
|
dm = newDirMap(dirString)
|
|
|
|
localDm = make(dirMap)
|
2017-11-17 11:30:35 +01:00
|
|
|
r.readLocal(t, localDm, "")
|
2017-11-18 12:59:56 +01:00
|
|
|
remoteDm = make(dirMap)
|
2017-11-17 11:30:35 +01:00
|
|
|
r.readRemote(t, remoteDm, "")
|
|
|
|
// Ignore directories for remote compare
|
|
|
|
remoteOK = reflect.DeepEqual(dm.filesOnly(), remoteDm.filesOnly())
|
|
|
|
fuseOK = reflect.DeepEqual(dm, localDm)
|
|
|
|
if remoteOK && fuseOK {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
sleep *= 2
|
|
|
|
t.Logf("Sleeping for %v for list eventual consistency: %d/%d", sleep, i, retries)
|
|
|
|
time.Sleep(sleep)
|
|
|
|
}
|
2017-11-18 12:59:56 +01:00
|
|
|
assert.Equal(t, dm.filesOnly(), remoteDm.filesOnly(), "expected vs remote")
|
|
|
|
assert.Equal(t, dm, localDm, "expected vs fuse mount")
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
2020-01-08 18:14:35 +01:00
|
|
|
// writeFile writes data to a file named by filename.
|
|
|
|
// If the file does not exist, WriteFile creates it with permissions perm;
|
|
|
|
// otherwise writeFile truncates it before writing.
|
|
|
|
// If there is an error writing then writeFile
|
|
|
|
// deletes it an existing file and tries again.
|
|
|
|
func writeFile(filename string, data []byte, perm os.FileMode) error {
|
2020-04-16 14:33:46 +02:00
|
|
|
f, err := run.os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
|
2020-01-08 18:14:35 +01:00
|
|
|
if err != nil {
|
2020-04-16 14:33:46 +02:00
|
|
|
err = run.os.Remove(filename)
|
2020-01-08 18:14:35 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-04-16 14:33:46 +02:00
|
|
|
f, err = run.os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, perm)
|
2020-01-08 18:14:35 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
n, err := f.Write(data)
|
|
|
|
if err == nil && n < len(data) {
|
|
|
|
err = io.ErrShortWrite
|
|
|
|
}
|
|
|
|
if err1 := f.Close(); err == nil {
|
|
|
|
err = err1
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-07-18 00:03:23 +02:00
|
|
|
func (r *Run) createFile(t *testing.T, filepath string, contents string) {
|
|
|
|
filepath = r.path(filepath)
|
2023-10-04 19:33:12 +02:00
|
|
|
err := writeFile(filepath, []byte(contents), 0644)
|
2016-07-18 00:03:23 +02:00
|
|
|
require.NoError(t, err)
|
2017-11-18 16:50:38 +01:00
|
|
|
r.waitForWriters()
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Run) readFile(t *testing.T, filepath string) string {
|
|
|
|
filepath = r.path(filepath)
|
2022-06-16 13:08:11 +02:00
|
|
|
result, err := r.os.ReadFile(filepath)
|
2016-07-18 00:03:23 +02:00
|
|
|
require.NoError(t, err)
|
|
|
|
return string(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Run) mkdir(t *testing.T, filepath string) {
|
|
|
|
filepath = r.path(filepath)
|
2023-10-04 19:33:12 +02:00
|
|
|
err := r.os.Mkdir(filepath, 0755)
|
2016-07-18 00:03:23 +02:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Run) rm(t *testing.T, filepath string) {
|
|
|
|
filepath = r.path(filepath)
|
2022-06-16 13:08:11 +02:00
|
|
|
err := r.os.Remove(filepath)
|
2016-07-18 00:03:23 +02:00
|
|
|
require.NoError(t, err)
|
2017-11-18 19:40:28 +01:00
|
|
|
|
|
|
|
// Wait for file to disappear from listing
|
2018-03-09 22:16:16 +01:00
|
|
|
for i := 0; i < 100; i++ {
|
2022-06-16 13:08:11 +02:00
|
|
|
_, err := r.os.Stat(filepath)
|
2017-11-18 19:40:28 +01:00
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
}
|
|
|
|
assert.Fail(t, "failed to delete file", filepath)
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Run) rmdir(t *testing.T, filepath string) {
|
|
|
|
filepath = r.path(filepath)
|
2022-06-16 13:08:11 +02:00
|
|
|
err := r.os.Remove(filepath)
|
2016-07-18 00:03:23 +02:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2017-05-08 19:05:12 +02:00
|
|
|
// TestMount checks that the Fs is mounted by seeing if the mountpoint
|
|
|
|
// is in the mount output
|
2016-07-18 00:03:23 +02:00
|
|
|
func TestMount(t *testing.T) {
|
2020-04-16 14:33:46 +02:00
|
|
|
run.skipIfVFS(t)
|
2016-08-20 13:43:33 +02:00
|
|
|
run.skipIfNoFUSE(t)
|
2017-11-18 13:05:17 +01:00
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
t.Skip("not running on windows")
|
|
|
|
}
|
2016-08-20 13:43:33 +02:00
|
|
|
|
2016-07-18 00:03:23 +02:00
|
|
|
out, err := exec.Command("mount").Output()
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Contains(t, string(out), run.mountPath)
|
|
|
|
}
|
|
|
|
|
2017-05-08 19:05:12 +02:00
|
|
|
// TestRoot checks root directory is present and correct
|
2016-07-18 00:03:23 +02:00
|
|
|
func TestRoot(t *testing.T) {
|
2020-04-16 14:33:46 +02:00
|
|
|
run.skipIfVFS(t)
|
2016-08-20 13:43:33 +02:00
|
|
|
run.skipIfNoFUSE(t)
|
|
|
|
|
2016-07-18 00:03:23 +02:00
|
|
|
fi, err := os.Lstat(run.mountPath)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.True(t, fi.IsDir())
|
2024-07-03 12:34:29 +02:00
|
|
|
assert.Equal(t, os.FileMode(run.vfsOpt.DirPerms)&os.ModePerm, fi.Mode().Perm())
|
2016-07-18 00:03:23 +02:00
|
|
|
}
|