From 55d02a11bfc5e4f2af4b6ba4838e61599aa45813 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 9 Sep 2015 16:12:12 +1000 Subject: [PATCH] StatFSTest.Syscall_NonZeroValues --- samples/statfs/statfs_test.go | 40 ++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/samples/statfs/statfs_test.go b/samples/statfs/statfs_test.go index 9914e7c..f6533b1 100644 --- a/samples/statfs/statfs_test.go +++ b/samples/statfs/statfs_test.go @@ -20,6 +20,7 @@ import ( "syscall" "testing" + "github.com/jacobsa/fuse/fuseops" "github.com/jacobsa/fuse/fuseutil" "github.com/jacobsa/fuse/samples" "github.com/jacobsa/fuse/samples/statfs" @@ -109,7 +110,44 @@ func (t *StatFSTest) Syscall_ZeroValues() { } func (t *StatFSTest) Syscall_NonZeroValues() { - AssertTrue(false, "TODO") + var err error + var stat syscall.Statfs_t + + // Set up the canned response. + canned := fuseops.StatFSOp{ + BlockSize: 1 << 15, + + Blocks: 1<<51 + 3, + BlocksFree: 1<<43 + 5, + BlocksAvailable: 1<<41 + 7, + + Inodes: 1<<59 + 11, + InodesFree: 1<<58 + 13, + } + + t.fs.SetStatFSResponse(canned) + + // Compute the canonicalized directory, for use below. + canonicalDir, err := filepath.EvalSymlinks(t.Dir) + AssertEq(nil, err) + canonicalDir = path.Clean(canonicalDir) + + // Stat. + err = syscall.Statfs(t.Dir, &stat) + AssertEq(nil, err) + + ExpectEq(4096, stat.Bsize) // OS X seems to always make this 4096. + ExpectEq(canned.BlockSize, stat.Iosize) + ExpectEq(canned.Blocks, stat.Blocks) + ExpectEq(canned.BlocksFree, stat.Bfree) + ExpectEq(canned.BlocksAvailable, stat.Bavail) + ExpectEq(canned.Inodes, stat.Files) + ExpectEq(canned.InodesFree, stat.Ffree) + ExpectEq("osxfusefs", convertName(stat.Fstypename[:])) + ExpectEq(canonicalDir, convertName(stat.Mntonname[:])) + ExpectThat( + convertName(stat.Mntfromname[:]), + MatchesRegexp(`mount_osxfusefs@osxfuse\d+`)) } func (t *StatFSTest) CapacityAndFreeSpace() {