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

Unified Diff: base/process/process_metrics_unittest.cc

Issue 1384363002: [NOT TO COMMIT YET] Using proc/pid/status file contents to get process metrics in linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@smaps_fscan
Patch Set: Fixes. Created 5 years, 2 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 | « base/process/process_metrics_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_metrics_unittest.cc
diff --git a/base/process/process_metrics_unittest.cc b/base/process/process_metrics_unittest.cc
index 31479cefff64f5b0dc17c960b317bae45bec3b0e..3a8515b0b735c5007625aa90fc5265efaa6b035d 100644
--- a/base/process/process_metrics_unittest.cc
+++ b/base/process/process_metrics_unittest.cc
@@ -268,6 +268,34 @@ TEST_F(SystemMetricsTest, ParseVmstat) {
EXPECT_EQ(meminfo.pswpout, 901);
EXPECT_EQ(meminfo.pgmajfault, 2023);
}
+
+TEST(ProcessMetricsTest, ParseProcStatusFile) {
+ const char* kValindStatusContents =
+ "Name: bash\n"
+ "PPid: 3452\n"
+ "TracerPid: 0\n"
+ "Uid: 1000 1000 1000 1000\n"
+ "Gid: 100 100 100 100\n"
+ "FDSize: 256\n"
+ "Groups: 16 33 100\n"
+ "VmPeak: 9136 kB\n"
+ "VmSize: 7896 kB\n"
+ "VmHWM: 7572 kB\n"
+ "VmLib: 1708 kB\n"
+ "SigQ: 0/3067\n"
+ "SigPnd: 0000000000000000\n"
+ "ShdPnd: 0000000000000000\n"
+ "CapBnd: ffffffffffffffff\n"
+ "Seccomp: 0\n"
+ "Cpus_allowed: 00000001\n"
+ "nonvoluntary_ctxt_switches: 545\n";
+
+ size_t vm_size;
+ bool res =
+ ParseProcStatusAndGetField(kValindStatusContents, "VmSize", &vm_size);
+ EXPECT_TRUE(res);
+ EXPECT_EQ(7896 * 1024u, vm_size);
+}
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) || \
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698