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
5531575a
Commit
5531575a
authored
Mar 22, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: test NotifyContent
parent
8b325003
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
nodefs/cache_test.go
nodefs/cache_test.go
+22
-7
nodefs/simple_test.go
nodefs/simple_test.go
+0
-3
No files found.
nodefs/cache_test.go
View file @
5531575a
...
@@ -62,28 +62,31 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of
...
@@ -62,28 +62,31 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of
type
keepCacheRoot
struct
{
type
keepCacheRoot
struct
{
DefaultOperations
DefaultOperations
keep
,
nokeep
*
keepCacheFile
}
}
func
(
r
*
keepCacheRoot
)
OnAdd
()
{
func
(
r
*
keepCacheRoot
)
OnAdd
()
{
i
:=
InodeOf
(
r
)
i
:=
InodeOf
(
r
)
f1
:
=
&
keepCacheFile
{
r
.
keep
=
&
keepCacheFile
{
keepCache
:
true
,
keepCache
:
true
,
}
}
f1
.
setContent
(
0
)
r
.
keep
.
setContent
(
0
)
i
.
AddChild
(
"keep"
,
i
.
NewInode
(
f1
,
NodeAttr
{}),
true
)
i
.
AddChild
(
"keep"
,
i
.
NewInode
(
r
.
keep
,
NodeAttr
{}),
true
)
f2
:
=
&
keepCacheFile
{
r
.
nokeep
=
&
keepCacheFile
{
keepCache
:
false
,
keepCache
:
false
,
}
}
f2
.
setContent
(
0
)
r
.
nokeep
.
setContent
(
0
)
i
.
AddChild
(
"nokeep"
,
i
.
NewInode
(
f2
,
NodeAttr
{}),
true
)
i
.
AddChild
(
"nokeep"
,
i
.
NewInode
(
r
.
nokeep
,
NodeAttr
{}),
true
)
}
}
func
TestKeepCache
(
t
*
testing
.
T
)
{
func
TestKeepCache
(
t
*
testing
.
T
)
{
mntDir
:=
testutil
.
TempDir
()
mntDir
:=
testutil
.
TempDir
()
sec
:=
time
.
Second
sec
:=
time
.
Second
rawFS
:=
NewNodeFS
(
&
keepCacheRoot
{},
&
Options
{
root
:=
&
keepCacheRoot
{}
rawFS
:=
NewNodeFS
(
root
,
&
Options
{
Debug
:
testutil
.
VerboseTest
(),
Debug
:
testutil
.
VerboseTest
(),
FirstAutomaticIno
:
1
,
FirstAutomaticIno
:
1
,
...
@@ -118,6 +121,18 @@ func TestKeepCache(t *testing.T) {
...
@@ -118,6 +121,18 @@ func TestKeepCache(t *testing.T) {
t
.
Errorf
(
"keep read 2 got %q want read 1 %q"
,
c2
,
c1
)
t
.
Errorf
(
"keep read 2 got %q want read 1 %q"
,
c2
,
c1
)
}
}
if
s
:=
InodeOf
(
root
.
keep
)
.
NotifyContent
(
0
,
100
);
!
s
.
Ok
()
{
t
.
Errorf
(
"NotifyContent: %v"
,
s
)
}
c3
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/keep"
)
if
err
!=
nil
{
t
.
Fatalf
(
"read keep 3: %v"
,
err
)
}
if
bytes
.
Compare
(
c2
,
c3
)
==
0
{
t
.
Errorf
(
"keep read 3 got %q want different"
,
c3
)
}
nc1
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/nokeep"
)
nc1
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/nokeep"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"read keep 1: %v"
,
err
)
t
.
Fatalf
(
"read keep 1: %v"
,
err
)
...
...
nodefs/simple_test.go
View file @
5531575a
...
@@ -538,9 +538,6 @@ func TestNotifyEntry(t *testing.T) {
...
@@ -538,9 +538,6 @@ func TestNotifyEntry(t *testing.T) {
}
}
}
}
// XXX Test Notify() , but requires KEEP_CACHE ? or could use mmap?
// XXX Test NotifyDelete?
func
TestReadDir
(
t
*
testing
.
T
)
{
func
TestReadDir
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
,
true
,
true
)
tc
:=
newTestCase
(
t
,
true
,
true
)
defer
tc
.
Clean
()
defer
tc
.
Clean
()
...
...
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