Added tests for the Nlink field.
parent
651984dc1a
commit
147be0630d
|
@ -160,6 +160,7 @@ func (t *MemFSTest) Mkdir_OneLevel() {
|
||||||
ExpectEq(0, fi.ModTime().Sub(createTime))
|
ExpectEq(0, fi.ModTime().Sub(createTime))
|
||||||
ExpectTrue(fi.IsDir())
|
ExpectTrue(fi.IsDir())
|
||||||
|
|
||||||
|
ExpectNe(0, stat.Ino)
|
||||||
ExpectEq(1, stat.Nlink)
|
ExpectEq(1, stat.Nlink)
|
||||||
ExpectEq(currentUid(), stat.Uid)
|
ExpectEq(currentUid(), stat.Uid)
|
||||||
ExpectEq(currentGid(), stat.Gid)
|
ExpectEq(currentGid(), stat.Gid)
|
||||||
|
@ -214,6 +215,7 @@ func (t *MemFSTest) Mkdir_TwoLevels() {
|
||||||
ExpectEq(0, fi.ModTime().Sub(createTime))
|
ExpectEq(0, fi.ModTime().Sub(createTime))
|
||||||
ExpectTrue(fi.IsDir())
|
ExpectTrue(fi.IsDir())
|
||||||
|
|
||||||
|
ExpectNe(0, stat.Ino)
|
||||||
ExpectEq(1, stat.Nlink)
|
ExpectEq(1, stat.Nlink)
|
||||||
ExpectEq(currentUid(), stat.Uid)
|
ExpectEq(currentUid(), stat.Uid)
|
||||||
ExpectEq(currentGid(), stat.Gid)
|
ExpectEq(currentGid(), stat.Gid)
|
||||||
|
@ -403,9 +405,13 @@ func (t *MemFSTest) Rmdir_OpenedForReading() {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Create a directory.
|
// Create a directory.
|
||||||
|
createTime := t.clock.Now()
|
||||||
err = os.Mkdir(path.Join(t.mfs.Dir(), "dir"), 0700)
|
err = os.Mkdir(path.Join(t.mfs.Dir(), "dir"), 0700)
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
// Simulate time advancing.
|
||||||
|
t.clock.AdvanceTime(time.Second)
|
||||||
|
|
||||||
// Open the directory for reading.
|
// Open the directory for reading.
|
||||||
f, err := os.Open(path.Join(t.mfs.Dir(), "dir"))
|
f, err := os.Open(path.Join(t.mfs.Dir(), "dir"))
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -431,6 +437,14 @@ func (t *MemFSTest) Rmdir_OpenedForReading() {
|
||||||
err = os.MkdirAll(path.Join(t.mfs.Dir(), "dir/baz"), 0700)
|
err = os.MkdirAll(path.Join(t.mfs.Dir(), "dir/baz"), 0700)
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
// We should still be able to stat the open file handle. It should show up as
|
||||||
|
// unlinked.
|
||||||
|
fi, err := f.Stat()
|
||||||
|
|
||||||
|
ExpectEq("dir", fi.Name())
|
||||||
|
ExpectEq(0, fi.ModTime().Sub(createTime))
|
||||||
|
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 should succeed even though it has
|
||||||
// been unlinked, and we shouldn't see any junk from the new directory.
|
// been unlinked, and we shouldn't see any junk from the new directory.
|
||||||
entries, err := f.Readdir(0)
|
entries, err := f.Readdir(0)
|
||||||
|
|
Loading…
Reference in New Issue