aboutsummaryrefslogtreecommitdiff
path: root/tests/test_helpers/helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-07-02 19:43:57 +0200
committerJakob Unterwurzacher2016-07-02 19:52:09 +0200
commit54470baa23bf98adde69dc1a074c852ea19127d1 (patch)
tree3e9b3d7a4eba83462d1a16f76c4a14fd1c55926d /tests/test_helpers/helpers.go
parent04ad0635159150409252f6901463768008802221 (diff)
fusefrontend: add fallocate support
Mode=0 (default) and mode=1 (keep size) are supported. The patch includes test cases and the whole thing passed xfstests. Fixes https://github.com/rfjakob/gocryptfs/issues/1 .
Diffstat (limited to 'tests/test_helpers/helpers.go')
-rw-r--r--tests/test_helpers/helpers.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index a6c2b7d..02b9fe0 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -283,3 +283,14 @@ func VerifyExistence(path string) bool {
}
return false
}
+
+// Du returns the disk usage of the file "fd" points to, in bytes.
+// Same as "du --block-size=1".
+func Du(t *testing.T, fd int) (nBytes int64, nBlocks int64) {
+ var st syscall.Stat_t
+ err := syscall.Fstat(fd, &st)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return st.Blocks * st.Blksize, st.Blocks
+}