forked from TrueCloudLab/rclone
mounttest: run the tests for all 4 VFS cache modes
This commit is contained in:
parent
d7908c06c9
commit
57a5c67729
3 changed files with 30 additions and 3 deletions
|
@ -129,6 +129,8 @@ func mount(f fs.Fs, mountpoint string) (*vfs.VFS, <-chan error, func() error, er
|
||||||
|
|
||||||
// unmount
|
// unmount
|
||||||
unmount := func() error {
|
unmount := func() error {
|
||||||
|
// Shutdown the VFS
|
||||||
|
fsys.VFS.Shutdown()
|
||||||
fs.Debugf(nil, "Calling host.Unmount")
|
fs.Debugf(nil, "Calling host.Unmount")
|
||||||
if host.Unmount() {
|
if host.Unmount() {
|
||||||
fs.Debugf(nil, "host.Unmount succeeded")
|
fs.Debugf(nil, "host.Unmount succeeded")
|
||||||
|
|
|
@ -100,6 +100,8 @@ func mount(f fs.Fs, mountpoint string) (*vfs.VFS, <-chan error, func() error, er
|
||||||
}
|
}
|
||||||
|
|
||||||
unmount := func() error {
|
unmount := func() error {
|
||||||
|
// Shutdown the VFS
|
||||||
|
filesys.VFS.Shutdown()
|
||||||
return fuse.Unmount(mountpoint)
|
return fuse.Unmount(mountpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
_ "github.com/ncw/rclone/fs/all" // import all the file systems
|
_ "github.com/ncw/rclone/fs/all" // import all the file systems
|
||||||
"github.com/ncw/rclone/fstest"
|
"github.com/ncw/rclone/fstest"
|
||||||
"github.com/ncw/rclone/vfs"
|
"github.com/ncw/rclone/vfs"
|
||||||
|
"github.com/ncw/rclone/vfs/vfsflags"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -38,9 +39,25 @@ var (
|
||||||
func TestMain(m *testing.M, fn MountFn) {
|
func TestMain(m *testing.M, fn MountFn) {
|
||||||
mountFn = fn
|
mountFn = fn
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
run = newRun()
|
var rc int
|
||||||
rc := m.Run()
|
cacheModes := []vfs.CacheMode{
|
||||||
run.Finalise()
|
vfs.CacheModeOff,
|
||||||
|
vfs.CacheModeMinimal,
|
||||||
|
vfs.CacheModeWrites,
|
||||||
|
vfs.CacheModeFull,
|
||||||
|
}
|
||||||
|
for _, cacheMode := range cacheModes {
|
||||||
|
vfsflags.Opt.CacheMode = cacheMode
|
||||||
|
log.Printf("Starting test run with cache mode %v", cacheMode)
|
||||||
|
run = newRun()
|
||||||
|
rc = m.Run()
|
||||||
|
run.Finalise()
|
||||||
|
log.Printf("Finished test run with cache mode %v", cacheMode)
|
||||||
|
if rc != 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vfsflags.Opt.CacheMode = vfs.DefaultOpt.CacheMode
|
||||||
os.Exit(rc)
|
os.Exit(rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +164,12 @@ func (r *Run) umount() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("umount failed: %v", err)
|
log.Fatalf("umount failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup the VFS cache - umount has called Shutdown
|
||||||
|
err = r.vfs.CleanUp()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to cleanup the VFS cache: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Run) skipIfNoFUSE(t *testing.T) {
|
func (r *Run) skipIfNoFUSE(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue