Index: base/process/process_util_unittest.cc |
diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc |
index 80acb3878f3eea88bd06140e709b6774af021c84..2e533067475d9c9415168e789e4b52a4dd08456c 100644 |
--- a/base/process/process_util_unittest.cc |
+++ b/base/process/process_util_unittest.cc |
@@ -353,85 +353,8 @@ TEST_F(ProcessUtilTest, SetProcessBackgroundedSelf) { |
EXPECT_EQ(old_priority, new_priority); |
} |
-#if defined(OS_LINUX) || defined(OS_ANDROID) |
-TEST_F(ProcessUtilTest, GetSystemMemoryInfo) { |
- base::SystemMemoryInfoKB info; |
- EXPECT_TRUE(base::GetSystemMemoryInfo(&info)); |
- |
- // Ensure each field received a value. |
- EXPECT_GT(info.total, 0); |
- EXPECT_GT(info.free, 0); |
- EXPECT_GT(info.buffers, 0); |
- EXPECT_GT(info.cached, 0); |
- EXPECT_GT(info.active_anon, 0); |
- EXPECT_GT(info.inactive_anon, 0); |
- EXPECT_GT(info.active_file, 0); |
- EXPECT_GT(info.inactive_file, 0); |
- |
- // All the values should be less than the total amount of memory. |
- EXPECT_LT(info.free, info.total); |
- EXPECT_LT(info.buffers, info.total); |
- EXPECT_LT(info.cached, info.total); |
- EXPECT_LT(info.active_anon, info.total); |
- EXPECT_LT(info.inactive_anon, info.total); |
- EXPECT_LT(info.active_file, info.total); |
- EXPECT_LT(info.inactive_file, info.total); |
- |
-#if defined(OS_CHROMEOS) |
- // Chrome OS exposes shmem. |
- EXPECT_GT(info.shmem, 0); |
- EXPECT_LT(info.shmem, info.total); |
- // Chrome unit tests are not run on actual Chrome OS hardware, so gem_objects |
- // and gem_size cannot be tested here. |
-#endif |
-} |
-#endif // defined(OS_LINUX) || defined(OS_ANDROID) |
- |
-// TODO(estade): if possible, port these 2 tests. |
#if defined(OS_WIN) |
-TEST_F(ProcessUtilTest, CalcFreeMemory) { |
- scoped_ptr<base::ProcessMetrics> metrics( |
- base::ProcessMetrics::CreateProcessMetrics(::GetCurrentProcess())); |
- ASSERT_TRUE(NULL != metrics.get()); |
- |
- bool using_tcmalloc = false; |
- |
- // Detect if we are using tcmalloc |
-#if !defined(NO_TCMALLOC) |
- const char* chrome_allocator = getenv("CHROME_ALLOCATOR"); |
- if (!chrome_allocator || _stricmp(chrome_allocator, "tcmalloc") == 0) |
- using_tcmalloc = true; |
-#endif |
- |
- // Typical values here is ~1900 for total and ~1000 for largest. Obviously |
- // it depends in what other tests have done to this process. |
- base::FreeMBytes free_mem1 = {0}; |
- EXPECT_TRUE(metrics->CalculateFreeMemory(&free_mem1)); |
- EXPECT_LT(10u, free_mem1.total); |
- EXPECT_LT(10u, free_mem1.largest); |
- EXPECT_GT(2048u, free_mem1.total); |
- EXPECT_GT(2048u, free_mem1.largest); |
- EXPECT_GE(free_mem1.total, free_mem1.largest); |
- EXPECT_TRUE(NULL != free_mem1.largest_ptr); |
- |
- // Allocate 20M and check again. It should have gone down. |
- const int kAllocMB = 20; |
- scoped_ptr<char[]> alloc(new char[kAllocMB * 1024 * 1024]); |
- size_t expected_total = free_mem1.total - kAllocMB; |
- size_t expected_largest = free_mem1.largest; |
- |
- base::FreeMBytes free_mem2 = {0}; |
- EXPECT_TRUE(metrics->CalculateFreeMemory(&free_mem2)); |
- EXPECT_GE(free_mem2.total, free_mem2.largest); |
- // This test is flaky when using tcmalloc, because tcmalloc |
- // allocation strategy sometimes results in less than the |
- // full drop of 20Mb of free memory. |
- if (!using_tcmalloc) |
- EXPECT_GE(expected_total, free_mem2.total); |
- EXPECT_GE(expected_largest, free_mem2.largest); |
- EXPECT_TRUE(NULL != free_mem2.largest_ptr); |
-} |
- |
+// TODO(estade): if possible, port this test. |
TEST_F(ProcessUtilTest, GetAppOutput) { |
// Let's create a decently long message. |
std::string message; |
@@ -461,6 +384,7 @@ TEST_F(ProcessUtilTest, GetAppOutput) { |
EXPECT_EQ("", output); |
} |
+// TODO(estade): if possible, port this test. |
TEST_F(ProcessUtilTest, LaunchAsUser) { |
base::UserTokenHandle token; |
ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)); |
@@ -828,50 +752,6 @@ TEST_F(ProcessUtilTest, GetParentProcessId) { |
EXPECT_EQ(ppid, getppid()); |
} |
-#if defined(OS_LINUX) || defined(OS_ANDROID) |
-TEST_F(ProcessUtilTest, ParseProcStatCPU) { |
- // /proc/self/stat for a process running "top". |
- const char kTopStat[] = "960 (top) S 16230 960 16230 34818 960 " |
- "4202496 471 0 0 0 " |
- "12 16 0 0 " // <- These are the goods. |
- "20 0 1 0 121946157 15077376 314 18446744073709551615 4194304 " |
- "4246868 140733983044336 18446744073709551615 140244213071219 " |
- "0 0 0 138047495 0 0 0 17 1 0 0 0 0 0"; |
- EXPECT_EQ(12 + 16, base::ParseProcStatCPU(kTopStat)); |
- |
- // cat /proc/self/stat on a random other machine I have. |
- const char kSelfStat[] = "5364 (cat) R 5354 5364 5354 34819 5364 " |
- "0 142 0 0 0 " |
- "0 0 0 0 " // <- No CPU, apparently. |
- "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 " |
- "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0"; |
- |
- EXPECT_EQ(0, base::ParseProcStatCPU(kSelfStat)); |
-} |
- |
-// Disable on Android because base_unittests runs inside a Dalvik VM that |
-// starts and stop threads (crbug.com/175563). |
-#if !defined(OS_ANDROID) |
-TEST_F(ProcessUtilTest, GetNumberOfThreads) { |
- const base::ProcessHandle current = base::GetCurrentProcessHandle(); |
- const int initial_threads = base::GetNumberOfThreads(current); |
- ASSERT_GT(initial_threads, 0); |
- const int kNumAdditionalThreads = 10; |
- { |
- scoped_ptr<base::Thread> my_threads[kNumAdditionalThreads]; |
- for (int i = 0; i < kNumAdditionalThreads; ++i) { |
- my_threads[i].reset(new base::Thread("GetNumberOfThreadsTest")); |
- my_threads[i]->Start(); |
- ASSERT_EQ(base::GetNumberOfThreads(current), initial_threads + 1 + i); |
- } |
- } |
- // The Thread destructor will stop them. |
- ASSERT_EQ(initial_threads, base::GetNumberOfThreads(current)); |
-} |
-#endif // !defined(OS_ANDROID) |
- |
-#endif // defined(OS_LINUX) || defined(OS_ANDROID) |
- |
// TODO(port): port those unit tests. |
bool IsProcessDead(base::ProcessHandle child) { |
// waitpid() will actually reap the process which is exactly NOT what we |