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
df6feb98
Commit
df6feb98
authored
Mar 06, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MemFSTest.ReadDirWhileModifying
parent
b53eac30
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
1 deletion
+55
-1
samples/memfs/memfs_test.go
samples/memfs/memfs_test.go
+55
-1
No files found.
samples/memfs/memfs_test.go
View file @
df6feb98
...
@@ -1089,5 +1089,59 @@ func (t *MemFSTest) Chtimes() {
...
@@ -1089,5 +1089,59 @@ func (t *MemFSTest) Chtimes() {
}
}
func
(
t
*
MemFSTest
)
ReadDirWhileModifying
()
{
func
(
t
*
MemFSTest
)
ReadDirWhileModifying
()
{
AssertTrue
(
false
,
"TODO"
)
dirName
:=
path
.
Join
(
t
.
mfs
.
Dir
(),
"dir"
)
createFile
:=
func
(
name
string
)
{
AssertEq
(
nil
,
ioutil
.
WriteFile
(
path
.
Join
(
dirName
,
name
),
[]
byte
{},
0400
))
}
// Create a directory.
err
:=
os
.
Mkdir
(
dirName
,
0700
)
AssertEq
(
nil
,
err
)
// Open the directory.
d
,
err
:=
os
.
Open
(
dirName
)
t
.
toClose
=
append
(
t
.
toClose
,
d
)
AssertEq
(
nil
,
err
)
// Add four files.
createFile
(
"foo"
)
createFile
(
"bar"
)
createFile
(
"baz"
)
createFile
(
"qux"
)
// Read one entry from the directory.
names
,
err
:=
d
.
Readdirnames
(
1
)
AssertEq
(
nil
,
err
)
AssertThat
(
names
,
ElementsAre
(
"foo"
))
// Make two holes in the directory.
AssertEq
(
nil
,
os
.
Remove
(
path
.
Join
(
dirName
,
"foo"
)))
AssertEq
(
nil
,
os
.
Remove
(
path
.
Join
(
dirName
,
"baz"
)))
// Add a bunch of files to the directory.
createFile
(
"blah_0"
)
createFile
(
"blah_1"
)
createFile
(
"blah_2"
)
createFile
(
"blah_3"
)
createFile
(
"blah_4"
)
// Continue reading from the directory, noting the names we see.
namesSeen
:=
make
(
map
[
string
]
bool
)
for
{
names
,
err
=
d
.
Readdirnames
(
1
)
for
_
,
n
:=
range
names
{
namesSeen
[
n
]
=
true
}
if
err
==
io
.
EOF
{
break
}
AssertEq
(
nil
,
err
)
}
// Posix requires that we should have seen bar and qux, which we didn't
// delete.
ExpectTrue
(
namesSeen
[
"bar"
])
ExpectTrue
(
namesSeen
[
"qux"
])
}
}
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