Skip to content

Commit

Permalink
cmd/link: accept extra blocks in TestFallocate
Browse files Browse the repository at this point in the history
For #41127

Change-Id: I794a082299c6dce4202223197ece1864bed36810
Reviewed-on: https://go-review.googlesource.com/c/go/+/282555
Trust: Ian Lance Taylor <[email protected]>
Reviewed-by: Austin Clements <[email protected]>
  • Loading branch information
ianlancetaylor committed Jan 8, 2021
1 parent ee4d322 commit cab1202
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cmd/link/internal/ld/fallocate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ func TestFallocate(t *testing.T) {
if got := stat.Size(); got != sz {
t.Errorf("unexpected file size: got %d, want %d", got, sz)
}
if got, want := stat.Sys().(*syscall.Stat_t).Blocks, (sz+511)/512; got != want {
t.Errorf("unexpected disk usage: got %d blocks, want %d", got, want)
// The number of blocks must be enough for the requested size.
// We used to require an exact match, but it appears that
// some file systems allocate a few extra blocks in some cases.
// See issue #41127.
if got, want := stat.Sys().(*syscall.Stat_t).Blocks, (sz+511)/512; got < want {
t.Errorf("unexpected disk usage: got %d blocks, want at least %d", got, want)
}
out.munmap()
}
Expand Down

0 comments on commit cab1202

Please sign in to comment.