Updated "rmdir while opened for reading" tests for Linux.
commit
bf21976965
|
@ -734,12 +734,16 @@ func (t *MemFSTest) Rmdir_OpenedForReading() {
|
||||||
// https://github.com/bazillion/fuse/issues/66
|
// https://github.com/bazillion/fuse/issues/66
|
||||||
// ExpectEq(0, fi.Sys().(*syscall.Stat_t).Nlink)
|
// ExpectEq(0, fi.Sys().(*syscall.Stat_t).Nlink)
|
||||||
|
|
||||||
// Attempt to read from the directory. This should succeed even though it has
|
// Attempt to read from the directory. This shouldn't see any junk from the
|
||||||
// been unlinked, and we shouldn't see any junk from the new directory.
|
// new directory. It should either succeed with an empty result or should
|
||||||
|
// return ENOENT.
|
||||||
entries, err := f.Readdir(0)
|
entries, err := f.Readdir(0)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
if err != nil {
|
||||||
ExpectThat(entries, ElementsAre())
|
ExpectThat(err, Error(HasSubstr("no such file")))
|
||||||
|
} else {
|
||||||
|
ExpectThat(entries, ElementsAre())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MemFSTest) CaseSensitive() {
|
func (t *MemFSTest) CaseSensitive() {
|
||||||
|
|
|
@ -313,3 +313,51 @@ func (t *PosixTest) HardLinkDirectory() {
|
||||||
ExpectThat(err, Error(HasSubstr("link")))
|
ExpectThat(err, Error(HasSubstr("link")))
|
||||||
ExpectThat(err, Error(HasSubstr("not permitted")))
|
ExpectThat(err, Error(HasSubstr("not permitted")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *PosixTest) RmdirWhileOpenedForReading() {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Create a directory.
|
||||||
|
err = os.Mkdir(path.Join(t.dir, "dir"), 0700)
|
||||||
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
// Open the directory for reading.
|
||||||
|
f, err := os.Open(path.Join(t.dir, "dir"))
|
||||||
|
defer func() {
|
||||||
|
if f != nil {
|
||||||
|
ExpectEq(nil, f.Close())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
// Remove the directory.
|
||||||
|
err = os.Remove(path.Join(t.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.dir, "dir/foo"), 0700)
|
||||||
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
err = os.MkdirAll(path.Join(t.dir, "dir/bar"), 0700)
|
||||||
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
err = os.MkdirAll(path.Join(t.dir, "dir/baz"), 0700)
|
||||||
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
// We should still be able to stat the open file handle.
|
||||||
|
fi, err := f.Stat()
|
||||||
|
ExpectEq("dir", fi.Name())
|
||||||
|
|
||||||
|
// Attempt to read from the directory. This shouldn't see any junk from the
|
||||||
|
// new directory. It should either succeed with an empty result or should
|
||||||
|
// return ENOENT.
|
||||||
|
entries, err := f.Readdir(0)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
ExpectThat(err, Error(HasSubstr("no such file")))
|
||||||
|
} else {
|
||||||
|
ExpectThat(entries, ElementsAre())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue