Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
ncarter (slow)
2015/06/26 21:46:16
2015, no (c)
brucedawson
2015/06/27 00:13:06
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/process/private_working_set_snapshot.h" | |
| 6 | |
| 7 #include "base/win/windows_version.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 typedef testing::Test PrivateWorkingSetSnapshotWinTest; | |
|
ncarter (slow)
2015/06/26 21:46:16
Apparently we're supposed to prefer C++11 aliases
brucedawson
2015/06/27 00:13:06
Done.
| |
| 11 | |
| 12 TEST_F(PrivateWorkingSetSnapshotWinTest, FindPidSelfTest) { | |
| 13 // The Pdh APIs are supported on Windows XP, but the "Working Set - Private" | |
| 14 // counter that PrivateWorkingSetSnapshot depends on is not defined until | |
| 15 // Windows Vista. Early-out to avoid test failure. | |
| 16 if (base::win::GetVersion() < base::win::VERSION_VISTA) | |
| 17 return; | |
| 18 | |
| 19 // Sample this process. | |
| 20 base::ProcessId pid = base::GetCurrentProcId(); | |
| 21 | |
| 22 base::PrivateWorkingSetSnapshot private_ws_snapshot; | |
| 23 | |
| 24 private_ws_snapshot.AddToMonitorList("base_unittests"); | |
| 25 private_ws_snapshot.Sample(); | |
| 26 | |
| 27 size_t private_ws = private_ws_snapshot.GetPrivateWorkingSet(pid); | |
| 28 // Private working set is difficult to predict but should be at least several | |
| 29 // MB. Initial tests show a value of ~4 MB to 25 MB depending on how many | |
| 30 // tests and processes are used. Anomalously small or large values would | |
| 31 // warrant investigation. | |
| 32 EXPECT_GT(private_ws, 2000000u); | |
| 33 // Check that the WS is less than 500 MB. This is set very high to reduce the | |
| 34 // change that unrelated changes could ever make this fail. This mostly just | |
|
ncarter (slow)
2015/06/26 21:46:16
change->chance
brucedawson
2015/06/27 00:13:05
Done.
| |
| 35 // checks against some uncaught error that might return 0xFFFFFFFF. | |
|
ncarter (slow)
2015/06/26 21:46:16
There are two things to worry about here. One is p
brucedawson
2015/06/27 00:13:06
Done.
| |
| 36 EXPECT_LT(private_ws, 500000000u); | |
|
ncarter (slow)
2015/06/26 21:46:16
In a test similar to this (of code that reported m
brucedawson
2015/06/27 00:13:06
Sounds good. Done.
| |
| 37 } | |
| OLD | NEW |