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
7ec610e0
Commit
7ec610e0
authored
May 21, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PosixTest.SymlinkInParallel
parent
e158bcfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
samples/memfs/posix_test.go
samples/memfs/posix_test.go
+58
-0
No files found.
samples/memfs/posix_test.go
View file @
7ec610e0
...
...
@@ -323,6 +323,60 @@ func runMkdirInParallelTest(
}
}
func
runSymlinkInParallelTest
(
ctx
context
.
Context
,
dir
string
)
{
// Ensure that we get parallelism for this test.
defer
runtime
.
GOMAXPROCS
(
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
()))
// Try for awhile to see if anything breaks.
const
duration
=
500
*
time
.
Millisecond
startTime
:=
time
.
Now
()
for
time
.
Since
(
startTime
)
<
duration
{
filename
:=
path
.
Join
(
dir
,
"foo"
)
// Set up a function that creates the symlink, ignoring EEXIST errors.
worker
:=
func
(
id
byte
)
(
err
error
)
{
err
=
os
.
Symlink
(
"blah"
,
filename
)
if
os
.
IsExist
(
err
)
{
err
=
nil
}
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Worker %d: Symlink: %v"
,
id
,
err
)
return
}
return
}
// Run several workers in parallel.
const
numWorkers
=
16
b
:=
syncutil
.
NewBundle
(
ctx
)
for
i
:=
0
;
i
<
numWorkers
;
i
++
{
id
:=
byte
(
i
)
b
.
Add
(
func
(
ctx
context
.
Context
)
(
err
error
)
{
err
=
worker
(
id
)
return
})
}
err
:=
b
.
Join
()
AssertEq
(
nil
,
err
)
// The symlink should have been created, once.
entries
,
err
:=
fusetesting
.
ReadDirPicky
(
dir
)
AssertEq
(
nil
,
err
)
AssertEq
(
1
,
len
(
entries
))
AssertEq
(
"foo"
,
entries
[
0
]
.
Name
())
// Delete the directory.
err
=
os
.
Remove
(
filename
)
AssertEq
(
nil
,
err
)
}
}
////////////////////////////////////////////////////////////////////////
// Boilerplate
////////////////////////////////////////////////////////////////////////
...
...
@@ -720,3 +774,7 @@ func (t *PosixTest) CreateInParallel_Exclusive() {
func
(
t
*
PosixTest
)
MkdirInParallel
()
{
runMkdirInParallelTest
(
t
.
ctx
,
t
.
dir
)
}
func
(
t
*
PosixTest
)
SymlinkInParallel
()
{
runSymlinkInParallelTest
(
t
.
ctx
,
t
.
dir
)
}
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