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

Unified Diff: components/tracing/common/process_metrics_memory_dump_provider_unittest.cc

Issue 2601193002: Emit VMRegions for macOS when doing process memory dumps. (Closed)
Patch Set: Switch back to region recurse. Created 3 years, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/common/process_metrics_memory_dump_provider_unittest.cc
diff --git a/components/tracing/common/process_metrics_memory_dump_provider_unittest.cc b/components/tracing/common/process_metrics_memory_dump_provider_unittest.cc
index 5b1b25f1d0ea12f329b6d25f574c6e21438d8bc4..fc53f77a7811e6db365800e9afc9bb3274092b1d 100644
--- a/components/tracing/common/process_metrics_memory_dump_provider_unittest.cc
+++ b/components/tracing/common/process_metrics_memory_dump_provider_unittest.cc
@@ -17,6 +17,11 @@
#include "base/trace_event/trace_event_argument.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_MACOSX)
+#include <libgen.h>
+#include <mach-o/dyld.h>
+#endif
+
namespace tracing {
#if defined(OS_LINUX) || defined(OS_ANDROID)
@@ -269,4 +274,35 @@ TEST(ProcessMetricsMemoryDumpProviderTest, TestPollFastMemoryTotal) {
#endif
}
+#if defined(OS_MACOSX)
+TEST(ProcessMetricsMemoryDumpProviderTest, TestMachOReading) {
+ using VMRegion = base::trace_event::ProcessMemoryMaps::VMRegion;
+ ProcessMetricsMemoryDumpProvider mdp(base::kNullProcessId);
+ base::trace_event::MemoryDumpArgs args;
+ base::trace_event::ProcessMemoryDump dump(nullptr, args);
+ ASSERT_TRUE(mdp.DumpProcessMemoryMaps(args, &dump));
+ ASSERT_TRUE(dump.has_process_mmaps());
+ uint32_t size = 100;
+ char full_path[size];
+ int result = _NSGetExecutablePath(full_path, &size);
+ ASSERT_EQ(0, result);
+ std::string name = basename(full_path);
+
+ bool found_components_unittests = false;
+ for (const VMRegion& region : dump.process_mmaps()->vm_regions()) {
+ EXPECT_NE(0u, region.start_address);
+ EXPECT_NE(0u, region.size_in_bytes);
+
+ EXPECT_LT(region.size_in_bytes, 1ull << 32);
+ uint32_t required_protection_flags =
+ VMRegion::kProtectionFlagsRead | VMRegion::kProtectionFlagsExec;
+ if (region.mapped_file.find(name) != std::string::npos &&
+ region.protection_flags == required_protection_flags) {
+ found_components_unittests = true;
+ }
+ }
+ EXPECT_TRUE(found_components_unittests);
+}
+#endif // defined(OS_MACOSX)
+
} // namespace tracing
« 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