Commit 60bc5946 authored by erikchen's avatar erikchen Committed by Commit bot

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}
parent c536fccf
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
...@@ -167,9 +168,9 @@ static bool GetProcessMemoryInfoUsingPS( ...@@ -167,9 +168,9 @@ static bool GetProcessMemoryInfoUsingPS(
in >> proc_info.vsize; in >> proc_info.vsize;
proc_info.rss *= 1024; // Convert from kilobytes to bytes. proc_info.rss *= 1024; // Convert from kilobytes to bytes.
proc_info.vsize *= 1024; proc_info.vsize *= 1024;
in.ignore(1, ' '); // Eat the space.
std::getline(in, proc_info.command); // Get the rest of the line. // If the fail or bad bits were set, then there was an error reading input.
if (!in.good()) { if (in.fail()) {
LOG(ERROR) << "Error parsing output from " << kProgram.value() << "."; LOG(ERROR) << "Error parsing output from " << kProgram.value() << ".";
return false; return false;
} }
...@@ -181,6 +182,9 @@ static bool GetProcessMemoryInfoUsingPS( ...@@ -181,6 +182,9 @@ static bool GetProcessMemoryInfoUsingPS(
// Record the process information. // Record the process information.
proc_info_entries[proc_info.pid] = proc_info; 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; return true;
...@@ -309,6 +313,13 @@ bool ProcessInfoSnapshot::Sample(std::vector<base::ProcessId> pid_list) { ...@@ -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. // Get memory information using top.
bool memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_); bool memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/posix/eintr_wrapper.h" #include "base/posix/eintr_wrapper.h"
#include "base/process/kill.h" #include "base/process/kill.h"
#include "base/process/launch.h" #include "base/process/launch.h"
...@@ -77,12 +78,19 @@ TEST_F(ProcessInfoSnapshotMacTest, FindPidSelfTest) { ...@@ -77,12 +78,19 @@ TEST_F(ProcessInfoSnapshotMacTest, FindPidSelfTest) {
EXPECT_EQ(ppid, proc_info.ppid); EXPECT_EQ(ppid, proc_info.ppid);
EXPECT_EQ(uid, proc_info.uid); EXPECT_EQ(uid, proc_info.uid);
EXPECT_EQ(euid, proc_info.euid); EXPECT_EQ(euid, proc_info.euid);
EXPECT_GE(proc_info.rss, 100u); // Sanity check: we're running, so we // Sanity check: we're running, so we should occupy at least 100 kilobytes.
// should occupy at least 100 kilobytes. EXPECT_GE(proc_info.rss, 100u);
EXPECT_GE(proc_info.vsize, 1024u); // Sanity check: our |vsize| is presumably // Sanity check: our |vsize| is presumably at least a megabyte.
// at least a megabyte. EXPECT_GE(proc_info.vsize, 1024u);
EXPECT_GE(proc_info.rshrd, 1024u); // Shared memory should also > 1 MB.
EXPECT_GE(proc_info.rprvt, 1024u); // Same with private memory. // 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. // Find our parent.
ASSERT_TRUE(snapshot.GetProcInfo(ppid, &proc_info)); ASSERT_TRUE(snapshot.GetProcInfo(ppid, &proc_info));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment