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..d5f381f3f999f9b08371169ce4e1157448b6f489 100644 |
| --- a/base/trace_event/process_memory_dump_unittest.cc |
| +++ b/base/trace_event/process_memory_dump_unittest.cc |
| @@ -4,7 +4,8 @@ |
| #include "base/trace_event/process_memory_dump.h" |
| -#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/aligned_memory.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,26 @@ TEST(ProcessMemoryDumpTest, Suballocations) { |
| pmd.reset(); |
| } |
| +#if defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| +TEST(ProcessMemoryDumpTest, CountResidentBytes) { |
| + const size_t page_size = base::GetPageSize(); |
| + |
| + // Allocate few page of dirty memory and check if it is resident. |
| + scoped_ptr<char, base::AlignedFreeDeleter> memory1( |
| + static_cast<char*>(base::AlignedAlloc(5 * page_size, page_size))); |
| + size_t res1 = |
|
Primiano Tucci (use gerrit)
2015/10/09 09:48:51
I think you want to memset these.
ssid
2015/10/09 10:57:40
Yess. done
|
| + ProcessMemoryDump::CountResidentBytes(memory1.get(), 5 * page_size); |
| + ASSERT_EQ(res1, 5 * page_size); |
| + |
| + // Allocate a large memory segment (>32Mib). |
| + const size_t kVeryLargeMemorySize = 34 * 1024 * 1024; |
| + scoped_ptr<char, base::AlignedFreeDeleter> memory2( |
| + static_cast<char*>(base::AlignedAlloc(kVeryLargeMemorySize, page_size))); |
| + size_t res2 = ProcessMemoryDump::CountResidentBytes(memory2.get(), |
| + kVeryLargeMemorySize); |
| + ASSERT_EQ(res2, kVeryLargeMemorySize); |
| +} |
| +#endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| + |
| } // namespace trace_event |
| } // namespace base |