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
f0ae4d75
Commit
f0ae4d75
authored
Mar 24, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recategorized tests.
parent
5dde9ea0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
109 deletions
+105
-109
samples/flushfs/flush_fs_test.go
samples/flushfs/flush_fs_test.go
+105
-109
No files found.
samples/flushfs/flush_fs_test.go
View file @
f0ae4d75
...
...
@@ -119,9 +119,17 @@ func dup2(oldfd int, newfd int) (err error) {
}
////////////////////////////////////////////////////////////////////////
//
Test
s
//
No error
s
////////////////////////////////////////////////////////////////////////
type
NoErrorsTest
struct
{
flushFSTest
}
func
init
()
{
RegisterTestSuite
(
&
NoErrorsTest
{})
}
func
(
t
*
NoErrorsTest
)
SetUp
(
ti
*
TestInfo
)
func
(
t
*
FlushFSTest
)
CloseReports_ReadWrite
()
{
var
n
int
var
off
int64
...
...
@@ -304,24 +312,6 @@ func (t *FlushFSTest) CloseReports_MultipleTimes_OverlappingFileHandles() {
AssertThat
(
t
.
getFsyncs
(),
ElementsAre
())
}
func
(
t
*
FlushFSTest
)
CloseError
()
{
var
err
error
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_RDWR
,
0
)
AssertEq
(
nil
,
err
)
// Configure a flush error.
t
.
setFlushError
(
fuse
.
ENOENT
)
// Close the file.
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
func
(
t
*
FlushFSTest
)
FsyncReports
()
{
var
n
int
var
err
error
...
...
@@ -361,23 +351,6 @@ func (t *FlushFSTest) FsyncReports() {
AssertThat
(
t
.
getFsyncs
(),
ElementsAre
(
"taco"
,
"tacos"
))
}
func
(
t
*
FlushFSTest
)
FsyncError
()
{
var
err
error
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_RDWR
,
0
)
AssertEq
(
nil
,
err
)
// Configure an fsync error.
t
.
setFsyncError
(
fuse
.
ENOENT
)
// Fsync.
err
=
t
.
f1
.
Sync
()
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
func
(
t
*
FlushFSTest
)
Dup
()
{
var
n
int
var
err
error
...
...
@@ -442,45 +415,6 @@ func (t *FlushFSTest) Dup() {
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
}
func
(
t
*
FlushFSTest
)
Dup_FlushError
()
{
var
err
error
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_WRONLY
,
0
)
AssertEq
(
nil
,
err
)
fd1
:=
t
.
f1
.
Fd
()
// Use dup(2) to get another copy.
fd2
,
err
:=
syscall
.
Dup
(
int
(
fd1
))
AssertEq
(
nil
,
err
)
t
.
f2
=
os
.
NewFile
(
uintptr
(
fd2
),
t
.
f1
.
Name
())
// Configure a flush error.
t
.
setFlushError
(
fuse
.
ENOENT
)
// Close by the first handle. On OS X, where the semantics of file handles
// are different (cf. https://github.com/osxfuse/osxfuse/issues/199), this
// does not result in an error.
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
if
runtime
.
GOOS
==
"darwin"
{
AssertEq
(
nil
,
err
)
}
else
{
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
// Close by the second handle.
err
=
t
.
f2
.
Close
()
t
.
f2
=
nil
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
func
(
t
*
FlushFSTest
)
Dup2
()
{
var
n
int
var
err
error
...
...
@@ -510,29 +444,6 @@ func (t *FlushFSTest) Dup2() {
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
}
func
(
t
*
FlushFSTest
)
Dup2_FlushError
()
{
var
err
error
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_WRONLY
,
0
)
AssertEq
(
nil
,
err
)
// Open and unlink some temporary file.
t
.
f2
,
err
=
ioutil
.
TempFile
(
""
,
""
)
AssertEq
(
nil
,
err
)
err
=
os
.
Remove
(
t
.
f2
.
Name
())
AssertEq
(
nil
,
err
)
// Configure a flush error.
t
.
setFlushError
(
fuse
.
ENOENT
)
// Duplicate the temporary file descriptor on top of the file from our file
// system. We shouldn't see the flush error.
err
=
dup2
(
int
(
t
.
f2
.
Fd
()),
int
(
t
.
f1
.
Fd
()))
ExpectEq
(
nil
,
err
)
}
func
(
t
*
FlushFSTest
)
Mmap_MunmapBeforeClose
()
{
var
n
int
var
err
error
...
...
@@ -652,28 +563,96 @@ func (t *FlushFSTest) Directory() {
}
////////////////////////////////////////////////////////////////////////
//
No errors
//
Flush error
////////////////////////////////////////////////////////////////////////
type
NoErrors
Test
struct
{
type
FlushError
Test
struct
{
flushFSTest
}
func
init
()
{
RegisterTestSuite
(
&
NoErrors
Test
{})
}
func
init
()
{
RegisterTestSuite
(
&
FlushError
Test
{})
}
func
(
t
*
NoErrors
Test
)
SetUp
(
ti
*
TestInfo
)
func
(
t
*
FlushError
Test
)
SetUp
(
ti
*
TestInfo
)
////////////////////////////////////////////////////////////////////////
// Flush error
////////////////////////////////////////////////////////////////////////
func
(
t
*
FlushFSTest
)
CloseError
()
{
var
err
error
type
FlushErrorTest
struct
{
flushFSTest
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_RDWR
,
0
)
AssertEq
(
nil
,
err
)
// Configure a flush error.
t
.
setFlushError
(
fuse
.
ENOENT
)
// Close the file.
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
func
init
()
{
RegisterTestSuite
(
&
FlushErrorTest
{})
}
func
(
t
*
FlushFSTest
)
Dup_FlushError
()
{
var
err
error
func
(
t
*
FlushErrorTest
)
SetUp
(
ti
*
TestInfo
)
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_WRONLY
,
0
)
AssertEq
(
nil
,
err
)
fd1
:=
t
.
f1
.
Fd
()
// Use dup(2) to get another copy.
fd2
,
err
:=
syscall
.
Dup
(
int
(
fd1
))
AssertEq
(
nil
,
err
)
t
.
f2
=
os
.
NewFile
(
uintptr
(
fd2
),
t
.
f1
.
Name
())
// Configure a flush error.
t
.
setFlushError
(
fuse
.
ENOENT
)
// Close by the first handle. On OS X, where the semantics of file handles
// are different (cf. https://github.com/osxfuse/osxfuse/issues/199), this
// does not result in an error.
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
if
runtime
.
GOOS
==
"darwin"
{
AssertEq
(
nil
,
err
)
}
else
{
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
// Close by the second handle.
err
=
t
.
f2
.
Close
()
t
.
f2
=
nil
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
func
(
t
*
FlushFSTest
)
Dup2_FlushError
()
{
var
err
error
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_WRONLY
,
0
)
AssertEq
(
nil
,
err
)
// Open and unlink some temporary file.
t
.
f2
,
err
=
ioutil
.
TempFile
(
""
,
""
)
AssertEq
(
nil
,
err
)
err
=
os
.
Remove
(
t
.
f2
.
Name
())
AssertEq
(
nil
,
err
)
// Configure a flush error.
t
.
setFlushError
(
fuse
.
ENOENT
)
// Duplicate the temporary file descriptor on top of the file from our file
// system. We shouldn't see the flush error.
err
=
dup2
(
int
(
t
.
f2
.
Fd
()),
int
(
t
.
f1
.
Fd
()))
ExpectEq
(
nil
,
err
)
}
////////////////////////////////////////////////////////////////////////
// Fsync error
...
...
@@ -686,3 +665,20 @@ type FsyncErrorTest struct {
func
init
()
{
RegisterTestSuite
(
&
FsyncErrorTest
{})
}
func
(
t
*
FsyncErrorTest
)
SetUp
(
ti
*
TestInfo
)
func
(
t
*
FlushFSTest
)
FsyncError
()
{
var
err
error
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_RDWR
,
0
)
AssertEq
(
nil
,
err
)
// Configure an fsync error.
t
.
setFsyncError
(
fuse
.
ENOENT
)
// Fsync.
err
=
t
.
f1
.
Sync
()
AssertNe
(
nil
,
err
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"no such file"
)))
}
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