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
a0d210e5
Commit
a0d210e5
authored
Mar 24, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated msync tests after setting MS_SYNC.
parent
80c46259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
samples/flushfs/flush_fs_test.go
samples/flushfs/flush_fs_test.go
+27
-13
No files found.
samples/flushfs/flush_fs_test.go
View file @
a0d210e5
...
...
@@ -110,6 +110,8 @@ func (t *flushFSTest) TearDown() {
// Helpers
////////////////////////////////////////////////////////////////////////
var
isDarwin
=
runtime
.
GOOS
==
"darwin"
func
readReports
(
f
*
os
.
File
)
(
reports
[]
string
,
err
error
)
{
// Seek the file to the start.
_
,
err
=
f
.
Seek
(
0
,
0
)
...
...
@@ -476,7 +478,6 @@ func (t *NoErrorsTest) Dup() {
var
n
int
var
err
error
isDarwin
:=
runtime
.
GOOS
==
"darwin"
var
expectedFlushes
[]
interface
{}
// Open the file.
...
...
@@ -601,7 +602,7 @@ func (t *NoErrorsTest) Mmap_NoMsync_MunmapBeforeClose() {
t
.
f1
=
nil
AssertEq
(
nil
,
err
)
if
runtime
.
GOOS
==
"darwin"
{
if
isDarwin
{
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
(
"taco"
))
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
}
else
{
...
...
@@ -656,6 +657,8 @@ func (t *NoErrorsTest) Mmap_WithMsync_MunmapBeforeClose() {
var
n
int
var
err
error
var
expectedFsyncs
[]
interface
{}
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_RDWR
,
0
)
AssertEq
(
nil
,
err
)
...
...
@@ -677,35 +680,41 @@ func (t *NoErrorsTest) Mmap_WithMsync_MunmapBeforeClose() {
// Modify the contents.
data
[
0
]
=
'p'
// msync. This causes a write, but not a flush.
// msync. This causes an fsync, except on OS X (cf.
// https://github.com/osxfuse/osxfuse/issues/202).
err
=
msync
(
data
)
ExpectEq
(
nil
,
err
)
if
!
isDarwin
{
expectedFsyncs
=
append
(
expectedFsyncs
,
"paco"
)
}
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
(
expectedFsyncs
...
))
// Unmap.
Again, this does not cause a flush
.
// Unmap.
This does not cause anything
.
err
=
syscall
.
Munmap
(
data
)
AssertEq
(
nil
,
err
)
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
(
expectedFsyncs
...
))
// Close the file. We should now see a flush with the modified contents, even
// on OS X, which works differently from Linux with regard to flushing dirty
// pages (cf. https://github.com/osxfuse/osxfuse/issues/202).
// on OS X.
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
AssertEq
(
nil
,
err
)
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
(
"paco"
))
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
(
expectedFsyncs
...
))
}
func
(
t
*
NoErrorsTest
)
Mmap_WithMsync_CloseBeforeMunmap
()
{
var
n
int
var
err
error
var
expectedFsyncs
[]
interface
{}
// Open the file.
t
.
f1
,
err
=
os
.
OpenFile
(
path
.
Join
(
t
.
Dir
,
"foo"
),
os
.
O_RDWR
,
0
)
AssertEq
(
nil
,
err
)
...
...
@@ -735,19 +744,24 @@ func (t *NoErrorsTest) Mmap_WithMsync_CloseBeforeMunmap() {
// Modify the contents.
data
[
0
]
=
'p'
// msync. This causes a write, but not a flush.
// msync. This causes an fsync, except on OS X (cf.
// https://github.com/osxfuse/osxfuse/issues/202).
err
=
msync
(
data
)
ExpectEq
(
nil
,
err
)
if
!
isDarwin
{
expectedFsyncs
=
append
(
expectedFsyncs
,
"paco"
)
}
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
(
"taco"
))
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
(
expectedFsyncs
...
))
// Unmap. Again, this does not cause a flush.
err
=
syscall
.
Munmap
(
data
)
AssertEq
(
nil
,
err
)
ExpectThat
(
t
.
getFlushes
(),
ElementsAre
(
"taco"
))
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
())
ExpectThat
(
t
.
getFsyncs
(),
ElementsAre
(
expectedFsyncs
...
))
}
func
(
t
*
NoErrorsTest
)
Directory
()
{
...
...
@@ -826,7 +840,7 @@ func (t *FlushErrorTest) Dup() {
err
=
t
.
f1
.
Close
()
t
.
f1
=
nil
if
runtime
.
GOOS
==
"darwin"
{
if
isDarwin
{
AssertEq
(
nil
,
err
)
}
else
{
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