Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
31e0f8e4
Commit
31e0f8e4
authored
Dec 15, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Plain Diff
Added integration tests for googlecloudplatform/gcsfuse#137.
parents
1dcc6791
6afe951e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
5 deletions
+98
-5
samples/memfs/memfs_test.go
samples/memfs/memfs_test.go
+98
-5
No files found.
samples/memfs/memfs_test.go
View file @
31e0f8e4
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"os"
"os"
"os/user"
"os/user"
"path"
"path"
"runtime"
"strconv"
"strconv"
"syscall"
"syscall"
"testing"
"testing"
...
@@ -87,21 +88,25 @@ func applyUmask(m os.FileMode) os.FileMode {
...
@@ -87,21 +88,25 @@ func applyUmask(m os.FileMode) os.FileMode {
// Boilerplate
// Boilerplate
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
type
M
emFSTest
struct
{
type
m
emFSTest
struct
{
samples
.
SampleTest
samples
.
SampleTest
}
}
func
init
()
{
RegisterTestSuite
(
&
MemFSTest
{})
}
func
(
t
*
memFSTest
)
SetUp
(
ti
*
TestInfo
)
{
func
(
t
*
MemFSTest
)
SetUp
(
ti
*
TestInfo
)
{
t
.
Server
=
memfs
.
NewMemFS
(
currentUid
(),
currentGid
())
t
.
Server
=
memfs
.
NewMemFS
(
currentUid
(),
currentGid
())
t
.
SampleTest
.
SetUp
(
ti
)
t
.
SampleTest
.
SetUp
(
ti
)
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//
Test function
s
//
Basic
s
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
type
MemFSTest
struct
{
memFSTest
}
func
init
()
{
RegisterTestSuite
(
&
MemFSTest
{})
}
func
(
t
*
MemFSTest
)
ContentsOfEmptyFileSystem
()
{
func
(
t
*
MemFSTest
)
ContentsOfEmptyFileSystem
()
{
entries
,
err
:=
fusetesting
.
ReadDirPicky
(
t
.
Dir
)
entries
,
err
:=
fusetesting
.
ReadDirPicky
(
t
.
Dir
)
...
@@ -1614,3 +1619,91 @@ func (t *MemFSTest) RenameNonExistentFile() {
...
@@ -1614,3 +1619,91 @@ func (t *MemFSTest) RenameNonExistentFile() {
err
=
os
.
Rename
(
path
.
Join
(
t
.
Dir
,
"foo"
),
path
.
Join
(
t
.
Dir
,
"bar"
))
err
=
os
.
Rename
(
path
.
Join
(
t
.
Dir
,
"foo"
),
path
.
Join
(
t
.
Dir
,
"bar"
))
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
}
////////////////////////////////////////////////////////////////////////
// Mknod
////////////////////////////////////////////////////////////////////////
type
MknodTest
struct
{
memFSTest
}
func
init
()
{
RegisterTestSuite
(
&
MknodTest
{})
}
func
(
t
*
MknodTest
)
File
()
{
// mknod(2) only works for root on OS X.
if
runtime
.
GOOS
==
"darwin"
{
return
}
var
err
error
p
:=
path
.
Join
(
t
.
Dir
,
"foo"
)
// Create
err
=
syscall
.
Mknod
(
p
,
syscall
.
S_IFREG
|
0642
,
0
)
AssertEq
(
nil
,
err
)
// Stat
fi
,
err
:=
os
.
Stat
(
p
)
AssertEq
(
nil
,
err
)
ExpectEq
(
path
.
Base
(
p
),
fi
.
Name
())
ExpectEq
(
0
,
fi
.
Size
())
ExpectEq
(
os
.
FileMode
(
0642
),
fi
.
Mode
())
// Read
contents
,
err
:=
ioutil
.
ReadFile
(
p
)
AssertEq
(
nil
,
err
)
ExpectEq
(
""
,
string
(
contents
))
}
func
(
t
*
MknodTest
)
Directory
()
{
// mknod(2) only works for root on OS X.
if
runtime
.
GOOS
==
"darwin"
{
return
}
var
err
error
p
:=
path
.
Join
(
t
.
Dir
,
"foo"
)
// Quoth `man 2 mknod`: "Under Linux, this call cannot be used to create
// directories."
err
=
syscall
.
Mknod
(
p
,
syscall
.
S_IFDIR
|
0700
,
0
)
ExpectEq
(
syscall
.
EPERM
,
err
)
}
func
(
t
*
MknodTest
)
AlreadyExists
()
{
// mknod(2) only works for root on OS X.
if
runtime
.
GOOS
==
"darwin"
{
return
}
var
err
error
p
:=
path
.
Join
(
t
.
Dir
,
"foo"
)
// Create (first)
err
=
ioutil
.
WriteFile
(
p
,
[]
byte
(
"taco"
),
0600
)
AssertEq
(
nil
,
err
)
// Create (second)
err
=
syscall
.
Mknod
(
p
,
syscall
.
S_IFREG
|
0600
,
0
)
ExpectEq
(
syscall
.
EEXIST
,
err
)
// Read
contents
,
err
:=
ioutil
.
ReadFile
(
p
)
AssertEq
(
nil
,
err
)
ExpectEq
(
"taco"
,
string
(
contents
))
}
func
(
t
*
MknodTest
)
NonExistentParent
()
{
// mknod(2) only works for root on OS X.
if
runtime
.
GOOS
==
"darwin"
{
return
}
var
err
error
p
:=
path
.
Join
(
t
.
Dir
,
"foo/bar"
)
err
=
syscall
.
Mknod
(
p
,
syscall
.
S_IFREG
|
0600
,
0
)
ExpectEq
(
syscall
.
ENOENT
,
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