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
d7ac6b93
Commit
d7ac6b93
authored
Jun 28, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse/test: use channel in NotifyTest to obviate ThreadSanitizerSync.
parent
66ff11b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
15 deletions
+37
-15
fuse/test/notify_test.go
fuse/test/notify_test.go
+37
-15
No files found.
fuse/test/notify_test.go
View file @
d7ac6b93
...
@@ -2,7 +2,6 @@ package test
...
@@ -2,7 +2,6 @@ package test
import
(
import
(
"io/ioutil"
"io/ioutil"
"log"
"os"
"os"
"testing"
"testing"
"time"
"time"
...
@@ -12,20 +11,47 @@ import (
...
@@ -12,20 +11,47 @@ import (
"github.com/hanwen/go-fuse/fuse/pathfs"
"github.com/hanwen/go-fuse/fuse/pathfs"
)
)
var
_
=
log
.
Println
type
NotifyFs
struct
{
type
NotifyFs
struct
{
pathfs
.
FileSystem
pathfs
.
FileSystem
size
uint64
size
uint64
exist
bool
exist
bool
sizeChan
chan
uint64
existChan
chan
bool
}
func
newNotifyFs
()
*
NotifyFs
{
return
&
NotifyFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
(),
sizeChan
:
make
(
chan
uint64
,
1
),
existChan
:
make
(
chan
bool
,
1
),
}
}
func
(
fs
*
NotifyFs
)
Exists
()
bool
{
select
{
case
s
:=
<-
fs
.
existChan
:
fs
.
exist
=
s
default
:
}
return
fs
.
exist
}
func
(
fs
*
NotifyFs
)
Size
()
uint64
{
select
{
case
s
:=
<-
fs
.
sizeChan
:
fs
.
size
=
s
default
:
}
return
fs
.
size
}
}
func
(
fs
*
NotifyFs
)
GetAttr
(
name
string
,
context
*
fuse
.
Context
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
func
(
fs
*
NotifyFs
)
GetAttr
(
name
string
,
context
*
fuse
.
Context
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
if
name
==
""
{
if
name
==
""
{
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
0755
},
fuse
.
OK
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
0755
},
fuse
.
OK
}
}
if
name
==
"file"
||
(
name
==
"dir/file"
&&
fs
.
exist
)
{
if
name
==
"file"
||
(
name
==
"dir/file"
&&
fs
.
Exists
()
)
{
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFREG
|
0644
,
Size
:
fs
.
size
},
fuse
.
OK
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFREG
|
0644
,
Size
:
fs
.
Size
()
},
fuse
.
OK
}
}
if
name
==
"dir"
{
if
name
==
"dir"
{
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
0755
},
fuse
.
OK
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
0755
},
fuse
.
OK
...
@@ -47,7 +73,7 @@ type NotifyTest struct {
...
@@ -47,7 +73,7 @@ type NotifyTest struct {
func
NewNotifyTest
(
t
*
testing
.
T
)
*
NotifyTest
{
func
NewNotifyTest
(
t
*
testing
.
T
)
*
NotifyTest
{
me
:=
&
NotifyTest
{}
me
:=
&
NotifyTest
{}
me
.
fs
=
&
NotifyFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
()}
me
.
fs
=
newNotifyFs
()
var
err
error
var
err
error
me
.
dir
,
err
=
ioutil
.
TempDir
(
""
,
"go-fuse-notify_test"
)
me
.
dir
,
err
=
ioutil
.
TempDir
(
""
,
"go-fuse-notify_test"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -85,8 +111,7 @@ func TestInodeNotify(t *testing.T) {
...
@@ -85,8 +111,7 @@ func TestInodeNotify(t *testing.T) {
fs
:=
test
.
fs
fs
:=
test
.
fs
dir
:=
test
.
dir
dir
:=
test
.
dir
fs
.
size
=
42
fs
.
sizeChan
<-
42
test
.
state
.
ThreadSanitizerSync
()
fi
,
err
:=
os
.
Lstat
(
dir
+
"/file"
)
fi
,
err
:=
os
.
Lstat
(
dir
+
"/file"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -96,8 +121,7 @@ func TestInodeNotify(t *testing.T) {
...
@@ -96,8 +121,7 @@ func TestInodeNotify(t *testing.T) {
t
.
Error
(
fi
)
t
.
Error
(
fi
)
}
}
test
.
state
.
ThreadSanitizerSync
()
fs
.
sizeChan
<-
666
fs
.
size
=
666
fi
,
err
=
os
.
Lstat
(
dir
+
"/file"
)
fi
,
err
=
os
.
Lstat
(
dir
+
"/file"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -126,9 +150,8 @@ func TestEntryNotify(t *testing.T) {
...
@@ -126,9 +150,8 @@ func TestEntryNotify(t *testing.T) {
defer
test
.
Clean
()
defer
test
.
Clean
()
dir
:=
test
.
dir
dir
:=
test
.
dir
test
.
fs
.
size
=
42
test
.
fs
.
sizeChan
<-
42
test
.
fs
.
exist
=
false
test
.
fs
.
existChan
<-
false
test
.
state
.
ThreadSanitizerSync
()
fn
:=
dir
+
"/dir/file"
fn
:=
dir
+
"/dir/file"
fi
,
_
:=
os
.
Lstat
(
fn
)
fi
,
_
:=
os
.
Lstat
(
fn
)
...
@@ -136,8 +159,7 @@ func TestEntryNotify(t *testing.T) {
...
@@ -136,8 +159,7 @@ func TestEntryNotify(t *testing.T) {
t
.
Errorf
(
"File should not exist, %#v"
,
fi
)
t
.
Errorf
(
"File should not exist, %#v"
,
fi
)
}
}
test
.
fs
.
exist
=
true
test
.
fs
.
existChan
<-
true
test
.
state
.
ThreadSanitizerSync
()
fi
,
_
=
os
.
Lstat
(
fn
)
fi
,
_
=
os
.
Lstat
(
fn
)
if
fi
!=
nil
{
if
fi
!=
nil
{
t
.
Errorf
(
"negative entry should have been cached: %#v"
,
fi
)
t
.
Errorf
(
"negative entry should have been cached: %#v"
,
fi
)
...
...
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