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

Side by Side Diff: base/process/process_metrics_unittest.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « base/process/process_linux.cc ('k') | base/process/process_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process/process_metrics.h" 5 #include "base/process/process_metrics.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 "Committed_AS: 118680 kB\n" 136 "Committed_AS: 118680 kB\n"
137 "PageTables: 1236 kB\n" 137 "PageTables: 1236 kB\n"
138 "VmallocTotal: 3874808 kB\n" 138 "VmallocTotal: 3874808 kB\n"
139 "VmallocUsed: 1416 kB\n" 139 "VmallocUsed: 1416 kB\n"
140 "VmallocChunk: 3872908 kB\n" 140 "VmallocChunk: 3872908 kB\n"
141 "HugePages_Total: 0\n" 141 "HugePages_Total: 0\n"
142 "HugePages_Free: 0\n" 142 "HugePages_Free: 0\n"
143 "Hugepagesize: 4096 kB\n"; 143 "Hugepagesize: 4096 kB\n";
144 144
145 EXPECT_TRUE(ParseProcMeminfo(valid_input1, &meminfo)); 145 EXPECT_TRUE(ParseProcMeminfo(valid_input1, &meminfo));
146 EXPECT_TRUE(meminfo.total == 3981504); 146 EXPECT_EQ(meminfo.total, 3981504);
147 EXPECT_TRUE(meminfo.free == 140764); 147 EXPECT_EQ(meminfo.free, 140764);
148 EXPECT_TRUE(meminfo.buffers == 116480); 148 EXPECT_EQ(meminfo.buffers, 116480);
149 EXPECT_TRUE(meminfo.cached == 406160); 149 EXPECT_EQ(meminfo.cached, 406160);
150 EXPECT_TRUE(meminfo.active_anon == 2972352); 150 EXPECT_EQ(meminfo.active_anon, 2972352);
151 EXPECT_TRUE(meminfo.active_file == 179688); 151 EXPECT_EQ(meminfo.active_file, 179688);
152 EXPECT_TRUE(meminfo.inactive_anon == 270108); 152 EXPECT_EQ(meminfo.inactive_anon, 270108);
153 EXPECT_TRUE(meminfo.inactive_file == 202748); 153 EXPECT_EQ(meminfo.inactive_file, 202748);
154 EXPECT_TRUE(meminfo.swap_total == 5832280); 154 EXPECT_EQ(meminfo.swap_total, 5832280);
155 EXPECT_TRUE(meminfo.swap_free == 3672368); 155 EXPECT_EQ(meminfo.swap_free, 3672368);
156 EXPECT_TRUE(meminfo.dirty == 184); 156 EXPECT_EQ(meminfo.dirty, 184);
157 #if defined(OS_CHROMEOS) 157 #if defined(OS_CHROMEOS)
158 EXPECT_TRUE(meminfo.shmem == 140204); 158 EXPECT_EQ(meminfo.shmem, 140204);
159 EXPECT_TRUE(meminfo.slab == 54212); 159 EXPECT_EQ(meminfo.slab, 54212);
160 #endif 160 #endif
161 EXPECT_TRUE(ParseProcMeminfo(valid_input2, &meminfo)); 161 EXPECT_TRUE(ParseProcMeminfo(valid_input2, &meminfo));
162 EXPECT_TRUE(meminfo.total == 255908); 162 EXPECT_EQ(meminfo.total, 255908);
163 EXPECT_TRUE(meminfo.free == 69936); 163 EXPECT_EQ(meminfo.free, 69936);
164 EXPECT_TRUE(meminfo.buffers == 15812); 164 EXPECT_EQ(meminfo.buffers, 15812);
165 EXPECT_TRUE(meminfo.cached == 115124); 165 EXPECT_EQ(meminfo.cached, 115124);
166 EXPECT_TRUE(meminfo.swap_total == 524280); 166 EXPECT_EQ(meminfo.swap_total, 524280);
167 EXPECT_TRUE(meminfo.swap_free == 524200); 167 EXPECT_EQ(meminfo.swap_free, 524200);
168 EXPECT_TRUE(meminfo.dirty == 4); 168 EXPECT_EQ(meminfo.dirty, 4);
169 } 169 }
170 170
171 TEST_F(SystemMetricsTest, ParseVmstat) { 171 TEST_F(SystemMetricsTest, ParseVmstat) {
172 struct SystemMemoryInfoKB meminfo; 172 struct SystemMemoryInfoKB meminfo;
173 // part of vmstat from a 3.2 kernel with numa enabled 173 // part of vmstat from a 3.2 kernel with numa enabled
174 std::string valid_input1 = 174 std::string valid_input1 =
175 "nr_free_pages 905104\n" 175 "nr_free_pages 905104\n"
176 "nr_inactive_anon 142478" 176 "nr_inactive_anon 142478"
177 "nr_active_anon 1520046\n" 177 "nr_active_anon 1520046\n"
178 "nr_inactive_file 4481001\n" 178 "nr_inactive_file 4481001\n"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 "pgalloc_movable 0\n" 253 "pgalloc_movable 0\n"
254 "pgfree 308894908\n" 254 "pgfree 308894908\n"
255 "pgactivate 239320\n" 255 "pgactivate 239320\n"
256 "pgdeactivate 1\n" 256 "pgdeactivate 1\n"
257 "pgfault 716044601\n" 257 "pgfault 716044601\n"
258 "pgmajfault 2023\n" 258 "pgmajfault 2023\n"
259 "pgrefill_normal 0\n" 259 "pgrefill_normal 0\n"
260 "pgrefill_high 0\n" 260 "pgrefill_high 0\n"
261 "pgrefill_movable 0\n"; 261 "pgrefill_movable 0\n";
262 EXPECT_TRUE(ParseProcVmstat(valid_input1, &meminfo)); 262 EXPECT_TRUE(ParseProcVmstat(valid_input1, &meminfo));
263 EXPECT_TRUE(meminfo.pswpin == 179); 263 EXPECT_EQ(meminfo.pswpin, 179);
264 EXPECT_TRUE(meminfo.pswpout == 406); 264 EXPECT_EQ(meminfo.pswpout, 406);
265 EXPECT_TRUE(meminfo.pgmajfault == 487192); 265 EXPECT_EQ(meminfo.pgmajfault, 487192);
266 EXPECT_TRUE(ParseProcVmstat(valid_input2, &meminfo)); 266 EXPECT_TRUE(ParseProcVmstat(valid_input2, &meminfo));
267 EXPECT_TRUE(meminfo.pswpin == 12); 267 EXPECT_EQ(meminfo.pswpin, 12);
268 EXPECT_TRUE(meminfo.pswpout == 901); 268 EXPECT_EQ(meminfo.pswpout, 901);
269 EXPECT_TRUE(meminfo.pgmajfault == 2023); 269 EXPECT_EQ(meminfo.pgmajfault, 2023);
270 } 270 }
271 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 271 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
272 272
273 #if defined(OS_LINUX) || defined(OS_ANDROID) 273 #if defined(OS_LINUX) || defined(OS_ANDROID)
274 TEST(SystemMetrics2Test, GetSystemMemoryInfo) { 274 TEST(SystemMetrics2Test, GetSystemMemoryInfo) {
275 base::SystemMemoryInfoKB info; 275 base::SystemMemoryInfoKB info;
276 EXPECT_TRUE(base::GetSystemMemoryInfo(&info)); 276 EXPECT_TRUE(base::GetSystemMemoryInfo(&info));
277 277
278 // Ensure each field received a value. 278 // Ensure each field received a value.
279 EXPECT_GT(info.total, 0); 279 EXPECT_GT(info.total, 0);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 ASSERT_EQ(base::GetNumberOfThreads(current), initial_threads + 1 + i); 354 ASSERT_EQ(base::GetNumberOfThreads(current), initial_threads + 1 + i);
355 } 355 }
356 } 356 }
357 // The Thread destructor will stop them. 357 // The Thread destructor will stop them.
358 ASSERT_EQ(initial_threads, base::GetNumberOfThreads(current)); 358 ASSERT_EQ(initial_threads, base::GetNumberOfThreads(current));
359 } 359 }
360 #endif // defined(OS_LINUX) 360 #endif // defined(OS_LINUX)
361 361
362 } // namespace debug 362 } // namespace debug
363 } // namespace base 363 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_linux.cc ('k') | base/process/process_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698