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

Side by Side Diff: chrome/browser/metrics/metrics_service_browsertest.cc

Issue 2879793003: Disable stack trace during MetricsServiceBrowserTest.OOMRenderers (Closed)
Patch Set: Add bug reference Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Tests the MetricsService stat recording to make sure that the numbers are 5 // Tests the MetricsService stat recording to make sure that the numbers are
6 // what we expect. 6 // what we expect.
7 7
8 #include "components/metrics/metrics_service.h" 8 #include "components/metrics/metrics_service.h"
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/process/memory.h" 15 #include "base/process/memory.h"
16 #include "base/test/histogram_tester.h" 16 #include "base/test/histogram_tester.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
24 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
26 #include "components/metrics/metrics_pref_names.h" 26 #include "components/metrics/metrics_pref_names.h"
27 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
28 #include "content/public/test/browser_test_utils.h" 28 #include "content/public/test/browser_test_utils.h"
29 #include "net/base/filename_util.h" 29 #include "net/base/filename_util.h"
30 #include "services/service_manager/embedder/switches.h"
30 #include "ui/base/window_open_disposition.h" 31 #include "ui/base/window_open_disposition.h"
31 #include "url/gurl.h" 32 #include "url/gurl.h"
32 33
33 #if defined(OS_POSIX) 34 #if defined(OS_POSIX)
34 #include <sys/wait.h> 35 #include <sys/wait.h>
35 #endif 36 #endif
36 37
37 #if defined(OS_WIN) 38 #if defined(OS_WIN)
38 #include "sandbox/win/src/sandbox_types.h" 39 #include "sandbox/win/src/sandbox_types.h"
39 #endif 40 #endif
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 std::abs(static_cast<int32_t>(STATUS_BREAKPOINT)), 1); 189 std::abs(static_cast<int32_t>(STATUS_BREAKPOINT)), 1);
189 #elif defined(OS_MACOSX) || defined(OS_LINUX) 190 #elif defined(OS_MACOSX) || defined(OS_LINUX)
190 VerifyRendererExitCodeIsSignal(histogram_tester, SIGTRAP); 191 VerifyRendererExitCodeIsSignal(histogram_tester, SIGTRAP);
191 #endif 192 #endif
192 histogram_tester.ExpectUniqueSample("Tabs.SadTab.CrashCreated", 1, 1); 193 histogram_tester.ExpectUniqueSample("Tabs.SadTab.CrashCreated", 1, 1);
193 } 194 }
194 195
195 // OOM code only works on Windows. 196 // OOM code only works on Windows.
196 #if defined(OS_WIN) && !defined(ADDRESS_SANITIZER) 197 #if defined(OS_WIN) && !defined(ADDRESS_SANITIZER)
197 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, OOMRenderers) { 198 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, OOMRenderers) {
199 // Disable stack traces during this test since DbgHelp is unreliable in
200 // low-memory conditions (see crbug.com/692564).
201 base::CommandLine::ForCurrentProcess()->AppendSwitch(
202 service_manager::switches::kDisableInProcessStackTraces);
Will Harris 2017/05/12 16:46:33 I'm not too familiar with this switch, but does it
203
198 base::HistogramTester histogram_tester; 204 base::HistogramTester histogram_tester;
199 205
200 OpenTabsAndNavigateToCrashyUrl(content::kChromeUIMemoryExhaustURL); 206 OpenTabsAndNavigateToCrashyUrl(content::kChromeUIMemoryExhaustURL);
201 207
202 // Verify that the expected stability metrics were recorded. 208 // Verify that the expected stability metrics were recorded.
203 const PrefService* prefs = g_browser_process->local_state(); 209 const PrefService* prefs = g_browser_process->local_state();
204 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); 210 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount));
205 // The three tabs from OpenTabs() and the one tab to open 211 // The three tabs from OpenTabs() and the one tab to open
206 // chrome://memory-exhaust/. 212 // chrome://memory-exhaust/.
207 EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); 213 EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount));
208 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); 214 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount));
209 215
210 // On 64-bit, the Job object should terminate the renderer on an OOM. 216 // On 64-bit, the Job object should terminate the renderer on an OOM.
211 #if defined(ARCH_CPU_64_BITS) 217 #if defined(ARCH_CPU_64_BITS)
212 const int expected_exit_code = sandbox::SBOX_FATAL_MEMORY_EXCEEDED; 218 const int expected_exit_code = sandbox::SBOX_FATAL_MEMORY_EXCEEDED;
213 #else 219 #else
214 const int expected_exit_code = base::win::kOomExceptionCode; 220 const int expected_exit_code = base::win::kOomExceptionCode;
215 #endif 221 #endif
216 222
217 // Exit codes are recorded after being passed through std::abs see 223 // Exit codes are recorded after being passed through std::abs see
218 // MapCrashExitCodeForHistogram. 224 // MapCrashExitCodeForHistogram.
219 histogram_tester.ExpectUniqueSample("CrashExitCodes.Renderer", 225 histogram_tester.ExpectUniqueSample("CrashExitCodes.Renderer",
220 std::abs(expected_exit_code), 1); 226 std::abs(expected_exit_code), 1);
221 227
222 histogram_tester.ExpectUniqueSample("Tabs.SadTab.OomCreated", 1, 1); 228 histogram_tester.ExpectUniqueSample("Tabs.SadTab.OomCreated", 1, 1);
223 } 229 }
224 #endif // OS_WIN && !ADDRESS_SANITIZER 230 #endif // OS_WIN && !ADDRESS_SANITIZER
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698