Chromium Code Reviews| 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 571774a10ca2224e469e447902be2e0b5618953b..619b6c7cf0999f1cd24781dfe05c5615b27df600 100644 |
| --- a/base/trace_event/process_memory_dump_unittest.cc |
| +++ b/base/trace_event/process_memory_dump_unittest.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/memory/aligned_memory.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/process/process_metrics.h" |
| +#include "base/trace_event/heap_profiler_allocation_register.h" |
| #include "base/trace_event/memory_allocator_dump_guid.h" |
| #include "base/trace_event/memory_infra_background_whitelist.h" |
| #include "base/trace_event/trace_event_argument.h" |
| @@ -90,31 +91,27 @@ TEST(ProcessMemoryDumpTest, Clear) { |
| TEST(ProcessMemoryDumpTest, TakeAllDumpsFrom) { |
| std::unique_ptr<TracedValue> traced_value(new TracedValue); |
| - hash_map<AllocationContext, AllocationMetrics> metrics_by_context; |
| - metrics_by_context[AllocationContext()] = { 1, 1 }; |
| - TraceEventMemoryOverhead overhead; |
| + AllocationRegister allocation_register(10, 10); |
| + allocation_register.Insert("", 100, AllocationContext()); |
| scoped_refptr<MemoryDumpSessionState> session_state = |
| new MemoryDumpSessionState; |
| - session_state->SetStackFrameDeduplicator( |
| - WrapUnique(new StackFrameDeduplicator)); |
| - session_state->SetTypeNameDeduplicator( |
| - WrapUnique(new TypeNameDeduplicator)); |
| + session_state->CreateDeduplicators(); |
| std::unique_ptr<ProcessMemoryDump> pmd1( |
| new ProcessMemoryDump(session_state.get(), kDetailedDumpArgs)); |
| auto* mad1_1 = pmd1->CreateAllocatorDump("pmd1/mad1"); |
| auto* mad1_2 = pmd1->CreateAllocatorDump("pmd1/mad2"); |
| pmd1->AddOwnershipEdge(mad1_1->guid(), mad1_2->guid()); |
| - pmd1->DumpHeapUsage(metrics_by_context, overhead, "pmd1/heap_dump1"); |
| - pmd1->DumpHeapUsage(metrics_by_context, overhead, "pmd1/heap_dump2"); |
| + pmd1->DumpHeapUsage(allocation_register, "pmd1/heap_dump1"); |
| + pmd1->DumpHeapUsage(allocation_register, "pmd1/heap_dump2"); |
| std::unique_ptr<ProcessMemoryDump> pmd2( |
| new ProcessMemoryDump(session_state.get(), kDetailedDumpArgs)); |
| auto* mad2_1 = pmd2->CreateAllocatorDump("pmd2/mad1"); |
| auto* mad2_2 = pmd2->CreateAllocatorDump("pmd2/mad2"); |
| pmd2->AddOwnershipEdge(mad2_1->guid(), mad2_2->guid()); |
| - pmd2->DumpHeapUsage(metrics_by_context, overhead, "pmd2/heap_dump1"); |
| - pmd2->DumpHeapUsage(metrics_by_context, overhead, "pmd2/heap_dump2"); |
| + pmd2->DumpHeapUsage(allocation_register, "pmd2/heap_dump1"); |
| + pmd2->DumpHeapUsage(allocation_register, "pmd2/heap_dump2"); |
| MemoryAllocatorDumpGuid shared_mad_guid1(1); |
| MemoryAllocatorDumpGuid shared_mad_guid2(2); |
| @@ -122,6 +119,8 @@ TEST(ProcessMemoryDumpTest, TakeAllDumpsFrom) { |
| auto* shared_mad2 = |
| pmd2->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid2); |
| + LOG(INFO) << "About to merge"; |
|
ssid
2017/03/16 02:09:20
Isn't the test logs going to help with debugging h
DmitrySkiba
2017/03/17 04:01:38
Done. Thanks for noticing!
|
| + |
| pmd1->TakeAllDumpsFrom(pmd2.get()); |
| // Make sure that pmd2 is empty but still usable after it has been emptied. |
| @@ -142,7 +141,9 @@ TEST(ProcessMemoryDumpTest, TakeAllDumpsFrom) { |
| pmd2.reset(); |
| // Now check that |pmd1| has been effectively merged. |
| - ASSERT_EQ(6u, pmd1->allocator_dumps().size()); |
| + // Note that DumpHeapUsage() adds an implicit dump for AllocationRegister's |
| + // memory overhead. |
|
ssid
2017/03/16 02:09:20
Can you add asserts that these overhead dumps exis
DmitrySkiba
2017/03/17 04:01:38
That's an interesting test, but I don't think it's
|
| + ASSERT_EQ(10u, 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")); |