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 (
...
@@ -9,13 +9,11 @@ import (
"context"
"context"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"sync"
"sync"
"syscall"
"syscall"
"testing"
"testing"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
)
)
type
keepCacheFile
struct
{
type
keepCacheFile
struct
{
...
@@ -27,6 +25,10 @@ type keepCacheFile struct {
...
@@ -27,6 +25,10 @@ type keepCacheFile struct {
count
int
count
int
}
}
var
_
=
(
Reader
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Opener
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Getattrer
)((
*
keepCacheFile
)(
nil
))
func
(
f
*
keepCacheFile
)
setContent
(
delta
int
)
{
func
(
f
*
keepCacheFile
)
setContent
(
delta
int
)
{
f
.
mu
.
Lock
()
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
defer
f
.
mu
.
Unlock
()
...
@@ -61,10 +63,6 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of
...
@@ -61,10 +63,6 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of
return
fuse
.
ReadResultData
(
f
.
content
[
off
:
]),
OK
return
fuse
.
ReadResultData
(
f
.
content
[
off
:
]),
OK
}
}
var
_
=
(
Reader
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Opener
)((
*
keepCacheFile
)(
nil
))
var
_
=
(
Getattrer
)((
*
keepCacheFile
)(
nil
))
type
keepCacheRoot
struct
{
type
keepCacheRoot
struct
{
Inode
Inode
...
@@ -93,18 +91,9 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
...
@@ -93,18 +91,9 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
// invalidation triggers if mtime or file size is changed, so only
// invalidation triggers if mtime or file size is changed, so only
// change content but no metadata.
// change content but no metadata.
func
TestKeepCache
(
t
*
testing
.
T
)
{
func
TestKeepCache
(
t
*
testing
.
T
)
{
mntDir
:=
testutil
.
TempDir
()
defer
os
.
RemoveAll
(
mntDir
)
root
:=
&
keepCacheRoot
{}
root
:=
&
keepCacheRoot
{}
server
,
err
:=
Mount
(
mntDir
,
root
,
&
Options
{
mntDir
,
clean
:=
testMount
(
t
,
root
,
nil
)
MountOptions
:
fuse
.
MountOptions
{
defer
clean
()
Debug
:
testutil
.
VerboseTest
(),
},
FirstAutomaticIno
:
1
,
// no caching.
})
defer
server
.
Unmount
()
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
)
...
...
nodefs/directio_test.go
View file @
dddd77b8
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"testing"
"testing"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
)
)
type
dioRoot
struct
{
type
dioRoot
struct
{
...
@@ -55,18 +54,8 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
...
@@ -55,18 +54,8 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
func
TestDirectIO
(
t
*
testing
.
T
)
{
func
TestDirectIO
(
t
*
testing
.
T
)
{
root
:=
&
dioRoot
{}
root
:=
&
dioRoot
{}
mntDir
:=
testutil
.
TempDir
()
mntDir
,
clean
:=
testMount
(
t
,
root
,
nil
)
defer
clean
()
defer
os
.
RemoveAll
(
mntDir
)
server
,
err
:=
Mount
(
mntDir
,
root
,
&
Options
{
MountOptions
:
fuse
.
MountOptions
{
Debug
:
testutil
.
VerboseTest
(),
},
FirstAutomaticIno
:
1
,
// no caching.
})
defer
server
.
Unmount
()
f
,
err
:=
os
.
Open
(
mntDir
+
"/file"
)
f
,
err
:=
os
.
Open
(
mntDir
+
"/file"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
nodefs/interrupt_test.go
View file @
dddd77b8
...
@@ -6,14 +6,12 @@ package nodefs
...
@@ -6,14 +6,12 @@ package nodefs
import
(
import
(
"context"
"context"
"os"
"os/exec"
"os/exec"
"syscall"
"syscall"
"testing"
"testing"
"time"
"time"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
)
)
type
interruptRoot
struct
{
type
interruptRoot
struct
{
...
@@ -54,22 +52,18 @@ func (o *interruptOps) Open(ctx context.Context, flags uint32) (FileHandle, uint
...
@@ -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
// This currently doesn't test functionality, but is useful to investigate how
// INTERRUPT opcodes are handled.
// INTERRUPT opcodes are handled.
func
TestInterrupt
(
t
*
testing
.
T
)
{
func
TestInterrupt
(
t
*
testing
.
T
)
{
mntDir
:=
testutil
.
TempDir
()
defer
os
.
Remove
(
mntDir
)
root
:=
&
interruptRoot
{}
root
:=
&
interruptRoot
{}
oneSec
:=
time
.
Second
oneSec
:=
time
.
Second
server
,
err
:=
Mount
(
mntDir
,
root
,
&
Options
{
mntDir
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
MountOptions
:
fuse
.
MountOptions
{
Debug
:
testutil
.
VerboseTest
(),
},
EntryTimeout
:
&
oneSec
,
EntryTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
AttrTimeout
:
&
oneSec
,
})
})
if
err
!=
nil
{
defer
func
()
{
t
.
Fatal
(
err
)
if
clean
!=
nil
{
}
clean
()
defer
server
.
Unmount
()
}
}()
cmd
:=
exec
.
Command
(
"cat"
,
mntDir
+
"/file"
)
cmd
:=
exec
.
Command
(
"cat"
,
mntDir
+
"/file"
)
if
err
:=
cmd
.
Start
();
err
!=
nil
{
if
err
:=
cmd
.
Start
();
err
!=
nil
{
...
@@ -81,7 +75,9 @@ func TestInterrupt(t *testing.T) {
...
@@ -81,7 +75,9 @@ func TestInterrupt(t *testing.T) {
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"
)
}
}
...
...
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