summaryrefslogtreecommitdiff
path: root/tests/test_helpers/helpers.go
diff options
context:
space:
mode:
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
+}