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
fe14fa8f
Commit
fe14fa8f
authored
May 04, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started InterruptFSTest.InterruptedDuringRead.
parent
d862e4b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
samples/interruptfs/interrupt_fs_test.go
samples/interruptfs/interrupt_fs_test.go
+42
-0
No files found.
samples/interruptfs/interrupt_fs_test.go
View file @
fe14fa8f
...
...
@@ -16,8 +16,11 @@ package interruptfs_test
import
(
"os"
"os/exec"
"path"
"sync"
"testing"
"time"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/fuse/samples"
...
...
@@ -68,5 +71,44 @@ func (t *InterruptFSTest) StatFoo() {
}
func
(
t
*
InterruptFSTest
)
InterruptedDuringRead
()
{
// Start a sub-process that attempts to read the file. Wait for it in the
// background.
cmd
:=
exec
.
Command
(
"cat"
,
path
.
Join
(
t
.
Dir
,
"foo"
))
var
cmdOutput
[]
byte
var
cmdErr
error
var
mu
sync
.
Mutex
cmdFinished
:=
false
cmdFinishedChanged
:=
sync
.
NewCond
(
&
mu
)
go
func
()
{
cmdOutput
,
cmdErr
=
cmd
.
CombinedOutput
()
mu
.
Lock
()
cmdFinished
=
true
cmdFinishedChanged
.
Broadcast
()
mu
.
Unlock
()
}()
// Wait for the read to make it to the file system.
t
.
fs
.
WaitForReadInFlight
()
// Wait another moment. The command should still be hanging.
time
.
Sleep
(
100
*
time
.
Millisecond
)
func
()
{
mu
.
Lock
()
defer
mu
.
Unlock
()
AssertFalse
(
cmdFinished
)
}()
// Send SIGINT.
cmd
.
Process
.
Signal
(
os
.
Interrupt
)
// Now the command should return, with an appropriate error.
mu
.
Lock
()
for
!
cmdFinished
{
cmdFinishedChanged
.
Wait
()
}
mu
.
Unlock
()
AssertTrue
(
false
,
"TODO"
)
}
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