Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: components/tracing/common/process_metrics_memory_dump_provider_unittest.cc

Issue 2787143002: [Reland #1] macOS: Fix a bug in logic to get all memory regions. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/tracing/common/process_metrics_memory_dump_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <unordered_set> 10 #include <unordered_set>
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 403 }
404 404
405 if (region.mapped_file.find("AppKit") != std::string::npos) { 405 if (region.mapped_file.find("AppKit") != std::string::npos) {
406 found_appkit = true; 406 found_appkit = true;
407 } 407 }
408 } 408 }
409 EXPECT_GT(components_unittests_resident_pages, 0u); 409 EXPECT_GT(components_unittests_resident_pages, 0u);
410 EXPECT_TRUE(found_appkit); 410 EXPECT_TRUE(found_appkit);
411 } 411 }
412 412
413 TEST(ProcessMetricsMemoryDumpProviderTest, NoDuplicateRegions) {
414 using VMRegion = base::trace_event::ProcessMemoryMaps::VMRegion;
415 ProcessMetricsMemoryDumpProvider mdp(base::kNullProcessId);
416 base::trace_event::MemoryDumpArgs args;
417 base::trace_event::ProcessMemoryDump dump(nullptr, args);
418 ASSERT_TRUE(mdp.DumpProcessMemoryMaps(args, &dump));
419 ASSERT_TRUE(dump.has_process_mmaps());
420
421 std::vector<VMRegion> regions;
422 regions.reserve(dump.process_mmaps()->vm_regions().size());
423 for (const VMRegion& region : dump.process_mmaps()->vm_regions())
424 regions.push_back(region);
425 std::sort(regions.begin(), regions.end(),
426 [](const VMRegion& a, const VMRegion& b) -> bool {
427 return a.start_address < b.start_address;
428 });
429 uint64_t last_address = 0;
430 for (const VMRegion& region : regions) {
431 EXPECT_GE(region.start_address, last_address);
432 last_address = region.start_address + region.size_in_bytes;
433 }
434 }
435
436 #endif // defined(OS_MACOSX) 413 #endif // defined(OS_MACOSX)
437 } // namespace tracing 414 } // namespace tracing
OLDNEW
« no previous file with comments | « components/tracing/common/process_metrics_memory_dump_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698