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
437ab542
Commit
437ab542
authored
Sep 25, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use testing.Log for test progress messages.
parent
ab5078a6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
16 additions
and
29 deletions
+16
-29
fuse/defaultnode.go
fuse/defaultnode.go
+0
-1
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+3
-6
fuse/handle_test.go
fuse/handle_test.go
+2
-2
fuse/latencymap_test.go
fuse/latencymap_test.go
+0
-1
fuse/loopback_test.go
fuse/loopback_test.go
+1
-8
fuse/memnode.go
fuse/memnode.go
+0
-1
fuse/memnode_test.go
fuse/memnode_test.go
+0
-1
fuse/mount_test.go
fuse/mount_test.go
+5
-6
fuse/xattr_test.go
fuse/xattr_test.go
+5
-3
No files found.
fuse/defaultnode.go
View file @
437ab542
...
@@ -104,7 +104,6 @@ func (me *DefaultFsNode) OpenDir(context *Context) (chan DirEntry, Status) {
...
@@ -104,7 +104,6 @@ func (me *DefaultFsNode) OpenDir(context *Context) (chan DirEntry, Status) {
for
name
,
child
:=
range
ch
{
for
name
,
child
:=
range
ch
{
fi
,
code
:=
child
.
FsNode
()
.
GetAttr
(
nil
,
context
)
fi
,
code
:=
child
.
FsNode
()
.
GetAttr
(
nil
,
context
)
if
code
.
Ok
()
{
if
code
.
Ok
()
{
log
.
Printf
(
"mode %o"
,
fi
.
Mode
)
s
<-
DirEntry
{
Name
:
name
,
Mode
:
fi
.
Mode
}
s
<-
DirEntry
{
Name
:
name
,
Mode
:
fi
.
Mode
}
}
}
}
}
...
...
fuse/fsetattr_test.go
View file @
437ab542
package
fuse
package
fuse
import
(
import
(
"fmt"
"io/ioutil"
"io/ioutil"
"log"
"os"
"os"
"syscall"
"syscall"
"testing"
"testing"
...
@@ -121,7 +119,7 @@ func NewFile() *MutableDataFile {
...
@@ -121,7 +119,7 @@ func NewFile() *MutableDataFile {
return
&
MutableDataFile
{}
return
&
MutableDataFile
{}
}
}
func
setupFAttrTest
(
fs
FileSystem
)
(
dir
string
,
clean
func
())
{
func
setupFAttrTest
(
t
*
testing
.
T
,
fs
FileSystem
)
(
dir
string
,
clean
func
())
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
state
,
_
,
err
:=
MountPathFileSystem
(
dir
,
fs
,
nil
)
state
,
_
,
err
:=
MountPathFileSystem
(
dir
,
fs
,
nil
)
...
@@ -133,7 +131,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
...
@@ -133,7 +131,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
// Trigger INIT.
// Trigger INIT.
os
.
Lstat
(
dir
)
os
.
Lstat
(
dir
)
if
state
.
KernelSettings
()
.
Flags
&
CAP_FILE_OPS
==
0
{
if
state
.
KernelSettings
()
.
Flags
&
CAP_FILE_OPS
==
0
{
log
.
Println
(
"Mount does not support file operations"
)
t
.
Log
(
"Mount does not support file operations"
)
}
}
return
dir
,
func
()
{
return
dir
,
func
()
{
...
@@ -145,7 +143,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
...
@@ -145,7 +143,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
func
TestFSetAttr
(
t
*
testing
.
T
)
{
func
TestFSetAttr
(
t
*
testing
.
T
)
{
fs
:=
&
FSetAttrFs
{}
fs
:=
&
FSetAttrFs
{}
dir
,
clean
:=
setupFAttrTest
(
fs
)
dir
,
clean
:=
setupFAttrTest
(
t
,
fs
)
defer
clean
()
defer
clean
()
fn
:=
dir
+
"/file"
fn
:=
dir
+
"/file"
...
@@ -159,7 +157,6 @@ func TestFSetAttr(t *testing.T) {
...
@@ -159,7 +157,6 @@ func TestFSetAttr(t *testing.T) {
_
,
err
=
f
.
WriteString
(
"hello"
)
_
,
err
=
f
.
WriteString
(
"hello"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Ftruncate"
)
code
:=
syscall
.
Ftruncate
(
f
.
Fd
(),
3
)
code
:=
syscall
.
Ftruncate
(
f
.
Fd
(),
3
)
if
code
!=
0
{
if
code
!=
0
{
t
.
Error
(
"truncate retval"
,
os
.
NewSyscallError
(
"Ftruncate"
,
code
))
t
.
Error
(
"truncate retval"
,
os
.
NewSyscallError
(
"Ftruncate"
,
code
))
...
...
fuse/handle_test.go
View file @
437ab542
...
@@ -23,7 +23,7 @@ func TestHandleMapDoubleRegister(t *testing.T) {
...
@@ -23,7 +23,7 @@ func TestHandleMapDoubleRegister(t *testing.T) {
t
.
Log
(
"skipping test for 32 bits"
)
t
.
Log
(
"skipping test for 32 bits"
)
return
return
}
}
log
.
Println
(
"TestDoubleRegister"
)
t
.
Log
(
"TestDoubleRegister"
)
defer
markSeen
(
"already has a handle"
)
defer
markSeen
(
"already has a handle"
)
hm
:=
NewHandleMap
(
false
)
hm
:=
NewHandleMap
(
false
)
obj
:=
&
Handled
{}
obj
:=
&
Handled
{}
...
@@ -69,7 +69,7 @@ func TestHandleMapBasic(t *testing.T) {
...
@@ -69,7 +69,7 @@ func TestHandleMapBasic(t *testing.T) {
v
:=
new
(
Handled
)
v
:=
new
(
Handled
)
hm
:=
NewHandleMap
(
portable
)
hm
:=
NewHandleMap
(
portable
)
h
:=
hm
.
Register
(
v
,
v
)
h
:=
hm
.
Register
(
v
,
v
)
log
.
Print
f
(
"Got handle 0x%x"
,
h
)
t
.
Log
f
(
"Got handle 0x%x"
,
h
)
if
!
hm
.
Has
(
h
)
{
if
!
hm
.
Has
(
h
)
{
t
.
Fatal
(
"Does not have handle"
)
t
.
Fatal
(
"Does not have handle"
)
}
}
...
...
fuse/latencymap_test.go
View file @
437ab542
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
var
_
=
fmt
.
Println
var
_
=
fmt
.
Println
func
TestLatencyMap
(
t
*
testing
.
T
)
{
func
TestLatencyMap
(
t
*
testing
.
T
)
{
fmt
.
Println
(
"TestLatencyMap"
)
m
:=
NewLatencyMap
()
m
:=
NewLatencyMap
()
m
.
Add
(
"foo"
,
""
,
0.1e9
)
m
.
Add
(
"foo"
,
""
,
0.1e9
)
m
.
Add
(
"foo"
,
""
,
0.2e9
)
m
.
Add
(
"foo"
,
""
,
0.2e9
)
...
...
fuse/loopback_test.go
View file @
437ab542
...
@@ -120,7 +120,6 @@ func TestTouch(t *testing.T) {
...
@@ -120,7 +120,6 @@ func TestTouch(t *testing.T) {
ts
:=
NewTestCase
(
t
)
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
defer
ts
.
Cleanup
()
log
.
Println
(
"testTouch"
)
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
contents
),
0700
)
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
err
=
os
.
Chtimes
(
ts
.
mountFile
,
42e9
,
43e9
)
err
=
os
.
Chtimes
(
ts
.
mountFile
,
42e9
,
43e9
)
...
@@ -139,11 +138,9 @@ func (me *testCase) TestReadThrough(t *testing.T) {
...
@@ -139,11 +138,9 @@ func (me *testCase) TestReadThrough(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
contents
),
0700
)
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Testing chmod."
)
err
=
os
.
Chmod
(
ts
.
mountFile
,
mode
)
err
=
os
.
Chmod
(
ts
.
mountFile
,
mode
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Testing Lstat."
)
fi
,
err
:=
os
.
Lstat
(
ts
.
mountFile
)
fi
,
err
:=
os
.
Lstat
(
ts
.
mountFile
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
if
(
fi
.
Mode
&
0777
)
!=
mode
{
if
(
fi
.
Mode
&
0777
)
!=
mode
{
...
@@ -151,12 +148,10 @@ func (me *testCase) TestReadThrough(t *testing.T) {
...
@@ -151,12 +148,10 @@ func (me *testCase) TestReadThrough(t *testing.T) {
}
}
// Open (for read), read.
// Open (for read), read.
fmt
.
Println
(
"Testing open."
)
f
,
err
:=
os
.
Open
(
ts
.
mountFile
)
f
,
err
:=
os
.
Open
(
ts
.
mountFile
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
defer
f
.
Close
()
defer
f
.
Close
()
fmt
.
Println
(
"Testing read."
)
var
buf
[
1024
]
byte
var
buf
[
1024
]
byte
slice
:=
buf
[
:
]
slice
:=
buf
[
:
]
n
,
err
:=
f
.
Read
(
slice
)
n
,
err
:=
f
.
Read
(
slice
)
...
@@ -164,7 +159,6 @@ func (me *testCase) TestReadThrough(t *testing.T) {
...
@@ -164,7 +159,6 @@ func (me *testCase) TestReadThrough(t *testing.T) {
if
len
(
slice
[
:
n
])
!=
len
(
contents
)
{
if
len
(
slice
[
:
n
])
!=
len
(
contents
)
{
t
.
Errorf
(
"Content error %v"
,
slice
)
t
.
Errorf
(
"Content error %v"
,
slice
)
}
}
fmt
.
Println
(
"Testing close."
)
}
}
func
TestRemove
(
t
*
testing
.
T
)
{
func
TestRemove
(
t
*
testing
.
T
)
{
...
@@ -676,8 +670,7 @@ func TestIoctl(t *testing.T) {
...
@@ -676,8 +670,7 @@ func TestIoctl(t *testing.T) {
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
defer
f
.
Close
()
defer
f
.
Close
()
CheckSuccess
(
err
)
CheckSuccess
(
err
)
v
,
e
:=
ioctl
(
f
.
Fd
(),
0x5401
,
42
)
ioctl
(
f
.
Fd
(),
0x5401
,
42
)
fmt
.
Println
(
"ioctl"
,
v
,
e
)
}
}
// This test is racy. If an external process consumes space while this
// This test is racy. If an external process consumes space while this
...
...
fuse/memnode.go
View file @
437ab542
...
@@ -142,7 +142,6 @@ func (me *memNodeFile) Flush() Status {
...
@@ -142,7 +142,6 @@ func (me *memNodeFile) Flush() Status {
fi
,
_
:=
me
.
LoopbackFile
.
GetAttr
()
fi
,
_
:=
me
.
LoopbackFile
.
GetAttr
()
me
.
node
.
info
.
Size
=
fi
.
Size
me
.
node
.
info
.
Size
=
fi
.
Size
me
.
node
.
info
.
Blocks
=
fi
.
Blocks
me
.
node
.
info
.
Blocks
=
fi
.
Blocks
log
.
Println
(
"reset size"
,
me
.
node
.
info
.
Size
,
me
.
node
.
Inode
()
.
nodeId
)
return
code
return
code
}
}
...
...
fuse/memnode_test.go
View file @
437ab542
...
@@ -54,7 +54,6 @@ func TestMemNodeFs(t *testing.T) {
...
@@ -54,7 +54,6 @@ func TestMemNodeFs(t *testing.T) {
}
}
entries
,
err
:=
ioutil
.
ReadDir
(
wd
)
entries
,
err
:=
ioutil
.
ReadDir
(
wd
)
log
.
Println
(
entries
)
if
len
(
entries
)
!=
1
||
entries
[
0
]
.
Name
!=
"test"
{
if
len
(
entries
)
!=
1
||
entries
[
0
]
.
Name
!=
"test"
{
t
.
Fatalf
(
"Readdir got %v, expected 1 file named 'test'"
,
entries
)
t
.
Fatalf
(
"Readdir got %v, expected 1 file named 'test'"
,
entries
)
}
}
...
...
fuse/mount_test.go
View file @
437ab542
package
fuse
package
fuse
import
(
import
(
"log"
"os"
"os"
"testing"
"testing"
"time"
"time"
...
@@ -86,7 +85,7 @@ func TestRecursiveMount(t *testing.T) {
...
@@ -86,7 +85,7 @@ func TestRecursiveMount(t *testing.T) {
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
CheckSuccess
(
err
)
CheckSuccess
(
err
)
log
.
Println
(
"Attempting unmount, should fail"
)
t
.
Log
(
"Attempting unmount, should fail"
)
code
=
ts
.
pathFs
.
Unmount
(
"mnt"
)
code
=
ts
.
pathFs
.
Unmount
(
"mnt"
)
if
code
!=
EBUSY
{
if
code
!=
EBUSY
{
t
.
Error
(
"expect EBUSY"
)
t
.
Error
(
"expect EBUSY"
)
...
@@ -94,10 +93,10 @@ func TestRecursiveMount(t *testing.T) {
...
@@ -94,10 +93,10 @@ func TestRecursiveMount(t *testing.T) {
f
.
Close
()
f
.
Close
()
log
.
Println
(
"Waiting for kernel to flush file-close to fuse..."
)
t
.
Log
(
"Waiting for kernel to flush file-close to fuse..."
)
time
.
Sleep
(
1.5e9
*
testTtl
)
time
.
Sleep
(
1.5e9
*
testTtl
)
log
.
Println
(
"Attempting unmount, should succeed"
)
t
.
Log
(
"Attempting unmount, should succeed"
)
code
=
ts
.
pathFs
.
Unmount
(
"mnt"
)
code
=
ts
.
pathFs
.
Unmount
(
"mnt"
)
if
code
!=
OK
{
if
code
!=
OK
{
t
.
Error
(
"umount failed."
,
code
)
t
.
Error
(
"umount failed."
,
code
)
...
@@ -117,11 +116,11 @@ func TestDeletedUnmount(t *testing.T) {
...
@@ -117,11 +116,11 @@ func TestDeletedUnmount(t *testing.T) {
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
CheckSuccess
(
err
)
CheckSuccess
(
err
)
log
.
Println
(
"Removing"
)
t
.
Log
(
"Removing"
)
err
=
os
.
Remove
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
err
=
os
.
Remove
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
CheckSuccess
(
err
)
CheckSuccess
(
err
)
log
.
Println
(
"Removing"
)
t
.
Log
(
"Removing"
)
_
,
err
=
f
.
Write
([]
byte
(
"bla"
))
_
,
err
=
f
.
Write
([]
byte
(
"bla"
))
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
...
fuse/xattr_test.go
View file @
437ab542
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
var
_
=
log
.
Print
var
_
=
log
.
Print
type
XAttrTestFs
struct
{
type
XAttrTestFs
struct
{
tester
*
testing
.
T
filename
string
filename
string
attrs
map
[
string
][]
byte
attrs
map
[
string
][]
byte
...
@@ -39,7 +40,7 @@ func (me *XAttrTestFs) GetAttr(name string, context *Context) (*os.FileInfo, Sta
...
@@ -39,7 +40,7 @@ func (me *XAttrTestFs) GetAttr(name string, context *Context) (*os.FileInfo, Sta
}
}
func
(
me
*
XAttrTestFs
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
,
context
*
Context
)
Status
{
func
(
me
*
XAttrTestFs
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
,
context
*
Context
)
Status
{
log
.
Println
(
"SetXAttr"
,
name
,
attr
,
string
(
data
),
flags
)
me
.
tester
.
Log
(
"SetXAttr"
,
name
,
attr
,
string
(
data
),
flags
)
if
name
!=
me
.
filename
{
if
name
!=
me
.
filename
{
return
ENOENT
return
ENOENT
}
}
...
@@ -57,7 +58,7 @@ func (me *XAttrTestFs) GetXAttr(name string, attr string, context *Context) ([]b
...
@@ -57,7 +58,7 @@ func (me *XAttrTestFs) GetXAttr(name string, attr string, context *Context) ([]b
if
!
ok
{
if
!
ok
{
return
nil
,
ENODATA
return
nil
,
ENODATA
}
}
log
.
Println
(
"GetXAttr"
,
string
(
v
))
me
.
tester
.
Log
(
"GetXAttr"
,
string
(
v
))
return
v
,
OK
return
v
,
OK
}
}
...
@@ -77,7 +78,7 @@ func (me *XAttrTestFs) RemoveXAttr(name string, attr string, context *Context) S
...
@@ -77,7 +78,7 @@ func (me *XAttrTestFs) RemoveXAttr(name string, attr string, context *Context) S
return
ENOENT
return
ENOENT
}
}
_
,
ok
:=
me
.
attrs
[
attr
]
_
,
ok
:=
me
.
attrs
[
attr
]
log
.
Println
(
"RemoveXAttr"
,
name
,
attr
,
ok
)
me
.
tester
.
Log
(
"RemoveXAttr"
,
name
,
attr
,
ok
)
if
!
ok
{
if
!
ok
{
return
ENODATA
return
ENODATA
}
}
...
@@ -92,6 +93,7 @@ func TestXAttrRead(t *testing.T) {
...
@@ -92,6 +93,7 @@ func TestXAttrRead(t *testing.T) {
"user.attr1"
:
[]
byte
(
"val1"
),
"user.attr1"
:
[]
byte
(
"val1"
),
"user.attr2"
:
[]
byte
(
"val2"
)}
"user.attr2"
:
[]
byte
(
"val2"
)}
xfs
:=
NewXAttrFs
(
nm
,
golden
)
xfs
:=
NewXAttrFs
(
nm
,
golden
)
xfs
.
tester
=
t
mountPoint
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
mountPoint
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
defer
os
.
RemoveAll
(
mountPoint
)
defer
os
.
RemoveAll
(
mountPoint
)
...
...
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