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
92f7e9a7
Commit
92f7e9a7
authored
Dec 28, 2010
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test chunked reads and writes.
parent
464d6053
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
3 deletions
+133
-3
fuse/passthrough.go
fuse/passthrough.go
+4
-2
fuse/passthrough_test.go
fuse/passthrough_test.go
+129
-1
No files found.
fuse/passthrough.go
View file @
92f7e9a7
...
...
@@ -187,9 +187,11 @@ func (self *PassThroughFile) Fsync(*FsyncIn) (code Status) {
func
(
self
*
PassThroughFile
)
ReadDir
(
input
*
ReadIn
)
(
*
DEntryList
,
Status
)
{
list
:=
new
(
DEntryList
)
// TODO -
should we try to accomodate
the requested Size?
// TODO -
How to try accomodating
the requested Size?
// (typically: 4096.)
fis
,
err
:=
self
.
file
.
Readdir
(
-
1
)
// To test chunked reads, just return fetch 20 at a time.
fis
,
err
:=
self
.
file
.
Readdir
(
20
)
if
err
!=
nil
{
return
nil
,
OsErrorToFuseError
(
err
)
}
...
...
fuse/passthrough_test.go
View file @
92f7e9a7
package
fuse
import
(
"bytes"
"fmt"
"log"
"os"
...
...
@@ -429,6 +430,132 @@ func (self *testCase) testFSync() {
f
.
Close
()
}
func
(
self
*
testCase
)
testLargeRead
()
{
name
:=
path
.
Join
(
self
.
origDir
,
"large"
)
f
,
err
:=
os
.
Open
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"open write err %v"
,
err
)
}
b
:=
bytes
.
NewBuffer
(
nil
)
for
i
:=
0
;
i
<
20
*
1024
;
i
++
{
b
.
WriteString
(
"bla"
)
}
b
.
WriteString
(
"something extra to not be round"
)
slice
:=
b
.
Bytes
()
fmt
.
Println
(
"len : "
,
len
(
slice
))
n
,
err
:=
f
.
Write
(
slice
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"write err %v %v"
,
err
,
n
)
}
err
=
f
.
Close
()
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"close err %v"
,
err
)
}
// Read in one go.
g
,
err
:=
os
.
Open
(
path
.
Join
(
self
.
mountPoint
,
"large"
),
os
.
O_RDONLY
,
0
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"open err %v"
,
err
)
}
readSlice
:=
make
([]
byte
,
len
(
slice
))
m
,
err
:=
g
.
Read
(
readSlice
)
if
m
!=
n
{
self
.
tester
.
Errorf
(
"read mismatch %v %v"
,
m
,
n
)
}
for
i
,
v
:=
range
(
readSlice
)
{
if
(
slice
[
i
]
!=
v
)
{
self
.
tester
.
Errorf
(
"char mismatch %v %v %v"
,
i
,
slice
[
i
],
v
)
break
}
}
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"read mismatch %v"
,
err
)
}
g
.
Close
()
// Read in chunks
g
,
err
=
os
.
Open
(
path
.
Join
(
self
.
mountPoint
,
"large"
),
os
.
O_RDONLY
,
0
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"open err %v"
,
err
)
}
readSlice
=
make
([]
byte
,
4096
)
total
:=
0
for
{
m
,
err
:=
g
.
Read
(
readSlice
)
if
m
==
0
&&
err
==
os
.
EOF
{
break
}
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"read err %v %v"
,
err
,
m
)
break
}
total
+=
m
}
if
total
!=
len
(
slice
)
{
self
.
tester
.
Errorf
(
"slice error %d"
,
total
)
}
g
.
Close
()
os
.
Remove
(
name
)
}
func
(
self
*
testCase
)
testLargeDirRead
()
{
count
:=
100
names
:=
make
([]
string
,
count
)
subdir
:=
path
.
Join
(
self
.
origDir
,
"readdirSubdir"
)
os
.
Mkdir
(
subdir
,
0700
)
for
i
:=
0
;
i
<
count
;
i
++
{
// Should vary file name length.
name
:=
path
.
Join
(
subdir
,
fmt
.
Sprintf
(
"file%d"
,
i
))
f
,
err
:=
os
.
Open
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"open write err %v"
,
err
)
break
}
f
.
WriteString
(
"bla"
)
f
.
Close
()
names
[
i
]
=
name
}
dir
,
err
:=
os
.
Open
(
path
.
Join
(
self
.
mountPoint
,
"readdirSubdir"
),
os
.
O_RDONLY
,
0
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"dirread %v"
,
err
)
}
// Chunked read.
total
:=
0
for
{
namesRead
,
err
:=
dir
.
Readdirnames
(
20
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"readdir err %v %v"
,
err
,
namesRead
)
}
if
len
(
namesRead
)
==
0
{
break
}
total
+=
len
(
namesRead
)
}
if
total
!=
count
{
self
.
tester
.
Errorf
(
"readdir mismatch %v %v"
,
total
,
count
)
}
dir
.
Close
()
os
.
RemoveAll
(
subdir
)
}
// Test driver.
func
TestMount
(
t
*
testing
.
T
)
{
...
...
@@ -446,6 +573,7 @@ func TestMount(t *testing.T) {
ts
.
testMknod
()
ts
.
testReaddir
()
ts
.
testFSync
()
ts
.
testLargeRead
()
ts
.
testLargeDirRead
()
ts
.
Cleanup
()
}
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