diff options
author | erikchen <erikchen@chromium.org> | 2014-09-24 10:47:05 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-24 17:47:17 +0000 |
commit | 60bc59460320221de4bb233d28efed99dd827b51 (patch) | |
tree | 4e1722da58b80eefe240f99240bac534e443cefb | |
parent | c536fccf6efcd9a83701ebff8679a5824f6f0003 (diff) | |
download | chromium_src-60bc59460320221de4bb233d28efed99dd827b51.zip chromium_src-60bc59460320221de4bb233d28efed99dd827b51.tar.gz chromium_src-60bc59460320221de4bb233d28efed99dd827b51.tar.bz2 |
mac: Disable parts of ProcessInfoSnapshotMacTest on OSX 10.9+.
Collection of memory statistics is broken in OSX 10.9+. I've disabled the
checks in ProcessInfoSnapshotMacTest that expect collection of memory
statistics to work.
BUG=383553, 390276
Review URL: https://codereview.chromium.org/583193006
Cr-Commit-Position: refs/heads/master@{#296453}
-rw-r--r-- | chrome/browser/process_info_snapshot_mac.cc | 17 | ||||
-rw-r--r-- | chrome/browser/process_info_snapshot_mac_unittest.cc | 20 |
2 files changed, 28 insertions, 9 deletions
diff --git a/chrome/browser/process_info_snapshot_mac.cc b/chrome/browser/process_info_snapshot_mac.cc index 36d505c..fba77f8 100644 --- a/chrome/browser/process_info_snapshot_mac.cc +++ b/chrome/browser/process_info_snapshot_mac.cc @@ -11,6 +11,7 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/logging.h" +#include "base/mac/mac_util.h" #include "base/process/launch.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -167,9 +168,9 @@ static bool GetProcessMemoryInfoUsingPS( in >> proc_info.vsize; proc_info.rss *= 1024; // Convert from kilobytes to bytes. proc_info.vsize *= 1024; - in.ignore(1, ' '); // Eat the space. - std::getline(in, proc_info.command); // Get the rest of the line. - if (!in.good()) { + + // If the fail or bad bits were set, then there was an error reading input. + if (in.fail()) { LOG(ERROR) << "Error parsing output from " << kProgram.value() << "."; return false; } @@ -181,6 +182,9 @@ static bool GetProcessMemoryInfoUsingPS( // Record the process information. proc_info_entries[proc_info.pid] = proc_info; + + // Ignore the rest of the line. + in.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } return true; @@ -309,6 +313,13 @@ bool ProcessInfoSnapshot::Sample(std::vector<base::ProcessId> pid_list) { } } + // In OSX 10.9+, top no longer returns any useful information. 'rshrd' is no + // longer supported, and 'rprvt' and 'vsize' return N/A. 'rsize' still works, + // but the information is also available from ps. + // http://crbug.com/383553 + if (base::mac::IsOSMavericksOrLater()) + return GetProcessMemoryInfoUsingPS(pid_list, proc_info_entries_); + // Get memory information using top. bool memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_); diff --git a/chrome/browser/process_info_snapshot_mac_unittest.cc b/chrome/browser/process_info_snapshot_mac_unittest.cc index e968048..03323cc 100644 --- a/chrome/browser/process_info_snapshot_mac_unittest.cc +++ b/chrome/browser/process_info_snapshot_mac_unittest.cc @@ -12,6 +12,7 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/logging.h" +#include "base/mac/mac_util.h" #include "base/posix/eintr_wrapper.h" #include "base/process/kill.h" #include "base/process/launch.h" @@ -77,12 +78,19 @@ TEST_F(ProcessInfoSnapshotMacTest, FindPidSelfTest) { EXPECT_EQ(ppid, proc_info.ppid); EXPECT_EQ(uid, proc_info.uid); EXPECT_EQ(euid, proc_info.euid); - EXPECT_GE(proc_info.rss, 100u); // Sanity check: we're running, so we - // should occupy at least 100 kilobytes. - EXPECT_GE(proc_info.vsize, 1024u); // Sanity check: our |vsize| is presumably - // at least a megabyte. - EXPECT_GE(proc_info.rshrd, 1024u); // Shared memory should also > 1 MB. - EXPECT_GE(proc_info.rprvt, 1024u); // Same with private memory. + // Sanity check: we're running, so we should occupy at least 100 kilobytes. + EXPECT_GE(proc_info.rss, 100u); + // Sanity check: our |vsize| is presumably at least a megabyte. + EXPECT_GE(proc_info.vsize, 1024u); + + // Collection of some memory statistics is broken in OSX 10.9+. + // http://crbug.com/383553 + if (!base::mac::IsOSMavericksOrLater()) { + // Shared memory should also > 1 MB. + EXPECT_GE(proc_info.rshrd, 1024u); + // Same with private memory. + EXPECT_GE(proc_info.rprvt, 1024u); + } // Find our parent. ASSERT_TRUE(snapshot.GetProcInfo(ppid, &proc_info)); |