diff options
author | Jakob Unterwurzacher | 2019-01-06 20:43:24 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-06 20:56:53 +0100 |
commit | 5c8e7feabd61a7db852728c9faee0ed913501b61 (patch) | |
tree | 3910abfb2e087d2f3f1fb1a63b829ba3e597d0d9 /tests | |
parent | c83aa417e4396ea416b831d13e7a370ddbda5cb1 (diff) |
tests: check that fallocate does not over-allocate space
We currently allocate 18 bytes too much:
https://github.com/rfjakob/gocryptfs/issues/311
Diffstat (limited to 'tests')
-rw-r--r-- | tests/matrix/fallocate_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/matrix/fallocate_test.go b/tests/matrix/fallocate_test.go index 6928b4a..dde0685 100644 --- a/tests/matrix/fallocate_test.go +++ b/tests/matrix/fallocate_test.go @@ -148,6 +148,23 @@ func TestFallocate(t *testing.T) { } } } + // We used to allocate 18 bytes too much: + // https://github.com/rfjakob/gocryptfs/issues/311 + // + // 8110 bytes of plaintext should get us exactly 8192 bytes of ciphertext. + err = file.Truncate(0) + if err != nil { + t.Fatal(err) + } + err = syscallcompat.Fallocate(fd, FALLOC_DEFAULT, 0, 8110) + if err != nil { + t.Fatal(err) + } + nBytes = test_helpers.Du(t, fd) + want = 8192 + if nBytes != want { + t.Errorf("Expected %d allocated bytes, have %d", want, nBytes) + } // Cleanup syscall.Unlink(fn) if !wellKnown { |