tests: check that fallocate does not over-allocate space

We currently allocate 18 bytes too much:
https://github.com/rfjakob/gocryptfs/issues/311
This commit is contained in:
Jakob Unterwurzacher 2019-01-06 20:43:24 +01:00
parent c83aa417e4
commit 5c8e7feabd

View File

@ -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 {