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:
parent
c83aa417e4
commit
5c8e7feabd
|
@ -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
|
// Cleanup
|
||||||
syscall.Unlink(fn)
|
syscall.Unlink(fn)
|
||||||
if !wellKnown {
|
if !wellKnown {
|
||||||
|
|
Loading…
Reference in New Issue