Index: base/trace_event/process_memory_dump_unittest.cc |
diff --git a/base/trace_event/process_memory_dump_unittest.cc b/base/trace_event/process_memory_dump_unittest.cc |
index 88984abd34d6fa8813c877e08d6bd9e489eeff9b..986b8c83b9f04974aedd02e4fa6fea6ab7835ca5 100644 |
--- a/base/trace_event/process_memory_dump_unittest.cc |
+++ b/base/trace_event/process_memory_dump_unittest.cc |
@@ -30,8 +30,11 @@ TEST(ProcessMemoryDumpTest, Clear) { |
pmd1->AddOwnershipEdge(MemoryAllocatorDumpGuid(42), |
MemoryAllocatorDumpGuid(4242)); |
- MemoryAllocatorDumpGuid shared_mad_guid(1); |
- pmd1->CreateSharedGlobalAllocatorDump(shared_mad_guid); |
+ MemoryAllocatorDumpGuid shared_mad_guid1(1); |
+ MemoryAllocatorDumpGuid shared_mad_guid2(2); |
+ pmd1->CreateSharedGlobalAllocatorDump(shared_mad_guid1); |
+ pmd1->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid2); |
petrcermak
2016/01/18 17:18:12
Weak -> Strong transition is already checked by yo
ssid
2016/01/19 11:48:34
Done.
|
+ pmd1->CreateSharedGlobalAllocatorDump(shared_mad_guid2); |
pmd1->Clear(); |
ASSERT_TRUE(pmd1->allocator_dumps().empty()); |
@@ -41,7 +44,8 @@ TEST(ProcessMemoryDumpTest, Clear) { |
ASSERT_FALSE(pmd1->has_process_totals()); |
ASSERT_FALSE(pmd1->has_process_mmaps()); |
ASSERT_TRUE(pmd1->process_mmaps()->vm_regions().empty()); |
- ASSERT_EQ(nullptr, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid)); |
+ ASSERT_EQ(nullptr, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid1)); |
+ ASSERT_EQ(nullptr, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid2)); |
// Check that calling AsValueInto() doesn't cause a crash. |
scoped_refptr<TracedValue> traced_value(new TracedValue()); |
@@ -50,12 +54,16 @@ TEST(ProcessMemoryDumpTest, Clear) { |
// Check that the pmd can be reused and behaves as expected. |
auto mad1 = pmd1->CreateAllocatorDump("mad1"); |
auto mad3 = pmd1->CreateAllocatorDump("mad3"); |
- auto shared_mad = pmd1->CreateSharedGlobalAllocatorDump(shared_mad_guid); |
- ASSERT_EQ(3u, pmd1->allocator_dumps().size()); |
+ auto shared_mad1 = pmd1->CreateSharedGlobalAllocatorDump(shared_mad_guid1); |
+ auto shared_mad2 = |
+ pmd1->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid2); |
+ ASSERT_EQ(4u, pmd1->allocator_dumps().size()); |
ASSERT_EQ(mad1, pmd1->GetAllocatorDump("mad1")); |
ASSERT_EQ(nullptr, pmd1->GetAllocatorDump("mad2")); |
ASSERT_EQ(mad3, pmd1->GetAllocatorDump("mad3")); |
- ASSERT_EQ(shared_mad, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid)); |
+ ASSERT_EQ(shared_mad1, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid1)); |
+ ASSERT_EQ(shared_mad2, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid2)); |
+ ASSERT_TRUE(MemoryAllocatorDump::Flag::WEAK & shared_mad2->flags()); |
petrcermak
2016/01/18 17:18:12
To be honest, you could probably check ASSERT_EQ(M
ssid
2016/01/19 11:48:34
Done.
|
traced_value = new TracedValue(); |
pmd1->AsValueInto(traced_value.get()); |
@@ -76,8 +84,11 @@ TEST(ProcessMemoryDumpTest, TakeAllDumpsFrom) { |
auto mad2_2 = pmd2->CreateAllocatorDump("pmd2/mad2"); |
pmd1->AddOwnershipEdge(mad2_1->guid(), mad2_2->guid()); |
- MemoryAllocatorDumpGuid shared_mad_guid(1); |
- auto shared_mad = pmd2->CreateSharedGlobalAllocatorDump(shared_mad_guid); |
+ MemoryAllocatorDumpGuid shared_mad_guid1(1); |
+ MemoryAllocatorDumpGuid shared_mad_guid2(2); |
+ auto shared_mad1 = pmd2->CreateSharedGlobalAllocatorDump(shared_mad_guid1); |
+ auto shared_mad2 = |
+ pmd2->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid2); |
pmd1->TakeAllDumpsFrom(pmd2.get()); |
@@ -98,13 +109,15 @@ TEST(ProcessMemoryDumpTest, TakeAllDumpsFrom) { |
pmd2.reset(); |
// Now check that |pmd1| has been effectively merged. |
- ASSERT_EQ(5u, pmd1->allocator_dumps().size()); |
+ ASSERT_EQ(6u, pmd1->allocator_dumps().size()); |
ASSERT_EQ(1u, pmd1->allocator_dumps().count("pmd1/mad1")); |
ASSERT_EQ(1u, pmd1->allocator_dumps().count("pmd1/mad2")); |
ASSERT_EQ(1u, pmd1->allocator_dumps().count("pmd2/mad1")); |
ASSERT_EQ(1u, pmd1->allocator_dumps().count("pmd1/mad2")); |
ASSERT_EQ(2u, pmd1->allocator_dumps_edges().size()); |
- ASSERT_EQ(shared_mad, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid)); |
+ ASSERT_EQ(shared_mad1, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid1)); |
+ ASSERT_EQ(shared_mad2, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid2)); |
+ ASSERT_TRUE(MemoryAllocatorDump::Flag::WEAK & shared_mad2->flags()); |
// Check that calling AsValueInto() doesn't cause a crash. |
traced_value = new TracedValue(); |
@@ -157,6 +170,28 @@ TEST(ProcessMemoryDumpTest, Suballocations) { |
pmd.reset(); |
} |
+TEST(ProcessMemoryDumpTest, CreateGlobalDumpTest) { |
+ scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr)); |
+ MemoryAllocatorDumpGuid shared_mad_guid(1); |
+ auto shared_mad1 = pmd->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid); |
+ ASSERT_TRUE(MemoryAllocatorDump::Flag::WEAK & shared_mad1->flags()); |
petrcermak
2016/01/18 17:18:12
super-nit: I suggest you put this check after line
ssid
2016/01/19 11:48:34
Done.
|
+ ASSERT_EQ(shared_mad_guid, shared_mad1->guid()); |
+ auto shared_mad2 = pmd->GetSharedGlobalAllocatorDump(shared_mad_guid); |
petrcermak
2016/01/18 17:18:12
I'd put a blank line above this line (so that each
ssid
2016/01/19 11:48:34
Done.
|
+ ASSERT_EQ(shared_mad1, shared_mad2); |
petrcermak
2016/01/18 17:18:12
nit: I'd add ASSERT_TRUE after this line as well.
ssid
2016/01/19 11:48:34
Done.
|
+ |
+ auto shared_mad3 = pmd->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid); |
+ ASSERT_EQ(shared_mad1, shared_mad3); |
+ ASSERT_TRUE(MemoryAllocatorDump::Flag::WEAK & shared_mad1->flags()); |
+ |
+ auto shared_mad4 = pmd->CreateSharedGlobalAllocatorDump(shared_mad_guid); |
+ ASSERT_EQ(shared_mad1, shared_mad4); |
+ ASSERT_FALSE(MemoryAllocatorDump::Flag::WEAK & shared_mad1->flags()); |
+ |
+ auto shared_mad5 = pmd->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid); |
+ ASSERT_EQ(shared_mad1, shared_mad5); |
+ ASSERT_FALSE(MemoryAllocatorDump::Flag::WEAK & shared_mad1->flags()); |
+} |
+ |
#if defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
TEST(ProcessMemoryDumpTest, CountResidentBytes) { |
const size_t page_size = base::GetPageSize(); |