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
4ec1bc56
Commit
4ec1bc56
authored
Sep 02, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trim loopback tests.
parent
fdf07284
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
48 deletions
+32
-48
fuse/loopback_test.go
fuse/loopback_test.go
+32
-48
No files found.
fuse/loopback_test.go
View file @
4ec1bc56
...
...
@@ -29,10 +29,8 @@ type testCase struct {
mountFile
string
mountSubdir
string
mountSubfile
string
origFile
string
origSubdir
string
origSubfile
string
tester
*
testing
.
T
state
*
MountState
connector
*
FileSystemConnector
...
...
@@ -61,10 +59,8 @@ func NewTestCase(t *testing.T) *testCase {
me
.
mountFile
=
filepath
.
Join
(
me
.
mnt
,
name
)
me
.
mountSubdir
=
filepath
.
Join
(
me
.
mnt
,
subdir
)
me
.
mountSubfile
=
filepath
.
Join
(
me
.
mountSubdir
,
"subfile"
)
me
.
origFile
=
filepath
.
Join
(
me
.
orig
,
name
)
me
.
origSubdir
=
filepath
.
Join
(
me
.
orig
,
subdir
)
me
.
origSubfile
=
filepath
.
Join
(
me
.
origSubdir
,
"subfile"
)
var
pfs
FileSystem
pfs
=
NewLoopbackFileSystem
(
me
.
orig
)
...
...
@@ -102,27 +98,7 @@ func (me *testCase) Cleanup() {
os
.
Remove
(
me
.
tmpDir
)
}
////////////////
// Utilities.
func
(
me
*
testCase
)
makeOrigSubdir
()
{
err
:=
os
.
Mkdir
(
me
.
origSubdir
,
0777
)
CheckSuccess
(
err
)
}
func
(
me
*
testCase
)
removeMountSubdir
()
{
err
:=
os
.
RemoveAll
(
me
.
mountSubdir
)
CheckSuccess
(
err
)
}
func
(
me
*
testCase
)
removeMountFile
()
{
os
.
Remove
(
me
.
mountFile
)
// ignore errors.
}
func
(
me
*
testCase
)
writeOrigFile
()
{
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
}
////////////////
...
...
@@ -142,8 +118,9 @@ func TestTouch(t *testing.T) {
defer
ts
.
Cleanup
()
log
.
Println
(
"testTouch"
)
ts
.
writeOrigFile
()
err
:=
os
.
Chtimes
(
ts
.
mountFile
,
42e9
,
43e9
)
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
err
=
os
.
Chtimes
(
ts
.
mountFile
,
42e9
,
43e9
)
CheckSuccess
(
err
)
fi
,
err
:=
os
.
Lstat
(
ts
.
mountFile
)
CheckSuccess
(
err
)
...
...
@@ -156,10 +133,11 @@ func (me *testCase) TestReadThrough(t *testing.T) {
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
ts
.
writeOrigFile
()
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Testing chmod."
)
err
:
=
os
.
Chmod
(
ts
.
mountFile
,
mode
)
err
=
os
.
Chmod
(
ts
.
mountFile
,
mode
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Testing Lstat."
)
...
...
@@ -190,10 +168,10 @@ func TestRemove(t *testing.T) {
me
:=
NewTestCase
(
t
)
defer
me
.
Cleanup
()
me
.
writeOrigFile
()
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Testing remove."
)
err
:=
os
.
Remove
(
me
.
mountFile
)
err
=
os
.
Remove
(
me
.
mountFile
)
CheckSuccess
(
err
)
_
,
err
=
os
.
Lstat
(
me
.
origFile
)
if
err
==
nil
{
...
...
@@ -255,12 +233,14 @@ func TestLink(t *testing.T) {
defer
me
.
Cleanup
()
t
.
Log
(
"Testing hard links."
)
me
.
writeOrigFile
()
err
:=
os
.
Mkdir
(
me
.
origSubdir
,
0777
)
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
err
=
os
.
Mkdir
(
me
.
origSubdir
,
0777
)
CheckSuccess
(
err
)
// Link.
err
=
os
.
Link
(
me
.
mountFile
,
me
.
mountSubfile
)
mountSubfile
:=
filepath
.
Join
(
me
.
mountSubdir
,
"subfile"
)
err
=
os
.
Link
(
me
.
mountFile
,
mountSubfile
)
CheckSuccess
(
err
)
fi
,
err
:=
os
.
Lstat
(
me
.
origFile
)
...
...
@@ -268,7 +248,7 @@ func TestLink(t *testing.T) {
t
.
Errorf
(
"Expect 2 links: %v"
,
fi
)
}
f
,
err
:=
os
.
Open
(
m
e
.
m
ountSubfile
)
f
,
err
:=
os
.
Open
(
mountSubfile
)
var
buf
[
1024
]
byte
slice
:=
buf
[
:
]
...
...
@@ -286,13 +266,12 @@ func TestSymlink(t *testing.T) {
defer
me
.
Cleanup
()
t
.
Log
(
"testing symlink/readlink."
)
me
.
writeOrigFile
()
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
linkFile
:=
"symlink-file"
orig
:=
"hello.txt"
err
:=
os
.
Symlink
(
orig
,
filepath
.
Join
(
me
.
mnt
,
linkFile
))
defer
os
.
Remove
(
filepath
.
Join
(
me
.
mnt
,
linkFile
))
defer
me
.
removeMountFile
()
err
=
os
.
Symlink
(
orig
,
filepath
.
Join
(
me
.
mnt
,
linkFile
))
CheckSuccess
(
err
)
...
...
@@ -318,10 +297,10 @@ func TestRename(t *testing.T) {
defer
me
.
Cleanup
()
t
.
Log
(
"Testing rename."
)
me
.
writeOrigFile
()
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
sd
:=
me
.
mnt
+
"/testRename"
err
:=
os
.
MkdirAll
(
sd
,
0777
)
defer
os
.
RemoveAll
(
sd
)
err
=
os
.
MkdirAll
(
sd
,
0777
)
subFile
:=
sd
+
"/subfile"
err
=
os
.
Rename
(
me
.
mountFile
,
subFile
)
...
...
@@ -332,7 +311,7 @@ func TestRename(t *testing.T) {
}
f
,
_
=
os
.
Lstat
(
subFile
)
if
f
==
nil
{
t
.
Errorf
(
"destination %v does not exist."
,
me
.
origSubf
ile
)
t
.
Errorf
(
"destination %v does not exist."
,
subF
ile
)
}
}
...
...
@@ -396,8 +375,9 @@ func TestAccess(t *testing.T) {
me
:=
NewTestCase
(
t
)
defer
me
.
Cleanup
()
me
.
writeOrigFile
()
err
:=
os
.
Chmod
(
me
.
origFile
,
0
)
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
err
=
os
.
Chmod
(
me
.
origFile
,
0
)
CheckSuccess
(
err
)
// Ugh - copied from unistd.h
const
W_OK
uint32
=
2
...
...
@@ -434,8 +414,10 @@ func TestReaddir(t *testing.T) {
defer
me
.
Cleanup
()
t
.
Log
(
"Testing readdir."
)
me
.
writeOrigFile
()
me
.
makeOrigSubdir
()
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
err
=
os
.
Mkdir
(
me
.
origSubdir
,
0777
)
CheckSuccess
(
err
)
dir
,
err
:=
os
.
Open
(
me
.
mnt
)
CheckSuccess
(
err
)
...
...
@@ -465,7 +447,8 @@ func TestFSync(t *testing.T) {
defer
me
.
Cleanup
()
t
.
Log
(
"Testing fsync."
)
me
.
writeOrigFile
()
err
:=
ioutil
.
WriteFile
(
me
.
origFile
,
[]
byte
(
contents
),
0700
)
CheckSuccess
(
err
)
f
,
err
:=
os
.
OpenFile
(
me
.
mountFile
,
os
.
O_WRONLY
,
0
)
_
,
err
=
f
.
WriteString
(
"hello there"
)
...
...
@@ -690,3 +673,4 @@ func TestOriginalIsSymlink(t *testing.T) {
_
,
err
=
os
.
Lstat
(
mnt
)
CheckSuccess
(
err
)
}
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