Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: base/allocator/partition_allocator/partition_alloc_unittest.cc

Issue 2689103002: Fix partition_alloc unit tests. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/allocator/partition_allocator/PartitionAlloc.md ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « base/allocator/partition_allocator/PartitionAlloc.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698