Fix block overhead estimation in tests
authorNicholas Ormrod <njormrod@fb.com>
Fri, 22 Aug 2014 17:07:25 +0000 (10:07 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Sep 2014 21:22:23 +0000 (14:22 -0700)
commitcec3fa895b00598fc2f2c60f7591bf5969ef7fd3
treee1d8060bc3b4ff7bf0452969258079c9c5829325
parent5899b4ed30afe2355024ba08ca316545928272d6
Fix block overhead estimation in tests

Summary:
folly/test/ArenaTest.h assumes that goodMallocSize will account
for the block overhead, if the size is +1. However, when compiling
without jemalloc (as, I would imagine, most of our open-source clients
do), goodMallocSize(64 + 1) returns 65, which is less than 64 +
sizeof(Block), and so the tests fail.

I have added a constant to Arena.h which exposes the overhead taken by
the Block, and changed the tests to use that value instead of 1.
(Arena::getTotalSize relies on the totalAllocatedSize_ variable, which
is only non-trivially set in allocateSlow, where the size of the heap is
added to sizeof(Block)).

Test Plan: fbconfig --allocator=malloc folly/test:arena_test && fbmake runtests

Reviewed By: jon.coens@fb.com

Subscribers: sdwilsh, njormrod

FB internal diff: D1512231
folly/Arena.h
folly/test/ArenaTest.cpp