Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
8363cf88
Commit
8363cf88
authored
Apr 03, 2023
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/testutil: drop TempDir
Change-Id: I9357f137487d1c958a95ed46db081b7775604b6b
parent
bd47fe9b
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
47 additions
and
160 deletions
+47
-160
benchmark/stat_test.go
benchmark/stat_test.go
+8
-5
fs/loopback_linux_test.go
fs/loopback_linux_test.go
+1
-2
fs/mem_test.go
fs/mem_test.go
+1
-4
fs/simple_test.go
fs/simple_test.go
+2
-6
fuse/pathfs/copy_test.go
fuse/pathfs/copy_test.go
+2
-7
fuse/pathfs/owner_test.go
fuse/pathfs/owner_test.go
+1
-2
fuse/pathfs/xattr_test.go
fuse/pathfs/xattr_test.go
+1
-3
fuse/test/cache_test.go
fuse/test/cache_test.go
+4
-9
fuse/test/cachecontrol_test.go
fuse/test/cachecontrol_test.go
+1
-7
fuse/test/defaultnode_test.go
fuse/test/defaultnode_test.go
+1
-2
fuse/test/defaultread_test.go
fuse/test/defaultread_test.go
+1
-3
fuse/test/delete_linux_test.go
fuse/test/delete_linux_test.go
+1
-2
fuse/test/file_lock_test.go
fuse/test/file_lock_test.go
+3
-13
fuse/test/fsetattr_test.go
fuse/test/fsetattr_test.go
+1
-3
fuse/test/loopback_linux_test.go
fuse/test/loopback_linux_test.go
+3
-6
fuse/test/loopback_test.go
fuse/test/loopback_test.go
+2
-4
fuse/test/mount_test.go
fuse/test/mount_test.go
+2
-5
fuse/test/nil_file_truncation_test.go
fuse/test/nil_file_truncation_test.go
+1
-7
fuse/test/node_parallel_lookup_test.go
fuse/test/node_parallel_lookup_test.go
+1
-8
fuse/test/node_test.go
fuse/test/node_test.go
+1
-1
fuse/test/nofile_test.go
fuse/test/nofile_test.go
+1
-8
fuse/test/notify_linux_test.go
fuse/test/notify_linux_test.go
+1
-1
fuse/test/umask_test.go
fuse/test/umask_test.go
+1
-1
fuse/test/xattr_test.go
fuse/test/xattr_test.go
+2
-5
internal/testutil/tempdir.go
internal/testutil/tempdir.go
+0
-38
newunionfs/unionfs_test.go
newunionfs/unionfs_test.go
+1
-2
zipfs/multizip_test.go
zipfs/multizip_test.go
+1
-2
zipfs/tarfs_test.go
zipfs/tarfs_test.go
+1
-2
zipfs/zipfs_test.go
zipfs/zipfs_test.go
+1
-2
No files found.
benchmark/stat_test.go
View file @
8363cf88
...
@@ -25,7 +25,10 @@ import (
...
@@ -25,7 +25,10 @@ import (
func
setupFs
(
node
fs
.
InodeEmbedder
,
N
int
)
(
string
,
func
())
{
func
setupFs
(
node
fs
.
InodeEmbedder
,
N
int
)
(
string
,
func
())
{
opts
:=
&
fs
.
Options
{}
opts
:=
&
fs
.
Options
{}
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
mountPoint
:=
testutil
.
TempDir
()
mountPoint
,
err
:=
os
.
MkdirTemp
(
""
,
""
)
if
err
!=
nil
{
log
.
Panicf
(
"TempDir: %v"
,
err
)
}
server
,
err
:=
fs
.
Mount
(
mountPoint
,
node
,
opts
)
server
,
err
:=
fs
.
Mount
(
mountPoint
,
node
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Panicf
(
"cannot mount %v"
,
err
)
log
.
Panicf
(
"cannot mount %v"
,
err
)
...
@@ -53,8 +56,6 @@ func setupFs(node fs.InodeEmbedder, N int) (string, func()) {
...
@@ -53,8 +56,6 @@ func setupFs(node fs.InodeEmbedder, N int) (string, func()) {
err
:=
server
.
Unmount
()
err
:=
server
.
Unmount
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"error during unmount"
,
err
)
log
.
Println
(
"error during unmount"
,
err
)
}
else
{
os
.
RemoveAll
(
mountPoint
)
}
}
}
}
}
}
...
@@ -251,8 +252,10 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
...
@@ -251,8 +252,10 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
}
}
f
.
Close
()
f
.
Close
()
mountPoint
:=
testutil
.
TempDir
()
mountPoint
,
err
:=
os
.
MkdirTemp
(
""
,
""
)
defer
os
.
RemoveAll
(
mountPoint
)
if
err
!=
nil
{
b
.
Fatalf
(
"MkdirTemp: %v"
,
err
)
}
cmd
:=
exec
.
Command
(
wd
+
"/cstatfs"
,
cmd
:=
exec
.
Command
(
wd
+
"/cstatfs"
,
"-o"
,
"-o"
,
...
...
fs/loopback_linux_test.go
View file @
8363cf88
...
@@ -301,7 +301,7 @@ func waitMount(mnt string) error {
...
@@ -301,7 +301,7 @@ func waitMount(mnt string) error {
func
TestParallelDiropsHang
(
t
*
testing
.
T
)
{
func
TestParallelDiropsHang
(
t
*
testing
.
T
)
{
// We do NOT want to use newTestCase() here because we need to know the
// We do NOT want to use newTestCase() here because we need to know the
// mnt path before the filesystem is mounted
// mnt path before the filesystem is mounted
dir
:=
t
estutil
.
TempDir
()
dir
:=
t
.
TempDir
()
orig
:=
dir
+
"/orig"
orig
:=
dir
+
"/orig"
mnt
:=
dir
+
"/mnt"
mnt
:=
dir
+
"/mnt"
if
err
:=
os
.
Mkdir
(
orig
,
0755
);
err
!=
nil
{
if
err
:=
os
.
Mkdir
(
orig
,
0755
);
err
!=
nil
{
...
@@ -310,7 +310,6 @@ func TestParallelDiropsHang(t *testing.T) {
...
@@ -310,7 +310,6 @@ func TestParallelDiropsHang(t *testing.T) {
if
err
:=
os
.
Mkdir
(
mnt
,
0755
);
err
!=
nil
{
if
err
:=
os
.
Mkdir
(
mnt
,
0755
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
os
.
RemoveAll
(
dir
)
// Unblock the goroutines onces the mount shows up in /proc/self/mounts
// Unblock the goroutines onces the mount shows up in /proc/self/mounts
wait
:=
make
(
chan
struct
{})
wait
:=
make
(
chan
struct
{})
...
...
fs/mem_test.go
View file @
8363cf88
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
func
testMount
(
t
*
testing
.
T
,
root
InodeEmbedder
,
opts
*
Options
)
(
string
,
*
fuse
.
Server
)
{
func
testMount
(
t
*
testing
.
T
,
root
InodeEmbedder
,
opts
*
Options
)
(
string
,
*
fuse
.
Server
)
{
t
.
Helper
()
t
.
Helper
()
mntDir
:=
t
estutil
.
TempDir
()
mntDir
:=
t
.
TempDir
()
if
opts
==
nil
{
if
opts
==
nil
{
opts
=
&
Options
{
opts
=
&
Options
{
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
...
@@ -40,9 +40,6 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.S
...
@@ -40,9 +40,6 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.S
if
err
:=
server
.
Unmount
();
err
!=
nil
{
if
err
:=
server
.
Unmount
();
err
!=
nil
{
t
.
Fatalf
(
"testMount: Unmount failed: %v"
,
err
)
t
.
Fatalf
(
"testMount: Unmount failed: %v"
,
err
)
}
}
if
err
:=
syscall
.
Rmdir
(
mntDir
);
err
!=
nil
{
t
.
Errorf
(
"testMount: Remove failed: %v"
,
err
)
}
})
})
return
mntDir
,
server
return
mntDir
,
server
}
}
...
...
fs/simple_test.go
View file @
8363cf88
...
@@ -50,9 +50,6 @@ func (tc *testCase) clean() {
...
@@ -50,9 +50,6 @@ func (tc *testCase) clean() {
if
err
:=
tc
.
server
.
Unmount
();
err
!=
nil
{
if
err
:=
tc
.
server
.
Unmount
();
err
!=
nil
{
tc
.
Fatal
(
err
)
tc
.
Fatal
(
err
)
}
}
if
err
:=
os
.
RemoveAll
(
tc
.
dir
);
err
!=
nil
{
tc
.
Fatal
(
err
)
}
}
}
type
testOptions
struct
{
type
testOptions
struct
{
...
@@ -73,7 +70,7 @@ func newTestCase(t *testing.T, opts *testOptions) *testCase {
...
@@ -73,7 +70,7 @@ func newTestCase(t *testing.T, opts *testOptions) *testCase {
opts
=
&
testOptions
{}
opts
=
&
testOptions
{}
}
}
if
opts
.
testDir
==
""
{
if
opts
.
testDir
==
""
{
opts
.
testDir
=
t
estutil
.
TempDir
()
opts
.
testDir
=
t
.
TempDir
()
}
}
tc
:=
&
testCase
{
tc
:=
&
testCase
{
dir
:
opts
.
testDir
,
dir
:
opts
.
testDir
,
...
@@ -356,8 +353,7 @@ func TestMknod(t *testing.T) {
...
@@ -356,8 +353,7 @@ func TestMknod(t *testing.T) {
}
}
func
TestMknodNotSupported
(
t
*
testing
.
T
)
{
func
TestMknodNotSupported
(
t
*
testing
.
T
)
{
mountPoint
:=
testutil
.
TempDir
()
mountPoint
:=
t
.
TempDir
()
defer
os
.
Remove
(
mountPoint
)
server
,
err
:=
Mount
(
mountPoint
,
&
Inode
{},
nil
)
server
,
err
:=
Mount
(
mountPoint
,
&
Inode
{},
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
fuse/pathfs/copy_test.go
View file @
8363cf88
...
@@ -6,17 +6,12 @@ package pathfs
...
@@ -6,17 +6,12 @@ package pathfs
import
(
import
(
"io/ioutil"
"io/ioutil"
"os"
"testing"
"testing"
"github.com/hanwen/go-fuse/v2/internal/testutil"
)
)
func
TestCopyFile
(
t
*
testing
.
T
)
{
func
TestCopyFile
(
t
*
testing
.
T
)
{
d1
:=
testutil
.
TempDir
()
d1
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
d1
)
d2
:=
t
.
TempDir
()
d2
:=
testutil
.
TempDir
()
defer
os
.
RemoveAll
(
d2
)
fs1
:=
NewLoopbackFileSystem
(
d1
)
fs1
:=
NewLoopbackFileSystem
(
d1
)
fs2
:=
NewLoopbackFileSystem
(
d2
)
fs2
:=
NewLoopbackFileSystem
(
d2
)
...
...
fuse/pathfs/owner_test.go
View file @
8363cf88
...
@@ -35,7 +35,7 @@ func (fs *ownerFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse
...
@@ -35,7 +35,7 @@ func (fs *ownerFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse
}
}
func
setupOwnerTest
(
t
*
testing
.
T
,
opts
*
nodefs
.
Options
)
(
workdir
string
,
cleanup
func
())
{
func
setupOwnerTest
(
t
*
testing
.
T
,
opts
*
nodefs
.
Options
)
(
workdir
string
,
cleanup
func
())
{
wd
:=
t
estutil
.
TempDir
()
wd
:=
t
.
TempDir
()
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
fs
:=
&
ownerFs
{
NewDefaultFileSystem
()}
fs
:=
&
ownerFs
{
NewDefaultFileSystem
()}
...
@@ -50,7 +50,6 @@ func setupOwnerTest(t *testing.T, opts *nodefs.Options) (workdir string, cleanup
...
@@ -50,7 +50,6 @@ func setupOwnerTest(t *testing.T, opts *nodefs.Options) (workdir string, cleanup
}
}
return
wd
,
func
()
{
return
wd
,
func
()
{
state
.
Unmount
()
state
.
Unmount
()
os
.
RemoveAll
(
wd
)
}
}
}
}
...
...
fuse/pathfs/xattr_test.go
View file @
8363cf88
...
@@ -16,7 +16,6 @@ import (
...
@@ -16,7 +16,6 @@ import (
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/fuse/nodefs"
"github.com/hanwen/go-fuse/v2/fuse/nodefs"
"github.com/hanwen/go-fuse/v2/internal/testutil"
)
)
var
xattrGolden
=
map
[
string
][]
byte
{
var
xattrGolden
=
map
[
string
][]
byte
{
...
@@ -103,7 +102,7 @@ func (fs *XAttrTestFs) RemoveXAttr(name string, attr string, context *fuse.Conte
...
@@ -103,7 +102,7 @@ func (fs *XAttrTestFs) RemoveXAttr(name string, attr string, context *fuse.Conte
func
xattrTestCase
(
t
*
testing
.
T
,
nm
string
,
m
map
[
string
][]
byte
)
(
mountPoint
string
,
cleanup
func
())
{
func
xattrTestCase
(
t
*
testing
.
T
,
nm
string
,
m
map
[
string
][]
byte
)
(
mountPoint
string
,
cleanup
func
())
{
xfs
:=
NewXAttrFs
(
nm
,
m
)
xfs
:=
NewXAttrFs
(
nm
,
m
)
mountPoint
=
t
estutil
.
TempDir
()
mountPoint
=
t
.
TempDir
()
nfs
:=
NewPathNodeFs
(
xfs
,
nil
)
nfs
:=
NewPathNodeFs
(
xfs
,
nil
)
state
,
_
,
err
:=
nodefs
.
MountRoot
(
mountPoint
,
nfs
.
Root
(),
state
,
_
,
err
:=
nodefs
.
MountRoot
(
mountPoint
,
nfs
.
Root
(),
...
@@ -115,7 +114,6 @@ func xattrTestCase(t *testing.T, nm string, m map[string][]byte) (mountPoint str
...
@@ -115,7 +114,6 @@ func xattrTestCase(t *testing.T, nm string, m map[string][]byte) (mountPoint str
go
state
.
Serve
()
go
state
.
Serve
()
return
mountPoint
,
func
()
{
return
mountPoint
,
func
()
{
state
.
Unmount
()
state
.
Unmount
()
os
.
RemoveAll
(
mountPoint
)
}
}
}
}
...
...
fuse/test/cache_test.go
View file @
8363cf88
...
@@ -37,7 +37,7 @@ func (fs *cacheFs) Open(name string, flags uint32, context *fuse.Context) (fuseF
...
@@ -37,7 +37,7 @@ func (fs *cacheFs) Open(name string, flags uint32, context *fuse.Context) (fuseF
}
}
func
setupCacheTest
(
t
*
testing
.
T
)
(
string
,
*
pathfs
.
PathNodeFs
,
func
())
{
func
setupCacheTest
(
t
*
testing
.
T
)
(
string
,
*
pathfs
.
PathNodeFs
,
func
())
{
dir
:=
t
estutil
.
TempDir
()
dir
:=
t
.
TempDir
()
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
...
@@ -65,10 +65,7 @@ func setupCacheTest(t *testing.T) (string, *pathfs.PathNodeFs, func()) {
...
@@ -65,10 +65,7 @@ func setupCacheTest(t *testing.T) (string, *pathfs.PathNodeFs, func()) {
t
.
Fatal
(
"WaitMount"
,
err
)
t
.
Fatal
(
"WaitMount"
,
err
)
}
}
return
dir
,
pfs
,
func
()
{
return
dir
,
pfs
,
func
()
{
err
:=
state
.
Unmount
()
state
.
Unmount
()
if
err
==
nil
{
os
.
RemoveAll
(
dir
)
}
}
}
}
}
...
@@ -186,8 +183,7 @@ func TestNonseekable(t *testing.T) {
...
@@ -186,8 +183,7 @@ func TestNonseekable(t *testing.T) {
fs
:=
&
nonseekFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
()}
fs
:=
&
nonseekFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
()}
fs
.
Length
=
200
*
1024
fs
.
Length
=
200
*
1024
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
nfs
:=
pathfs
.
NewPathNodeFs
(
fs
,
nil
)
nfs
:=
pathfs
.
NewPathNodeFs
(
fs
,
nil
)
opts
:=
nodefs
.
NewOptions
()
opts
:=
nodefs
.
NewOptions
()
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
...
@@ -216,8 +212,7 @@ func TestNonseekable(t *testing.T) {
...
@@ -216,8 +212,7 @@ func TestNonseekable(t *testing.T) {
}
}
func
TestGetAttrRace
(
t
*
testing
.
T
)
{
func
TestGetAttrRace
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
...
...
fuse/test/cachecontrol_test.go
View file @
8363cf88
...
@@ -52,13 +52,7 @@ func (d *DataNode) Read(_ nodefs.File, dest []byte, off int64, _ *fuse.Context)
...
@@ -52,13 +52,7 @@ func (d *DataNode) Read(_ nodefs.File, dest []byte, off int64, _ *fuse.Context)
// TestCacheControl verifies that FUSE server process can store/retrieve kernel data cache.
// TestCacheControl verifies that FUSE server process can store/retrieve kernel data cache.
func
TestCacheControl
(
t
*
testing
.
T
)
{
func
TestCacheControl
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
func
()
{
err
:=
os
.
Remove
(
dir
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}()
// setup a filesystem with 1 file
// setup a filesystem with 1 file
root
:=
nodefs
.
NewDefaultNode
()
root
:=
nodefs
.
NewDefaultNode
()
...
...
fuse/test/defaultnode_test.go
View file @
8363cf88
...
@@ -16,8 +16,7 @@ import (
...
@@ -16,8 +16,7 @@ import (
)
)
func
TestDefaultNodeGetAttr
(
t
*
testing
.
T
)
{
func
TestDefaultNodeGetAttr
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
opts
:=
&
nodefs
.
Options
{
opts
:=
&
nodefs
.
Options
{
// Note: defaultNode.GetAttr() calling file.GetAttr() is only useful if
// Note: defaultNode.GetAttr() calling file.GetAttr() is only useful if
...
...
fuse/test/defaultread_test.go
View file @
8363cf88
...
@@ -6,7 +6,6 @@ package test
...
@@ -6,7 +6,6 @@ package test
import
(
import
(
"io/ioutil"
"io/ioutil"
"os"
"testing"
"testing"
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/fuse"
...
@@ -42,7 +41,7 @@ func defaultReadTest(t *testing.T) (root string, cleanup func()) {
...
@@ -42,7 +41,7 @@ func defaultReadTest(t *testing.T) (root string, cleanup func()) {
}
}
var
err
error
var
err
error
dir
:=
t
estutil
.
TempDir
()
dir
:=
t
.
TempDir
()
pathfs
:=
pathfs
.
NewPathNodeFs
(
fs
,
nil
)
pathfs
:=
pathfs
.
NewPathNodeFs
(
fs
,
nil
)
opts
:=
nodefs
.
NewOptions
()
opts
:=
nodefs
.
NewOptions
()
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
...
@@ -57,7 +56,6 @@ func defaultReadTest(t *testing.T) (root string, cleanup func()) {
...
@@ -57,7 +56,6 @@ func defaultReadTest(t *testing.T) (root string, cleanup func()) {
}
}
return
dir
,
func
()
{
return
dir
,
func
()
{
state
.
Unmount
()
state
.
Unmount
()
os
.
Remove
(
dir
)
}
}
}
}
...
...
fuse/test/delete_linux_test.go
View file @
8363cf88
...
@@ -34,8 +34,7 @@ func (f *flipNode) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fu
...
@@ -34,8 +34,7 @@ func (f *flipNode) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fu
}
}
func
TestDeleteNotify
(
t
*
testing
.
T
)
{
func
TestDeleteNotify
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
root
:=
nodefs
.
NewMemNodeFSRoot
(
dir
+
"/backing"
)
root
:=
nodefs
.
NewMemNodeFSRoot
(
dir
+
"/backing"
)
conn
:=
nodefs
.
NewFileSystemConnector
(
root
,
conn
:=
nodefs
.
NewFileSystemConnector
(
root
,
&
nodefs
.
Options
{
PortableInodes
:
true
})
&
nodefs
.
Options
{
PortableInodes
:
true
})
...
...
fuse/test/file_lock_test.go
View file @
8363cf88
...
@@ -123,8 +123,7 @@ func TestFlockInvoked(t *testing.T) {
...
@@ -123,8 +123,7 @@ func TestFlockInvoked(t *testing.T) {
t
.
Skip
(
"flock command not found."
)
t
.
Skip
(
"flock command not found."
)
}
}
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
opts
:=
&
nodefs
.
Options
{
opts
:=
&
nodefs
.
Options
{
Owner
:
fuse
.
CurrentOwner
(),
Owner
:
fuse
.
CurrentOwner
(),
...
@@ -188,17 +187,8 @@ func TestNoLockSupport(t *testing.T) {
...
@@ -188,17 +187,8 @@ func TestNoLockSupport(t *testing.T) {
t
.
Skip
(
"flock command not found."
)
t
.
Skip
(
"flock command not found."
)
}
}
tmp
,
err
:=
ioutil
.
TempDir
(
""
,
"TestNoLockSupport"
)
tmp
:=
t
.
TempDir
()
if
err
!=
nil
{
mnt
:=
t
.
TempDir
()
t
.
Fatal
(
err
)
}
mnt
,
err
:=
ioutil
.
TempDir
(
""
,
"TestNoLockSupport"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
RemoveAll
(
tmp
)
defer
os
.
RemoveAll
(
mnt
)
opts
:=
&
nodefs
.
Options
{
opts
:=
&
nodefs
.
Options
{
Owner
:
fuse
.
CurrentOwner
(),
Owner
:
fuse
.
CurrentOwner
(),
...
...
fuse/test/fsetattr_test.go
View file @
8363cf88
...
@@ -143,7 +143,7 @@ func NewFile() *MutableDataFile {
...
@@ -143,7 +143,7 @@ func NewFile() *MutableDataFile {
}
}
func
setupFAttrTest
(
t
*
testing
.
T
,
fs
pathfs
.
FileSystem
)
(
dir
string
,
clean
func
())
{
func
setupFAttrTest
(
t
*
testing
.
T
,
fs
pathfs
.
FileSystem
)
(
dir
string
,
clean
func
())
{
dir
=
t
estutil
.
TempDir
()
dir
=
t
.
TempDir
()
nfs
:=
pathfs
.
NewPathNodeFs
(
fs
,
nil
)
nfs
:=
pathfs
.
NewPathNodeFs
(
fs
,
nil
)
opts
:=
nodefs
.
NewOptions
()
opts
:=
nodefs
.
NewOptions
()
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
...
@@ -161,8 +161,6 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func(
...
@@ -161,8 +161,6 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func(
clean
=
func
()
{
clean
=
func
()
{
if
err
:=
state
.
Unmount
();
err
!=
nil
{
if
err
:=
state
.
Unmount
();
err
!=
nil
{
t
.
Errorf
(
"cleanup: Unmount: %v"
,
err
)
t
.
Errorf
(
"cleanup: Unmount: %v"
,
err
)
}
else
{
os
.
RemoveAll
(
dir
)
}
}
}
}
...
...
fuse/test/loopback_linux_test.go
View file @
8363cf88
...
@@ -17,7 +17,6 @@ import (
...
@@ -17,7 +17,6 @@ import (
"golang.org/x/sys/unix"
"golang.org/x/sys/unix"
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/internal/testutil"
)
)
var
enableOverlayfsTest
bool
var
enableOverlayfsTest
bool
...
@@ -147,11 +146,9 @@ func TestOverlayfs(t *testing.T) {
...
@@ -147,11 +146,9 @@ func TestOverlayfs(t *testing.T) {
tc
.
Mkdir
(
tc
.
origSubdir
,
0777
)
tc
.
Mkdir
(
tc
.
origSubdir
,
0777
)
tc
.
WriteFile
(
filepath
.
Join
(
tc
.
origSubdir
,
testfile
),
content
,
0700
)
tc
.
WriteFile
(
filepath
.
Join
(
tc
.
origSubdir
,
testfile
),
content
,
0700
)
tmpMergedDir
:=
testutil
.
TempDir
()
tmpMergedDir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
tmpMergedDir
)
tmpWorkDir
:=
t
.
TempDir
()
tmpWorkDir
:=
testutil
.
TempDir
()
tmpUpperDir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
tmpWorkDir
)
tmpUpperDir
:=
testutil
.
TempDir
()
defer
os
.
RemoveAll
(
tmpUpperDir
)
defer
os
.
RemoveAll
(
tmpUpperDir
)
if
err
:=
unix
.
Mount
(
"overlay"
,
tmpMergedDir
,
"overlay"
,
0
,
if
err
:=
unix
.
Mount
(
"overlay"
,
tmpMergedDir
,
"overlay"
,
0
,
fmt
.
Sprintf
(
"lowerdir=%s,upperdir=%s,workdir=%s"
,
tc
.
mnt
,
tmpUpperDir
,
tmpWorkDir
));
err
!=
nil
{
fmt
.
Sprintf
(
"lowerdir=%s,upperdir=%s,workdir=%s"
,
tc
.
mnt
,
tmpUpperDir
,
tmpWorkDir
));
err
!=
nil
{
...
...
fuse/test/loopback_test.go
View file @
8363cf88
...
@@ -77,7 +77,7 @@ func NewTestCase(t *testing.T) *testCase {
...
@@ -77,7 +77,7 @@ func NewTestCase(t *testing.T) *testCase {
const
subdir
string
=
"subdir"
const
subdir
string
=
"subdir"
var
err
error
var
err
error
tc
.
tmpDir
=
t
estutil
.
TempDir
()
tc
.
tmpDir
=
t
.
TempDir
()
tc
.
orig
=
tc
.
tmpDir
+
"/orig"
tc
.
orig
=
tc
.
tmpDir
+
"/orig"
tc
.
mnt
=
tc
.
tmpDir
+
"/mnt"
tc
.
mnt
=
tc
.
tmpDir
+
"/mnt"
...
@@ -125,7 +125,6 @@ func (tc *testCase) Cleanup() {
...
@@ -125,7 +125,6 @@ func (tc *testCase) Cleanup() {
if
err
!=
nil
{
if
err
!=
nil
{
tc
.
tester
.
Fatalf
(
"Unmount failed: %v"
,
err
)
tc
.
tester
.
Fatalf
(
"Unmount failed: %v"
,
err
)
}
}
os
.
RemoveAll
(
tc
.
tmpDir
)
}
}
func
(
tc
*
testCase
)
rootNode
()
*
nodefs
.
Inode
{
func
(
tc
*
testCase
)
rootNode
()
*
nodefs
.
Inode
{
...
@@ -774,8 +773,7 @@ func TestNonVerboseFStatFs(t *testing.T) {
...
@@ -774,8 +773,7 @@ func TestNonVerboseFStatFs(t *testing.T) {
}
}
func
TestOriginalIsSymlink
(
t
*
testing
.
T
)
{
func
TestOriginalIsSymlink
(
t
*
testing
.
T
)
{
tmpDir
:=
testutil
.
TempDir
()
tmpDir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
tmpDir
)
orig
:=
tmpDir
+
"/orig"
orig
:=
tmpDir
+
"/orig"
err
:=
os
.
Mkdir
(
orig
,
0755
)
err
:=
os
.
Mkdir
(
orig
,
0755
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
fuse/test/mount_test.go
View file @
8363cf88
...
@@ -15,7 +15,6 @@ import (
...
@@ -15,7 +15,6 @@ import (
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/fuse/nodefs"
"github.com/hanwen/go-fuse/v2/fuse/nodefs"
"github.com/hanwen/go-fuse/v2/fuse/pathfs"
"github.com/hanwen/go-fuse/v2/fuse/pathfs"
"github.com/hanwen/go-fuse/v2/internal/testutil"
)
)
func
TestMountOnExisting
(
t
*
testing
.
T
)
{
func
TestMountOnExisting
(
t
*
testing
.
T
)
{
...
@@ -171,8 +170,7 @@ func TestDeletedUnmount(t *testing.T) {
...
@@ -171,8 +170,7 @@ func TestDeletedUnmount(t *testing.T) {
}
}
func
TestDefaultNodeMount
(
t
*
testing
.
T
)
{
func
TestDefaultNodeMount
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
root
:=
nodefs
.
NewDefaultNode
()
root
:=
nodefs
.
NewDefaultNode
()
s
,
conn
,
err
:=
nodefs
.
MountRoot
(
dir
,
root
,
nil
)
s
,
conn
,
err
:=
nodefs
.
MountRoot
(
dir
,
root
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -198,8 +196,7 @@ func TestDefaultNodeMount(t *testing.T) {
...
@@ -198,8 +196,7 @@ func TestDefaultNodeMount(t *testing.T) {
}
}
func
TestLiveness
(
t
*
testing
.
T
)
{
func
TestLiveness
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
root
:=
nodefs
.
NewDefaultNode
()
root
:=
nodefs
.
NewDefaultNode
()
s
,
_
,
err
:=
nodefs
.
MountRoot
(
dir
,
root
,
nil
)
s
,
_
,
err
:=
nodefs
.
MountRoot
(
dir
,
root
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
fuse/test/nil_file_truncation_test.go
View file @
8363cf88
...
@@ -28,13 +28,7 @@ func (d *truncatableFile) Truncate(file nodefs.File, size uint64, context *fuse.
...
@@ -28,13 +28,7 @@ func (d *truncatableFile) Truncate(file nodefs.File, size uint64, context *fuse.
// TestNilFileTruncation verifies that the FUSE server process does not
// TestNilFileTruncation verifies that the FUSE server process does not
// crash when file truncation is performed on nil file handles.
// crash when file truncation is performed on nil file handles.
func
TestNilFileTruncation
(
t
*
testing
.
T
)
{
func
TestNilFileTruncation
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
func
()
{
err
:=
os
.
Remove
(
dir
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}()
root
:=
nodefs
.
NewDefaultNode
()
root
:=
nodefs
.
NewDefaultNode
()
opts
:=
nodefs
.
NewOptions
()
opts
:=
nodefs
.
NewOptions
()
...
...
fuse/test/node_parallel_lookup_test.go
View file @
8363cf88
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"log"
"log"
"os"
"testing"
"testing"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/errgroup"
...
@@ -58,13 +57,7 @@ func verifyFileRead(path string, dataOK string) error {
...
@@ -58,13 +57,7 @@ func verifyFileRead(path string, dataOK string) error {
}
}
func
TestNodeParallelLookup
(
t
*
testing
.
T
)
{
func
TestNodeParallelLookup
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
func
()
{
err
:=
os
.
Remove
(
dir
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}()
root
:=
&
tRoot
{
root
:=
&
tRoot
{
Node
:
nodefs
.
NewDefaultNode
(),
Node
:
nodefs
.
NewDefaultNode
(),
...
...
fuse/test/node_test.go
View file @
8363cf88
...
@@ -61,7 +61,7 @@ func (n *rootNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (*
...
@@ -61,7 +61,7 @@ func (n *rootNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (*
}
}
func
TestUpdateNode
(
t
*
testing
.
T
)
{
func
TestUpdateNode
(
t
*
testing
.
T
)
{
dir
:=
t
estutil
.
TempDir
()
dir
:=
t
.
TempDir
()
root
:=
&
rootNode
{
root
:=
&
rootNode
{
Node
:
nodefs
.
NewDefaultNode
(),
Node
:
nodefs
.
NewDefaultNode
(),
backing
:
map
[
string
]
string
{
"a"
:
"aaa"
},
backing
:
map
[
string
]
string
{
"a"
:
"aaa"
},
...
...
fuse/test/nofile_test.go
View file @
8363cf88
...
@@ -6,7 +6,6 @@ package test
...
@@ -6,7 +6,6 @@ package test
import
(
import
(
"io/ioutil"
"io/ioutil"
"os"
"sync/atomic"
"sync/atomic"
"testing"
"testing"
...
@@ -51,13 +50,7 @@ func (d *NoFileNode) Open(flags uint32, context *fuse.Context) (nodefs.File, fus
...
@@ -51,13 +50,7 @@ func (d *NoFileNode) Open(flags uint32, context *fuse.Context) (nodefs.File, fus
}
}
func
TestNoFile
(
t
*
testing
.
T
)
{
func
TestNoFile
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
func
()
{
err
:=
os
.
Remove
(
dir
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}()
// setup a filesystem with 2 files:
// setup a filesystem with 2 files:
//
//
...
...
fuse/test/notify_linux_test.go
View file @
8363cf88
...
@@ -78,7 +78,7 @@ type NotifyTest struct {
...
@@ -78,7 +78,7 @@ type NotifyTest struct {
func
NewNotifyTest
(
t
*
testing
.
T
)
*
NotifyTest
{
func
NewNotifyTest
(
t
*
testing
.
T
)
*
NotifyTest
{
me
:=
&
NotifyTest
{}
me
:=
&
NotifyTest
{}
me
.
fs
=
newNotifyFs
()
me
.
fs
=
newNotifyFs
()
me
.
dir
=
t
estutil
.
TempDir
()
me
.
dir
=
t
.
TempDir
()
entryTTL
:=
100
*
time
.
Millisecond
entryTTL
:=
100
*
time
.
Millisecond
opts
:=
&
nodefs
.
Options
{
opts
:=
&
nodefs
.
Options
{
EntryTimeout
:
entryTTL
,
EntryTimeout
:
entryTTL
,
...
...
fuse/test/umask_test.go
View file @
8363cf88
...
@@ -34,7 +34,7 @@ func (fs *umaskFS) Mkdir(name string, mode uint32, context *fuse.Context) (code
...
@@ -34,7 +34,7 @@ func (fs *umaskFS) Mkdir(name string, mode uint32, context *fuse.Context) (code
}
}
func
TestUmask
(
t
*
testing
.
T
)
{
func
TestUmask
(
t
*
testing
.
T
)
{
tmpDir
:=
t
estutil
.
TempDir
()
tmpDir
:=
t
.
TempDir
()
orig
:=
tmpDir
+
"/orig"
orig
:=
tmpDir
+
"/orig"
mnt
:=
tmpDir
+
"/mnt"
mnt
:=
tmpDir
+
"/mnt"
...
...
fuse/test/xattr_test.go
View file @
8363cf88
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
package
test
package
test
import
(
import
(
"os"
"path/filepath"
"path/filepath"
"syscall"
"syscall"
"testing"
"testing"
...
@@ -40,8 +39,7 @@ func (n *xattrChildNode) GetXAttr(attr string, context *fuse.Context) ([]byte, f
...
@@ -40,8 +39,7 @@ func (n *xattrChildNode) GetXAttr(attr string, context *fuse.Context) ([]byte, f
}
}
func
TestDefaultXAttr
(
t
*
testing
.
T
)
{
func
TestDefaultXAttr
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
root
:=
&
xattrNode
{
root
:=
&
xattrNode
{
Node
:
nodefs
.
NewDefaultNode
(),
Node
:
nodefs
.
NewDefaultNode
(),
...
@@ -70,8 +68,7 @@ func TestDefaultXAttr(t *testing.T) {
...
@@ -70,8 +68,7 @@ func TestDefaultXAttr(t *testing.T) {
}
}
func
TestEmptyXAttr
(
t
*
testing
.
T
)
{
func
TestEmptyXAttr
(
t
*
testing
.
T
)
{
dir
:=
testutil
.
TempDir
()
dir
:=
t
.
TempDir
()
defer
os
.
RemoveAll
(
dir
)
root
:=
&
xattrNode
{
root
:=
&
xattrNode
{
Node
:
nodefs
.
NewDefaultNode
(),
Node
:
nodefs
.
NewDefaultNode
(),
...
...
internal/testutil/tempdir.go
deleted
100644 → 0
View file @
bd47fe9b
// Copyright 2016 the Go-FUSE Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
testutil
import
(
"io/ioutil"
"log"
"runtime"
"strings"
)
// TempDir creates a temporary directory that includes the name of the
// testcase. Panics if there was an I/O problem creating the directory.
func
TempDir
()
string
{
frames
:=
make
([]
uintptr
,
10
)
// at least 1 entry needed
n
:=
runtime
.
Callers
(
1
,
frames
)
lastName
:=
""
for
_
,
pc
:=
range
frames
[
:
n
]
{
f
:=
runtime
.
FuncForPC
(
pc
)
name
:=
f
.
Name
()
i
:=
strings
.
LastIndex
(
name
,
"."
)
if
i
>=
0
{
name
=
name
[
i
+
1
:
]
}
if
strings
.
HasPrefix
(
name
,
"Test"
)
{
lastName
=
name
}
}
dir
,
err
:=
ioutil
.
TempDir
(
""
,
lastName
)
if
err
!=
nil
{
log
.
Panicf
(
"TempDir(%s): %v"
,
lastName
,
err
)
}
return
dir
}
newunionfs/unionfs_test.go
View file @
8363cf88
...
@@ -33,12 +33,11 @@ func (tc *testCase) Clean() {
...
@@ -33,12 +33,11 @@ func (tc *testCase) Clean() {
tc
.
server
.
Unmount
()
tc
.
server
.
Unmount
()
tc
.
server
=
nil
tc
.
server
=
nil
}
}
os
.
RemoveAll
(
tc
.
dir
)
}
}
func
newTestCase
(
t
*
testing
.
T
,
populate
bool
)
*
testCase
{
func
newTestCase
(
t
*
testing
.
T
,
populate
bool
)
*
testCase
{
t
.
Helper
()
t
.
Helper
()
dir
:=
t
estutil
.
TempDir
()
dir
:=
t
.
TempDir
()
dirs
:=
[]
string
{
"ro"
,
"rw"
,
"mnt"
}
dirs
:=
[]
string
{
"ro"
,
"rw"
,
"mnt"
}
if
populate
{
if
populate
{
dirs
=
append
(
dirs
,
"ro/dir"
)
dirs
=
append
(
dirs
,
"ro/dir"
)
...
...
zipfs/multizip_test.go
View file @
8363cf88
...
@@ -19,7 +19,7 @@ const testTtl = 100 * time.Millisecond
...
@@ -19,7 +19,7 @@ const testTtl = 100 * time.Millisecond
func
setupMzfs
(
t
*
testing
.
T
)
(
mountPoint
string
,
state
*
fuse
.
Server
,
cleanup
func
())
{
func
setupMzfs
(
t
*
testing
.
T
)
(
mountPoint
string
,
state
*
fuse
.
Server
,
cleanup
func
())
{
root
:=
&
MultiZipFs
{}
root
:=
&
MultiZipFs
{}
mountPoint
=
t
estutil
.
TempDir
()
mountPoint
=
t
.
TempDir
()
dt
:=
testTtl
dt
:=
testTtl
opts
:=
&
fs
.
Options
{
opts
:=
&
fs
.
Options
{
...
@@ -34,7 +34,6 @@ func setupMzfs(t *testing.T) (mountPoint string, state *fuse.Server, cleanup fun
...
@@ -34,7 +34,6 @@ func setupMzfs(t *testing.T) (mountPoint string, state *fuse.Server, cleanup fun
}
}
return
mountPoint
,
server
,
func
()
{
return
mountPoint
,
server
,
func
()
{
server
.
Unmount
()
server
.
Unmount
()
os
.
RemoveAll
(
mountPoint
)
}
}
}
}
...
...
zipfs/tarfs_test.go
View file @
8363cf88
...
@@ -67,8 +67,7 @@ func TestTar(t *testing.T) {
...
@@ -67,8 +67,7 @@ func TestTar(t *testing.T) {
root
:=
&
tarRoot
{
rc
:
&
addClose
{
buf
}}
root
:=
&
tarRoot
{
rc
:
&
addClose
{
buf
}}
mnt
:=
testutil
.
TempDir
()
mnt
:=
t
.
TempDir
()
defer
os
.
Remove
(
mnt
)
opts
:=
&
fs
.
Options
{}
opts
:=
&
fs
.
Options
{}
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
s
,
err
:=
fs
.
Mount
(
mnt
,
root
,
opts
)
s
,
err
:=
fs
.
Mount
(
mnt
,
root
,
opts
)
...
...
zipfs/zipfs_test.go
View file @
8363cf88
...
@@ -33,14 +33,13 @@ func setupZipfs(t *testing.T) (mountPoint string, cleanup func()) {
...
@@ -33,14 +33,13 @@ func setupZipfs(t *testing.T) (mountPoint string, cleanup func()) {
t
.
Fatalf
(
"NewArchiveFileSystem failed: %v"
,
err
)
t
.
Fatalf
(
"NewArchiveFileSystem failed: %v"
,
err
)
}
}
mountPoint
=
t
estutil
.
TempDir
()
mountPoint
=
t
.
TempDir
()
opts
:=
&
fs
.
Options
{}
opts
:=
&
fs
.
Options
{}
opts
.
Debug
=
testutil
.
VerboseTest
()
opts
.
Debug
=
testutil
.
VerboseTest
()
server
,
err
:=
fs
.
Mount
(
mountPoint
,
root
,
opts
)
server
,
err
:=
fs
.
Mount
(
mountPoint
,
root
,
opts
)
return
mountPoint
,
func
()
{
return
mountPoint
,
func
()
{
server
.
Unmount
()
server
.
Unmount
()
os
.
RemoveAll
(
mountPoint
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment