Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" | 5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 mdp.PollFastMemoryTotal(&value); | 262 mdp.PollFastMemoryTotal(&value); |
| 263 EXPECT_EQ(100 * page_size, value); | 263 EXPECT_EQ(100 * page_size, value); |
| 264 | 264 |
| 265 mdp.SuspendFastMemoryPolling(); | 265 mdp.SuspendFastMemoryPolling(); |
| 266 EXPECT_FALSE(mdp.fast_polling_statm_fd_.is_valid()); | 266 EXPECT_FALSE(mdp.fast_polling_statm_fd_.is_valid()); |
| 267 #else | 267 #else |
| 268 mdp.SuspendFastMemoryPolling(); | 268 mdp.SuspendFastMemoryPolling(); |
| 269 #endif | 269 #endif |
| 270 } | 270 } |
| 271 | 271 |
| 272 #if defined(OS_MACOSX) | |
| 273 TEST(ProcessMetricsMemoryDumpProviderTest, TestMachOReading) { | |
| 274 using VMRegion = base::trace_event::ProcessMemoryMaps::VMRegion; | |
| 275 ProcessMetricsMemoryDumpProvider mdp(base::kNullProcessId); | |
| 276 base::trace_event::MemoryDumpArgs args; | |
| 277 base::trace_event::ProcessMemoryDump dump(nullptr, args); | |
| 278 ASSERT_TRUE(mdp.DumpProcessMemoryMaps(args, &dump)); | |
| 279 ASSERT_TRUE(dump.has_process_mmaps()); | |
| 280 | |
| 281 bool found_components_unittests = false; | |
| 282 for (const VMRegion& region : dump.process_mmaps()->vm_regions()) { | |
| 283 EXPECT_NE(0u, region.start_address); | |
| 284 EXPECT_NE(0u, region.size_in_bytes); | |
| 285 | |
| 286 uint32_t required_protection_flags = | |
| 287 VMRegion::kProtectionFlagsRead | VMRegion::kProtectionFlagsExec; | |
| 288 EXPECT_EQ(required_protection_flags, | |
| 289 region.protection_flags & required_protection_flags); | |
| 290 EXPECT_LT(region.size_in_bytes, 1ull << 32); | |
| 291 if (region.mapped_file.find("components_unittests") != std::string::npos) | |
|
Mark Mentovai
2017/01/03 20:07:46
Might be less fragile if you used basename(_NSGetE
| |
| 292 found_components_unittests = true; | |
| 293 } | |
| 294 EXPECT_TRUE(found_components_unittests); | |
| 295 } | |
| 296 #endif // defined(OS_MACOSX) | |
| 297 | |
| 272 } // namespace tracing | 298 } // namespace tracing |
| OLD | NEW |