Commit 8d9962ee authored by Aaron Jacobs's avatar Aaron Jacobs

MemFSTest.Rmdir_OpenedForReading

parent d8905b0d
...@@ -400,5 +400,41 @@ func (t *MemFSTest) Rmdir_ReusesInodeID() { ...@@ -400,5 +400,41 @@ func (t *MemFSTest) Rmdir_ReusesInodeID() {
} }
func (t *MemFSTest) Rmdir_OpenedForReading() { func (t *MemFSTest) Rmdir_OpenedForReading() {
AssertTrue(false, "TODO") var err error
// Create a directory.
err = os.Mkdir(path.Join(t.mfs.Dir(), "dir"), 0700)
AssertEq(nil, err)
// Open the directory for reading.
f, err := os.Open(path.Join(t.mfs.Dir(), "dir"))
defer func() {
if f != nil {
ExpectEq(nil, f.Close())
}
}()
AssertEq(nil, err)
// Remove the directory.
err = os.Remove(path.Join(t.mfs.Dir(), "dir"))
AssertEq(nil, err)
// Create a new directory, with the same name even, and add some contents
// within it.
err = os.MkdirAll(path.Join(t.mfs.Dir(), "foo"), 0700)
AssertEq(nil, err)
err = os.MkdirAll(path.Join(t.mfs.Dir(), "bar"), 0700)
AssertEq(nil, err)
err = os.MkdirAll(path.Join(t.mfs.Dir(), "baz"), 0700)
AssertEq(nil, err)
// Attempt to read from the directory. This should succeed even though it has
// been unlinked, and we shouldn't see any junk from the new directory.
entries, err := f.Readdir(0)
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment