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
dddd77b8
Commit
dddd77b8
authored
Mar 29, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: use testMount in tests
parent
f73926e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
43 deletions
+17
-43
nodefs/cache_test.go
nodefs/cache_test.go
+6
-17
nodefs/directio_test.go
nodefs/directio_test.go
+2
-13
nodefs/interrupt_test.go
nodefs/interrupt_test.go
+9
-13
No files found.
nodefs/cache_test.go
View file @
dddd77b8
...
...
@@ -9,13 +9,11 @@ import (
"context"
"fmt"
"io/ioutil"
"os"
"sync"
"syscall"
"testing"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
)
type
keepCacheFile
struct
{
...
...
@@ -27,6 +25,10 @@ type keepCacheFile struct {
count
int
}
var
_
=
(
Reader
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Opener
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Getattrer
)((
*
keepCacheFile
)(
nil
))
func
(
f
*
keepCacheFile
)
setContent
(
delta
int
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
...
...
@@ -61,10 +63,6 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of
return
fuse
.
ReadResultData
(
f
.
content
[
off
:
]),
OK
}
var
_
=
(
Reader
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Opener
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Getattrer
)((
*
keepCacheFile
)(
nil
))
type
keepCacheRoot
struct
{
Inode
...
...
@@ -93,18 +91,9 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
// invalidation triggers if mtime or file size is changed, so only
// change content but no metadata.
func
TestKeepCache
(
t
*
testing
.
T
)
{
mntDir
:=
testutil
.
TempDir
()
defer
os
.
RemoveAll
(
mntDir
)
root
:=
&
keepCacheRoot
{}
server
,
err
:=
Mount
(
mntDir
,
root
,
&
Options
{
MountOptions
:
fuse
.
MountOptions
{
Debug
:
testutil
.
VerboseTest
(),
},
FirstAutomaticIno
:
1
,
// no caching.
})
defer
server
.
Unmount
()
mntDir
,
clean
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
c1
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/keep"
)
if
err
!=
nil
{
t
.
Fatalf
(
"read keep 1: %v"
,
err
)
...
...
nodefs/directio_test.go
View file @
dddd77b8
...
...
@@ -13,7 +13,6 @@ import (
"testing"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
)
type
dioRoot
struct
{
...
...
@@ -55,18 +54,8 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
func
TestDirectIO
(
t
*
testing
.
T
)
{
root
:=
&
dioRoot
{}
mntDir
:=
testutil
.
TempDir
()
defer
os
.
RemoveAll
(
mntDir
)
server
,
err
:=
Mount
(
mntDir
,
root
,
&
Options
{
MountOptions
:
fuse
.
MountOptions
{
Debug
:
testutil
.
VerboseTest
(),
},
FirstAutomaticIno
:
1
,
// no caching.
})
defer
server
.
Unmount
()
mntDir
,
clean
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
f
,
err
:=
os
.
Open
(
mntDir
+
"/file"
)
if
err
!=
nil
{
...
...
nodefs/interrupt_test.go
View file @
dddd77b8
...
...
@@ -6,14 +6,12 @@ package nodefs
import
(
"context"
"os"
"os/exec"
"syscall"
"testing"
"time"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
)
type
interruptRoot
struct
{
...
...
@@ -54,22 +52,18 @@ func (o *interruptOps) Open(ctx context.Context, flags uint32) (FileHandle, uint
// This currently doesn't test functionality, but is useful to investigate how
// INTERRUPT opcodes are handled.
func
TestInterrupt
(
t
*
testing
.
T
)
{
mntDir
:=
testutil
.
TempDir
()
defer
os
.
Remove
(
mntDir
)
root
:=
&
interruptRoot
{}
oneSec
:=
time
.
Second
server
,
err
:=
Mount
(
mntDir
,
root
,
&
Options
{
MountOptions
:
fuse
.
MountOptions
{
Debug
:
testutil
.
VerboseTest
(),
},
mntDir
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
EntryTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
server
.
Unmount
()
defer
func
()
{
if
clean
!=
nil
{
clean
()
}
}()
cmd
:=
exec
.
Command
(
"cat"
,
mntDir
+
"/file"
)
if
err
:=
cmd
.
Start
();
err
!=
nil
{
...
...
@@ -81,7 +75,9 @@ func TestInterrupt(t *testing.T) {
t
.
Errorf
(
"Kill: %v"
,
err
)
}
server
.
Unmount
()
clean
()
clean
=
nil
if
!
root
.
child
.
interrupted
{
t
.
Errorf
(
"open request was not interrupted"
)
}
...
...
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