Commit 284ddf44 authored by Aaron Jacobs's avatar Aaron Jacobs

MemFSTest.Statfs

parent ee4f4770
......@@ -28,6 +28,12 @@ import (
"github.com/jacobsa/syncutil"
)
// The capacities of the file system, as reported to statfs(2).
const (
Capacity_Bytes = 1 << 50
Capacity_Files = 1 << 30
)
type memFS struct {
fuseutil.NotImplementedFileSystem
......
......@@ -1614,3 +1614,27 @@ func (t *MemFSTest) RenameNonExistentFile() {
err = os.Rename(path.Join(t.Dir, "foo"), path.Join(t.Dir, "bar"))
ExpectThat(err, Error(HasSubstr("no such file")))
}
func (t *MemFSTest) Statfs() {
var err error
var stat syscall.Statfs_t
// Write a few bytes of file content.
const content = "taco"
err = ioutil.WriteFile(path.Join(t.Dir, "foo"), []byte(content), 0400)
AssertEq(nil, err)
// Stat the file system.
err = syscall.Statfs(t.Dir, &stat)
AssertEq(nil, err)
ExpectEq(1, stat.Bsize)
ExpectEq(memfs.Capacity_Bytes, stat.Blocks)
ExpectEq(memfs.Capacity_Bytes-len(content), stat.Bfree)
ExpectEq(stat.Bfree, stat.Bavail)
ExpectEq(memfs.Capacity_Files, stat.Files)
ExpectEq(memfs.Capacity_Files-2, stat.Ffree)
}
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