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 1e1fbc69cf91cab4262c4be1522e2e70705954b6..18c2d9b9b6295b5f4e2e332d67e542b0589c14c6 100644 |
| --- a/base/trace_event/process_memory_dump_unittest.cc |
| +++ b/base/trace_event/process_memory_dump_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "base/trace_event/process_memory_dump.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/process/process_metrics.h" |
| #include "base/trace_event/memory_allocator_dump_guid.h" |
| #include "base/trace_event/trace_event_argument.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -154,5 +155,34 @@ TEST(ProcessMemoryDumpTest, Suballocations) { |
| pmd.reset(); |
| } |
| +#if defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| +TEST(ProcessMemoryDumpTest, CountResidentBytes) { |
| + const size_t page_size = base::GetPageSize(); |
| + // Allocate a segment on stack and check if the page is resident. |
| + char memory1[100] = {0}; |
|
Primiano Tucci (use gerrit)
2015/10/07 13:59:51
if you decide to support only page aligned ranges,
ssid
2015/10/07 14:46:45
Hm, I added this check only to verify if it shows
|
| + void* page_start1 = reinterpret_cast<void*>( |
| + reinterpret_cast<uintptr_t>(memory1) / page_size * page_size); |
| + size_t res1 = ProcessMemoryDump::CountResidentBytes(page_start1, page_size); |
| + ASSERT_GE(res1, page_size); |
| + |
| + // Allocate few page of dirty memory and check if it is resident. |
| + scoped_ptr<char[]> memory2(new char[5 * page_size]()); |
| + void* page_start2 = reinterpret_cast<void*>( |
| + reinterpret_cast<uintptr_t>(memory2.get()) / page_size * page_size); |
| + size_t res2 = |
| + ProcessMemoryDump::CountResidentBytes(page_start2, 5 * page_size); |
| + ASSERT_GE(res2, 5 * page_size); |
| + |
| + // Allocate a large memory segment (>32Mib). |
| + const size_t kVeryLargeMemorySize = 34 * 1024 * 1024; |
| + scoped_ptr<char[]> memory3(new char[kVeryLargeMemorySize]()); |
| + void* page_start3 = reinterpret_cast<void*>( |
| + reinterpret_cast<uintptr_t>(memory3.get()) / page_size * page_size); |
| + size_t res3 = |
| + ProcessMemoryDump::CountResidentBytes(page_start3, kVeryLargeMemorySize); |
| + ASSERT_GE(res3, kVeryLargeMemorySize); |
|
Primiano Tucci (use gerrit)
2015/10/07 13:59:51
?? How does this pass? Nothing is making those pag
ssid
2015/10/07 14:46:45
new char[kVeryLargeMemorySize]() has an extra () a
|
| +} |
| +#endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| + |
| } // namespace trace_event |
| } // namespace base |