From 64cbdfea9a357bb6a8eeb0bef9b1bd3c15cbc4d3 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 9 Sep 2015 21:40:55 +1000 Subject: [PATCH] StatFSTest.WriteSize --- samples/statfs/statfs_test.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/samples/statfs/statfs_test.go b/samples/statfs/statfs_test.go index 05a13f6..704bfe3 100644 --- a/samples/statfs/statfs_test.go +++ b/samples/statfs/statfs_test.go @@ -17,6 +17,7 @@ package statfs_test import ( "bytes" "fmt" + "io/ioutil" "os/exec" "path" "path/filepath" @@ -238,7 +239,29 @@ func (t *StatFSTest) CapacityAndFreeSpace() { } func (t *StatFSTest) WriteSize() { - AssertTrue(false, "TODO") + var err error + + // Set up a smallish block size. + canned := fuseops.StatFSOp{ + BlockSize: 8192, + Blocks: 1234, + BlocksFree: 1234, + BlocksAvailable: 1234, + } + + t.fs.SetStatFSResponse(canned) + + // Cause a large amount of date to be written. + err = ioutil.WriteFile( + path.Join(t.Dir, "foo"), + bytes.Repeat([]byte{'x'}, 1<<22), + 0400) + + AssertEq(nil, err) + + // Despite the small block size, the OS shouldn't have given us pitifully + // small chunks of data. + ExpectEq(1<<20, t.fs.MostRecentWriteSize()) } func (t *StatFSTest) UnsupportedBlockSizes() {