Chromium Code Reviews| Index: base/allocator/partition_allocator/partition_alloc_unittest.cc |
| diff --git a/base/allocator/partition_allocator/partition_alloc_unittest.cc b/base/allocator/partition_allocator/partition_alloc_unittest.cc |
| index 2ddde105bb4aee707e97750f403c1a017ce5b2c1..1ed26bba972de191589fb5fee45fbeebc599aaec 100644 |
| --- a/base/allocator/partition_allocator/partition_alloc_unittest.cc |
| +++ b/base/allocator/partition_allocator/partition_alloc_unittest.cc |
| @@ -56,6 +56,11 @@ const size_t kTestBucketIndex = kRealAllocSize >> kBucketShift; |
| const char* type_name = nullptr; |
| void TestSetup() { |
| + // Zero the allocator structs to clear out traces |
| + // from previous test. |
| + memset(&allocator, 0, sizeof(allocator)); |
| + memset(&generic_allocator, 0, sizeof(generic_allocator)); |
|
Wez
2017/02/12 18:51:28
This looks highly suspect; why trash the instance'
sof
2017/02/12 20:07:04
The tests use a set of global allocators, which ea
Wez
2017/02/14 00:24:11
Presumably we're assuming that the tests themselve
Wez
2017/02/14 00:42:50
OK, looking through the PartitionRoot init code, i
|
| + |
| allocator.init(); |
| generic_allocator.init(); |
| } |
| @@ -1286,35 +1291,43 @@ static void DoReturnNullTest(size_t allocSize) { |
| EXPECT_TRUE(ClearAddressSpaceLimit()); |
| } |
| -// Tests that if an allocation fails in "return null" mode, repeating it doesn't |
| -// crash, and still returns null. The test tries to allocate 6 GB of memory in |
| -// 512 kB blocks. On 64-bit POSIX systems, the address space is limited to 6 GB |
| -// using setrlimit() first. |
| +// Unit tests that check if an allocation fails in "return null" mode, |
| +// repeating it doesn't crash, and still returns null. The tests need to |
| +// stress memory subsystem limits to do so, hence they try to allocate |
| +// 6 GB of memory, each with a different per-allocation block sizes. |
| // |
| +// On 64-bit POSIX systems, the address space is limited to 6 GB using |
| +// setrlimit() first. |
| + |
| +// Test "return null" for larger, direct-mapped allocations first. As a |
|
Wez
2017/02/12 18:51:28
Tests normally get sharded across all cores, so th
|
| +// direct-mapped allocation's pages are unmapped and freed on release, this |
| +// test is performd first for these "return null" tests in order to leave |
|
Wez
2017/02/12 18:51:28
typo: performed
|
| +// sufficient unreserved virtual memory around for the later one(s). |
| + |
| // Disable this test on Android because, due to its allocation-heavy behavior, |
|
Wez
2017/02/12 18:51:28
Looks like it is also disabled on Mac - same reaso
sof
2017/02/12 19:52:37
I believe so; this was just reordering pre-existin
|
| // it tends to get OOM-killed rather than pass. |
| #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| -#define MAYBE_RepeatedReturnNull DISABLED_RepeatedReturnNull |
| +#define MAYBE_RepeatedReturnNullDirect DISABLED_RepeatedReturnNullDirect |
| #else |
| -#define MAYBE_RepeatedReturnNull RepeatedReturnNull |
| +#define MAYBE_RepeatedReturnNullDirect RepeatedReturnNullDirect |
| #endif |
| -TEST(PartitionAllocTest, MAYBE_RepeatedReturnNull) { |
| - // A single-slot but non-direct-mapped allocation size. |
| - DoReturnNullTest(512 * 1024); |
| +TEST(PartitionAllocTest, MAYBE_RepeatedReturnNullDirect) { |
| + // A direct-mapped allocation size. |
| + DoReturnNullTest(32 * 1024 * 1024); |
| } |
| -// Another "return null" test but for larger, direct-mapped allocations. |
| -// |
| +// Test "return null" with a 512 kB block size. |
|
Wez
2017/02/12 18:51:28
nit: This comment describes what the test *does* n
|
| + |
| // Disable this test on Android because, due to its allocation-heavy behavior, |
| // it tends to get OOM-killed rather than pass. |
| #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| -#define MAYBE_RepeatedReturnNullDirect DISABLED_RepeatedReturnNullDirect |
| +#define MAYBE_RepeatedReturnNull DISABLED_RepeatedReturnNull |
| #else |
| -#define MAYBE_RepeatedReturnNullDirect RepeatedReturnNullDirect |
| +#define MAYBE_RepeatedReturnNull RepeatedReturnNull |
| #endif |
| -TEST(PartitionAllocTest, MAYBE_RepeatedReturnNullDirect) { |
| - // A direct-mapped allocation size. |
| - DoReturnNullTest(32 * 1024 * 1024); |
| +TEST(PartitionAllocTest, MAYBE_RepeatedReturnNull) { |
| + // A single-slot but non-direct-mapped allocation size. |
| + DoReturnNullTest(512 * 1024); |
| } |
| #endif // !defined(ARCH_CPU_64_BITS) || defined(OS_POSIX) |