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
Kirill Smelkov
go-fuse
Commits
ba08cb01
Commit
ba08cb01
authored
Apr 03, 2023
by
Han-Wen Nienhuys
Committed by
Han-Wen Nienhuys
Apr 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs: use testing.Cleanup throughout
Change-Id: I115ebce34aaf22767bb8b90b842927c133e30b65
parent
95d4266e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
71 deletions
+29
-71
fs/bridge_test.go
fs/bridge_test.go
+3
-7
fs/cache_test.go
fs/cache_test.go
+2
-2
fs/directio_test.go
fs/directio_test.go
+1
-2
fs/interrupt_test.go
fs/interrupt_test.go
+2
-9
fs/loopback_linux_test.go
fs/loopback_linux_test.go
+2
-9
fs/maxwrite_test.go
fs/maxwrite_test.go
+1
-2
fs/mem_test.go
fs/mem_test.go
+10
-15
fs/randomtype_test.go
fs/randomtype_test.go
+1
-2
fs/readonly_test.go
fs/readonly_test.go
+2
-4
fs/rmchild_test.go
fs/rmchild_test.go
+1
-2
fs/simple_test.go
fs/simple_test.go
+4
-17
No files found.
fs/bridge_test.go
View file @
ba08cb01
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
func
TestBridgeReaddirPlusVirtualEntries
(
t
*
testing
.
T
)
{
func
TestBridgeReaddirPlusVirtualEntries
(
t
*
testing
.
T
)
{
// Set suppressDebug as we do our own logging
// Set suppressDebug as we do our own logging
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
})
defer
tc
.
Clean
()
rb
:=
tc
.
rawFS
.
(
*
rawBridge
)
rb
:=
tc
.
rawFS
.
(
*
rawBridge
)
...
@@ -92,8 +91,7 @@ func TestBridgeReaddirPlusVirtualEntries(t *testing.T) {
...
@@ -92,8 +91,7 @@ func TestBridgeReaddirPlusVirtualEntries(t *testing.T) {
// we just have not received the FORGET yet.
// we just have not received the FORGET yet.
func
TestTypeChange
(
t
*
testing
.
T
)
{
func
TestTypeChange
(
t
*
testing
.
T
)
{
rootNode
:=
testTypeChangeIno
{}
rootNode
:=
testTypeChangeIno
{}
mnt
,
_
,
clean
:=
testMount
(
t
,
&
rootNode
,
nil
)
mnt
,
_
:=
testMount
(
t
,
&
rootNode
,
nil
)
defer
clean
()
for
i
:=
0
;
i
<
100
;
i
++
{
for
i
:=
0
;
i
<
100
;
i
++
{
fi
,
_
:=
os
.
Stat
(
mnt
+
"/file"
)
fi
,
_
:=
os
.
Stat
(
mnt
+
"/file"
)
...
@@ -141,8 +139,7 @@ func (fn *testTypeChangeIno) Lookup(ctx context.Context, name string, out *fuse.
...
@@ -141,8 +139,7 @@ func (fn *testTypeChangeIno) Lookup(ctx context.Context, name string, out *fuse.
// disconnected from the hierarchy (=orphaned)
// disconnected from the hierarchy (=orphaned)
func
TestDeletedInodePath
(
t
*
testing
.
T
)
{
func
TestDeletedInodePath
(
t
*
testing
.
T
)
{
rootNode
:=
testDeletedIno
{}
rootNode
:=
testDeletedIno
{}
mnt
,
_
,
clean
:=
testMount
(
t
,
&
rootNode
,
&
Options
{
Logger
:
log
.
New
(
os
.
Stderr
,
""
,
0
)})
mnt
,
_
:=
testMount
(
t
,
&
rootNode
,
&
Options
{
Logger
:
log
.
New
(
os
.
Stderr
,
""
,
0
)})
defer
clean
()
// Open a file handle so the kernel cannot FORGET the inode
// Open a file handle so the kernel cannot FORGET the inode
fd
,
err
:=
os
.
Open
(
mnt
+
"/dir"
)
fd
,
err
:=
os
.
Open
(
mnt
+
"/dir"
)
...
@@ -209,8 +206,7 @@ func (n *testDeletedIno) Getattr(ctx context.Context, f FileHandle, out *fuse.At
...
@@ -209,8 +206,7 @@ func (n *testDeletedIno) Getattr(ctx context.Context, f FileHandle, out *fuse.At
// panic: using reserved ID 1 for inode number
// panic: using reserved ID 1 for inode number
func
TestIno1
(
t
*
testing
.
T
)
{
func
TestIno1
(
t
*
testing
.
T
)
{
rootNode
:=
testIno1
{}
rootNode
:=
testIno1
{}
mnt
,
_
,
clean
:=
testMount
(
t
,
&
rootNode
,
nil
)
mnt
,
_
:=
testMount
(
t
,
&
rootNode
,
nil
)
defer
clean
()
var
st
syscall
.
Stat_t
var
st
syscall
.
Stat_t
err
:=
syscall
.
Stat
(
mnt
+
"/ino1"
,
&
st
)
err
:=
syscall
.
Stat
(
mnt
+
"/ino1"
,
&
st
)
...
...
fs/cache_test.go
View file @
ba08cb01
...
@@ -92,8 +92,8 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
...
@@ -92,8 +92,8 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
// change content but no metadata.
// change content but no metadata.
func
TestKeepCache
(
t
*
testing
.
T
)
{
func
TestKeepCache
(
t
*
testing
.
T
)
{
root
:=
&
keepCacheRoot
{}
root
:=
&
keepCacheRoot
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
nil
)
mntDir
,
_
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
c1
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/keep"
)
c1
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/keep"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"read keep 1: %v"
,
err
)
t
.
Fatalf
(
"read keep 1: %v"
,
err
)
...
...
fs/directio_test.go
View file @
ba08cb01
...
@@ -55,8 +55,7 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
...
@@ -55,8 +55,7 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
// this tests FOPEN_DIRECT_IO (as opposed to O_DIRECTIO)
// this tests FOPEN_DIRECT_IO (as opposed to O_DIRECTIO)
func
TestFUSEDirectIO
(
t
*
testing
.
T
)
{
func
TestFUSEDirectIO
(
t
*
testing
.
T
)
{
root
:=
&
dioRoot
{}
root
:=
&
dioRoot
{}
mntDir
,
server
,
clean
:=
testMount
(
t
,
root
,
nil
)
mntDir
,
server
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
f
,
err
:=
os
.
Open
(
mntDir
+
"/file"
)
f
,
err
:=
os
.
Open
(
mntDir
+
"/file"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
fs/interrupt_test.go
View file @
ba08cb01
...
@@ -55,15 +55,10 @@ func TestInterrupt(t *testing.T) {
...
@@ -55,15 +55,10 @@ func TestInterrupt(t *testing.T) {
root
:=
&
interruptRoot
{}
root
:=
&
interruptRoot
{}
oneSec
:=
time
.
Second
oneSec
:=
time
.
Second
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
server
:=
testMount
(
t
,
root
,
&
Options
{
EntryTimeout
:
&
oneSec
,
EntryTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
})
})
defer
func
()
{
if
clean
!=
nil
{
clean
()
}
}()
cmd
:=
exec
.
Command
(
"cat"
,
mntDir
+
"/file"
)
cmd
:=
exec
.
Command
(
"cat"
,
mntDir
+
"/file"
)
if
err
:=
cmd
.
Start
();
err
!=
nil
{
if
err
:=
cmd
.
Start
();
err
!=
nil
{
...
@@ -74,9 +69,7 @@ func TestInterrupt(t *testing.T) {
...
@@ -74,9 +69,7 @@ func TestInterrupt(t *testing.T) {
if
err
:=
cmd
.
Process
.
Kill
();
err
!=
nil
{
if
err
:=
cmd
.
Process
.
Kill
();
err
!=
nil
{
t
.
Errorf
(
"Kill: %v"
,
err
)
t
.
Errorf
(
"Kill: %v"
,
err
)
}
}
server
.
Unmount
()
clean
()
clean
=
nil
if
!
root
.
child
.
interrupted
{
if
!
root
.
child
.
interrupted
{
t
.
Errorf
(
"open request was not interrupted"
)
t
.
Errorf
(
"open request was not interrupted"
)
...
...
fs/loopback_linux_test.go
View file @
ba08cb01
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
func
TestRenameExchange
(
t
*
testing
.
T
)
{
func
TestRenameExchange
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
if
err
:=
os
.
Mkdir
(
tc
.
origDir
+
"/dir"
,
0755
);
err
!=
nil
{
if
err
:=
os
.
Mkdir
(
tc
.
origDir
+
"/dir"
,
0755
);
err
!=
nil
{
t
.
Fatalf
(
"Mkdir: %v"
,
err
)
t
.
Fatalf
(
"Mkdir: %v"
,
err
)
...
@@ -95,7 +94,6 @@ func TestRenameExchange(t *testing.T) {
...
@@ -95,7 +94,6 @@ func TestRenameExchange(t *testing.T) {
func
TestRenameNoOverwrite
(
t
*
testing
.
T
)
{
func
TestRenameNoOverwrite
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
if
err
:=
os
.
Mkdir
(
tc
.
origDir
+
"/dir"
,
0755
);
err
!=
nil
{
if
err
:=
os
.
Mkdir
(
tc
.
origDir
+
"/dir"
,
0755
);
err
!=
nil
{
t
.
Fatalf
(
"Mkdir: %v"
,
err
)
t
.
Fatalf
(
"Mkdir: %v"
,
err
)
...
@@ -123,7 +121,6 @@ func TestRenameNoOverwrite(t *testing.T) {
...
@@ -123,7 +121,6 @@ func TestRenameNoOverwrite(t *testing.T) {
func
TestXAttr
(
t
*
testing
.
T
)
{
func
TestXAttr
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
tc
.
writeOrig
(
"file"
,
""
,
0644
)
tc
.
writeOrig
(
"file"
,
""
,
0644
)
...
@@ -188,7 +185,6 @@ func TestXAttr(t *testing.T) {
...
@@ -188,7 +185,6 @@ func TestXAttr(t *testing.T) {
// so don't even bother. See `man 7 xattr` for more info.
// so don't even bother. See `man 7 xattr` for more info.
func
TestXAttrSymlink
(
t
*
testing
.
T
)
{
func
TestXAttrSymlink
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
nil
)
tc
:=
newTestCase
(
t
,
nil
)
defer
tc
.
Clean
()
path
:=
tc
.
mntDir
+
"/symlink"
path
:=
tc
.
mntDir
+
"/symlink"
if
err
:=
syscall
.
Symlink
(
"target/does/not/exist"
,
path
);
err
!=
nil
{
if
err
:=
syscall
.
Symlink
(
"target/does/not/exist"
,
path
);
err
!=
nil
{
...
@@ -203,7 +199,6 @@ func TestXAttrSymlink(t *testing.T) {
...
@@ -203,7 +199,6 @@ func TestXAttrSymlink(t *testing.T) {
func
TestCopyFileRange
(
t
*
testing
.
T
)
{
func
TestCopyFileRange
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
if
!
tc
.
server
.
KernelSettings
()
.
SupportsVersion
(
7
,
28
)
{
if
!
tc
.
server
.
KernelSettings
()
.
SupportsVersion
(
7
,
28
)
{
t
.
Skip
(
"need v7.28 for CopyFileRange"
)
t
.
Skip
(
"need v7.28 for CopyFileRange"
)
...
@@ -398,8 +393,7 @@ func TestParallelDiropsHang(t *testing.T) {
...
@@ -398,8 +393,7 @@ func TestParallelDiropsHang(t *testing.T) {
}
}
func
TestRoMount
(
t
*
testing
.
T
)
{
func
TestRoMount
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
ro
:
true
})
newTestCase
(
t
,
&
testOptions
{
ro
:
true
})
defer
tc
.
Clean
()
}
}
func
TestDirectMount
(
t
*
testing
.
T
)
{
func
TestDirectMount
(
t
*
testing
.
T
)
{
...
@@ -410,6 +404,5 @@ func TestDirectMount(t *testing.T) {
...
@@ -410,6 +404,5 @@ func TestDirectMount(t *testing.T) {
t
.
Log
(
"running as root, setting DirectMountStrict"
)
t
.
Log
(
"running as root, setting DirectMountStrict"
)
opts
.
directMountStrict
=
true
opts
.
directMountStrict
=
true
}
}
tc
:=
newTestCase
(
t
,
opts
)
newTestCase
(
t
,
opts
)
defer
tc
.
Clean
()
}
}
fs/maxwrite_test.go
View file @
ba08cb01
...
@@ -152,8 +152,7 @@ func TestMaxWrite(t *testing.T) {
...
@@ -152,8 +152,7 @@ func TestMaxWrite(t *testing.T) {
root
:=
&
maxWriteTestRoot
{}
root
:=
&
maxWriteTestRoot
{}
root
.
resetStats
()
root
.
resetStats
()
mntDir
,
srv
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
MountOptions
:
tc
})
mntDir
,
srv
:=
testMount
(
t
,
root
,
&
Options
{
MountOptions
:
tc
})
defer
clean
()
readAheadWant
:=
tc
.
MaxReadAhead
readAheadWant
:=
tc
.
MaxReadAhead
if
readAheadWant
==
0
{
if
readAheadWant
==
0
{
...
...
fs/mem_test.go
View file @
ba08cb01
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"github.com/hanwen/go-fuse/v2/internal/testutil"
"github.com/hanwen/go-fuse/v2/internal/testutil"
)
)
func
testMount
(
t
*
testing
.
T
,
root
InodeEmbedder
,
opts
*
Options
)
(
string
,
*
fuse
.
Server
,
func
()
)
{
func
testMount
(
t
*
testing
.
T
,
root
InodeEmbedder
,
opts
*
Options
)
(
string
,
*
fuse
.
Server
)
{
t
.
Helper
()
t
.
Helper
()
mntDir
:=
testutil
.
TempDir
()
mntDir
:=
testutil
.
TempDir
()
...
@@ -36,20 +36,21 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.S
...
@@ -36,20 +36,21 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.S
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
return
mntDir
,
server
,
func
()
{
t
.
Cleanup
(
func
()
{
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
{
if
err
:=
syscall
.
Rmdir
(
mntDir
);
err
!=
nil
{
t
.
Errorf
(
"testMount: Remove failed: %v"
,
err
)
t
.
Errorf
(
"testMount: Remove failed: %v"
,
err
)
}
}
}
})
return
mntDir
,
server
}
}
func
TestDefaultOwner
(
t
*
testing
.
T
)
{
func
TestDefaultOwner
(
t
*
testing
.
T
)
{
want
:=
"hello"
want
:=
"hello"
root
:=
&
Inode
{}
root
:=
&
Inode
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
:=
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
n
:=
root
.
EmbeddedInode
()
n
:=
root
.
EmbeddedInode
()
...
@@ -64,7 +65,6 @@ func TestDefaultOwner(t *testing.T) {
...
@@ -64,7 +65,6 @@ func TestDefaultOwner(t *testing.T) {
UID
:
42
,
UID
:
42
,
GID
:
43
,
GID
:
43
,
})
})
defer
clean
()
var
st
syscall
.
Stat_t
var
st
syscall
.
Stat_t
if
err
:=
syscall
.
Lstat
(
mntDir
+
"/file"
,
&
st
);
err
!=
nil
{
if
err
:=
syscall
.
Lstat
(
mntDir
+
"/file"
,
&
st
);
err
!=
nil
{
...
@@ -78,13 +78,12 @@ func TestRootInode(t *testing.T) {
...
@@ -78,13 +78,12 @@ func TestRootInode(t *testing.T) {
var
rootIno
uint64
=
42
var
rootIno
uint64
=
42
root
:=
&
Inode
{}
root
:=
&
Inode
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
:=
testMount
(
t
,
root
,
&
Options
{
RootStableAttr
:
&
StableAttr
{
RootStableAttr
:
&
StableAttr
{
Ino
:
rootIno
,
Ino
:
rootIno
,
Gen
:
1
,
Gen
:
1
,
},
},
})
})
defer
clean
()
var
st
syscall
.
Stat_t
var
st
syscall
.
Stat_t
if
err
:=
syscall
.
Lstat
(
mntDir
,
&
st
);
err
!=
nil
{
if
err
:=
syscall
.
Lstat
(
mntDir
,
&
st
);
err
!=
nil
{
...
@@ -97,7 +96,7 @@ func TestRootInode(t *testing.T) {
...
@@ -97,7 +96,7 @@ func TestRootInode(t *testing.T) {
func
TestDataFile
(
t
*
testing
.
T
)
{
func
TestDataFile
(
t
*
testing
.
T
)
{
want
:=
"hello"
want
:=
"hello"
root
:=
&
Inode
{}
root
:=
&
Inode
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
:=
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
n
:=
root
.
EmbeddedInode
()
n
:=
root
.
EmbeddedInode
()
...
@@ -113,7 +112,6 @@ func TestDataFile(t *testing.T) {
...
@@ -113,7 +112,6 @@ func TestDataFile(t *testing.T) {
n
.
AddChild
(
"file"
,
ch
,
false
)
n
.
AddChild
(
"file"
,
ch
,
false
)
},
},
})
})
defer
clean
()
var
st
syscall
.
Stat_t
var
st
syscall
.
Stat_t
if
err
:=
syscall
.
Lstat
(
mntDir
+
"/file"
,
&
st
);
err
!=
nil
{
if
err
:=
syscall
.
Lstat
(
mntDir
+
"/file"
,
&
st
);
err
!=
nil
{
...
@@ -165,7 +163,7 @@ func TestDataFileLargeRead(t *testing.T) {
...
@@ -165,7 +163,7 @@ func TestDataFileLargeRead(t *testing.T) {
data
:=
make
([]
byte
,
256
*
1024
)
data
:=
make
([]
byte
,
256
*
1024
)
rand
.
Read
(
data
[
:
])
rand
.
Read
(
data
[
:
])
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
:=
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
n
:=
root
.
EmbeddedInode
()
n
:=
root
.
EmbeddedInode
()
...
@@ -181,7 +179,6 @@ func TestDataFileLargeRead(t *testing.T) {
...
@@ -181,7 +179,6 @@ func TestDataFileLargeRead(t *testing.T) {
n
.
AddChild
(
"file"
,
ch
,
false
)
n
.
AddChild
(
"file"
,
ch
,
false
)
},
},
})
})
defer
clean
()
got
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/file"
)
got
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/file"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
...
@@ -208,8 +205,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
...
@@ -208,8 +205,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
func
TestDataSymlink
(
t
*
testing
.
T
)
{
func
TestDataSymlink
(
t
*
testing
.
T
)
{
root
:=
&
SymlinkerRoot
{}
root
:=
&
SymlinkerRoot
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
nil
)
mntDir
,
_
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
if
err
:=
syscall
.
Symlink
(
"target"
,
mntDir
+
"/link"
);
err
!=
nil
{
if
err
:=
syscall
.
Symlink
(
"target"
,
mntDir
+
"/link"
);
err
!=
nil
{
t
.
Fatalf
(
"Symlink: %v"
,
err
)
t
.
Fatalf
(
"Symlink: %v"
,
err
)
...
@@ -227,7 +223,7 @@ func TestReaddirplusParallel(t *testing.T) {
...
@@ -227,7 +223,7 @@ func TestReaddirplusParallel(t *testing.T) {
N
:=
100
N
:=
100
oneSec
:=
time
.
Second
oneSec
:=
time
.
Second
names
:=
map
[
string
]
int64
{}
names
:=
map
[
string
]
int64
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
:=
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
EntryTimeout
:
&
oneSec
,
EntryTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
...
@@ -248,7 +244,6 @@ func TestReaddirplusParallel(t *testing.T) {
...
@@ -248,7 +244,6 @@ func TestReaddirplusParallel(t *testing.T) {
}
}
},
},
})
})
defer
clean
()
read
:=
func
()
(
map
[
string
]
int64
,
error
)
{
read
:=
func
()
(
map
[
string
]
int64
,
error
)
{
es
,
err
:=
os
.
ReadDir
(
mntDir
)
es
,
err
:=
os
.
ReadDir
(
mntDir
)
...
...
fs/randomtype_test.go
View file @
ba08cb01
...
@@ -55,8 +55,7 @@ func (fn *randomTypeTest) Readdir(ctx context.Context) (DirStream, syscall.Errno
...
@@ -55,8 +55,7 @@ func (fn *randomTypeTest) Readdir(ctx context.Context) (DirStream, syscall.Errno
func
TestReaddirTypeFixup
(
t
*
testing
.
T
)
{
func
TestReaddirTypeFixup
(
t
*
testing
.
T
)
{
root
:=
&
randomTypeTest
{}
root
:=
&
randomTypeTest
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
nil
)
mntDir
,
_
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
f
,
err
:=
os
.
Open
(
mntDir
)
f
,
err
:=
os
.
Open
(
mntDir
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
fs/readonly_test.go
View file @
ba08cb01
...
@@ -16,8 +16,7 @@ import (
...
@@ -16,8 +16,7 @@ import (
func
TestReadonlyCreate
(
t
*
testing
.
T
)
{
func
TestReadonlyCreate
(
t
*
testing
.
T
)
{
root
:=
&
Inode
{}
root
:=
&
Inode
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
nil
)
mntDir
,
_
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
_
,
err
:=
syscall
.
Creat
(
mntDir
+
"/test"
,
0644
)
_
,
err
:=
syscall
.
Creat
(
mntDir
+
"/test"
,
0644
)
if
want
:=
syscall
.
EROFS
;
want
!=
err
{
if
want
:=
syscall
.
EROFS
;
want
!=
err
{
...
@@ -28,7 +27,7 @@ func TestReadonlyCreate(t *testing.T) {
...
@@ -28,7 +27,7 @@ func TestReadonlyCreate(t *testing.T) {
func
TestDefaultPermissions
(
t
*
testing
.
T
)
{
func
TestDefaultPermissions
(
t
*
testing
.
T
)
{
root
:=
&
Inode
{}
root
:=
&
Inode
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
:=
testMount
(
t
,
root
,
&
Options
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
dir
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
StableAttr
{
Mode
:
syscall
.
S_IFDIR
})
dir
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
StableAttr
{
Mode
:
syscall
.
S_IFDIR
})
file
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
StableAttr
{
Mode
:
syscall
.
S_IFREG
})
file
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
StableAttr
{
Mode
:
syscall
.
S_IFREG
})
...
@@ -37,7 +36,6 @@ func TestDefaultPermissions(t *testing.T) {
...
@@ -37,7 +36,6 @@ func TestDefaultPermissions(t *testing.T) {
root
.
AddChild
(
"file"
,
file
,
false
)
root
.
AddChild
(
"file"
,
file
,
false
)
},
},
})
})
defer
clean
()
for
k
,
v
:=
range
map
[
string
]
uint32
{
for
k
,
v
:=
range
map
[
string
]
uint32
{
"dir"
:
fuse
.
S_IFDIR
|
0755
,
"dir"
:
fuse
.
S_IFDIR
|
0755
,
...
...
fs/rmchild_test.go
View file @
ba08cb01
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
func
TestRmChildParallel
(
t
*
testing
.
T
)
{
func
TestRmChildParallel
(
t
*
testing
.
T
)
{
want
:=
"hello"
want
:=
"hello"
root
:=
&
Inode
{}
root
:=
&
Inode
{}
_
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
n
:=
root
.
EmbeddedInode
()
n
:=
root
.
EmbeddedInode
()
...
@@ -53,5 +53,4 @@ func TestRmChildParallel(t *testing.T) {
...
@@ -53,5 +53,4 @@ func TestRmChildParallel(t *testing.T) {
wg
.
Wait
()
wg
.
Wait
()
},
},
})
})
defer
clean
()
}
}
fs/simple_test.go
View file @
ba08cb01
...
@@ -46,7 +46,7 @@ func (tc *testCase) writeOrig(path, content string, mode os.FileMode) {
...
@@ -46,7 +46,7 @@ func (tc *testCase) writeOrig(path, content string, mode os.FileMode) {
}
}
}
}
func
(
tc
*
testCase
)
C
lean
()
{
func
(
tc
*
testCase
)
c
lean
()
{
if
err
:=
tc
.
server
.
Unmount
();
err
!=
nil
{
if
err
:=
tc
.
server
.
Unmount
();
err
!=
nil
{
tc
.
Fatal
(
err
)
tc
.
Fatal
(
err
)
}
}
...
@@ -130,12 +130,13 @@ func newTestCase(t *testing.T, opts *testOptions) *testCase {
...
@@ -130,12 +130,13 @@ func newTestCase(t *testing.T, opts *testOptions) *testCase {
if
err
:=
tc
.
server
.
WaitMount
();
err
!=
nil
{
if
err
:=
tc
.
server
.
WaitMount
();
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
t
.
Cleanup
(
tc
.
clean
)
return
tc
return
tc
}
}
func
TestBasic
(
t
*
testing
.
T
)
{
func
TestBasic
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
tc
.
writeOrig
(
"file"
,
"hello"
,
0644
)
tc
.
writeOrig
(
"file"
,
"hello"
,
0644
)
...
@@ -169,15 +170,10 @@ func TestFileFdLeak(t *testing.T) {
...
@@ -169,15 +170,10 @@ func TestFileFdLeak(t *testing.T) {
attrCache
:
true
,
attrCache
:
true
,
entryCache
:
true
,
entryCache
:
true
,
})
})
defer
func
()
{
if
tc
!=
nil
{
tc
.
Clean
()
}
}()
posixtest
.
FdLeak
(
t
,
tc
.
mntDir
)
posixtest
.
FdLeak
(
t
,
tc
.
mntDir
)
tc
.
C
lean
()
tc
.
c
lean
()
bridge
:=
tc
.
rawFS
.
(
*
rawBridge
)
bridge
:=
tc
.
rawFS
.
(
*
rawBridge
)
tc
=
nil
tc
=
nil
...
@@ -188,7 +184,6 @@ func TestFileFdLeak(t *testing.T) {
...
@@ -188,7 +184,6 @@ func TestFileFdLeak(t *testing.T) {
func
TestNotifyEntry
(
t
*
testing
.
T
)
{
func
TestNotifyEntry
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
orig
:=
tc
.
origDir
+
"/file"
orig
:=
tc
.
origDir
+
"/file"
fn
:=
tc
.
mntDir
+
"/file"
fn
:=
tc
.
mntDir
+
"/file"
...
@@ -221,7 +216,6 @@ func TestNotifyEntry(t *testing.T) {
...
@@ -221,7 +216,6 @@ func TestNotifyEntry(t *testing.T) {
func
TestReadDirStress
(
t
*
testing
.
T
)
{
func
TestReadDirStress
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
,
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
,
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
// Create 110 entries
// Create 110 entries
for
i
:=
0
;
i
<
110
;
i
++
{
for
i
:=
0
;
i
<
110
;
i
++
{
...
@@ -262,7 +256,6 @@ func TestReadDirStress(t *testing.T) {
...
@@ -262,7 +256,6 @@ func TestReadDirStress(t *testing.T) {
// runs, we may see spurious differences between the two statfs() calls.
// runs, we may see spurious differences between the two statfs() calls.
func
TestStatFs
(
t
*
testing
.
T
)
{
func
TestStatFs
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
empty
:=
syscall
.
Statfs_t
{}
empty
:=
syscall
.
Statfs_t
{}
orig
:=
empty
orig
:=
empty
...
@@ -290,7 +283,6 @@ func TestGetAttrParallel(t *testing.T) {
...
@@ -290,7 +283,6 @@ func TestGetAttrParallel(t *testing.T) {
// (f)stat in parallel don't lead to fstat on closed files.
// (f)stat in parallel don't lead to fstat on closed files.
// We can only test that if we switch off caching
// We can only test that if we switch off caching
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
})
defer
tc
.
Clean
()
N
:=
100
N
:=
100
...
@@ -331,7 +323,6 @@ func TestGetAttrParallel(t *testing.T) {
...
@@ -331,7 +323,6 @@ func TestGetAttrParallel(t *testing.T) {
func
TestMknod
(
t
*
testing
.
T
)
{
func
TestMknod
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{})
tc
:=
newTestCase
(
t
,
&
testOptions
{})
defer
tc
.
Clean
()
modes
:=
map
[
string
]
uint32
{
modes
:=
map
[
string
]
uint32
{
"regular"
:
syscall
.
S_IFREG
,
"regular"
:
syscall
.
S_IFREG
,
...
@@ -396,7 +387,6 @@ func TestPosix(t *testing.T) {
...
@@ -396,7 +387,6 @@ func TestPosix(t *testing.T) {
entryCache
:
true
,
entryCache
:
true
,
enableLocks
:
true
,
enableLocks
:
true
,
})
})
defer
tc
.
Clean
()
fn
(
t
,
tc
.
mntDir
)
fn
(
t
,
tc
.
mntDir
)
})
})
...
@@ -424,7 +414,6 @@ func TestOpenDirectIO(t *testing.T) {
...
@@ -424,7 +414,6 @@ func TestOpenDirectIO(t *testing.T) {
}
}
tc
:=
newTestCase
(
t
,
&
opts
)
tc
:=
newTestCase
(
t
,
&
opts
)
defer
tc
.
Clean
()
posixtest
.
DirectIO
(
t
,
tc
.
mntDir
)
posixtest
.
DirectIO
(
t
,
tc
.
mntDir
)
}
}
...
@@ -440,7 +429,6 @@ func TestOpenDirectIO(t *testing.T) {
...
@@ -440,7 +429,6 @@ func TestOpenDirectIO(t *testing.T) {
// distributions, and tmpfs does not reuse inode numbers, hiding the problem.
// distributions, and tmpfs does not reuse inode numbers, hiding the problem.
func
TestFsstress
(
t
*
testing
.
T
)
{
func
TestFsstress
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
,
attrCache
:
true
,
entryCache
:
true
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
suppressDebug
:
true
,
attrCache
:
true
,
entryCache
:
true
})
defer
tc
.
Clean
()
{
{
old
:=
runtime
.
GOMAXPROCS
(
100
)
old
:=
runtime
.
GOMAXPROCS
(
100
)
...
@@ -653,7 +641,6 @@ func TestFsstress(t *testing.T) {
...
@@ -653,7 +641,6 @@ func TestFsstress(t *testing.T) {
func
TestStaleHardlinks
(
t
*
testing
.
T
)
{
func
TestStaleHardlinks
(
t
*
testing
.
T
)
{
// Disable all caches we can disable
// Disable all caches we can disable
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
false
,
entryCache
:
false
})
tc
:=
newTestCase
(
t
,
&
testOptions
{
attrCache
:
false
,
entryCache
:
false
})
defer
tc
.
Clean
()
// "link0" is original file
// "link0" is original file
link0
:=
tc
.
mntDir
+
"/link0"
link0
:=
tc
.
mntDir
+
"/link0"
...
...
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