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

Unified Diff: components/metrics/stability_metrics_helper_unittest.cc

Issue 2233303002: Correctly increment crashed renderer process stability counts on OOM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add android Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/stability_metrics_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/stability_metrics_helper_unittest.cc
diff --git a/components/metrics/stability_metrics_helper_unittest.cc b/components/metrics/stability_metrics_helper_unittest.cc
index d5aa9291a0cc9e588c4c5dbd7ce1706597501ce3..018906d8a1cde9d0cbf3cc2e323248a076f3af4b 100644
--- a/components/metrics/stability_metrics_helper_unittest.cc
+++ b/components/metrics/stability_metrics_helper_unittest.cc
@@ -5,6 +5,7 @@
#include "components/metrics/stability_metrics_helper.h"
#include "base/macros.h"
+#include "base/test/histogram_tester.h"
#include "components/metrics/proto/system_profile.pb.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
@@ -15,6 +16,15 @@ namespace metrics {
namespace {
+enum RendererType {
+ RENDERER_TYPE_RENDERER = 1,
+ RENDERER_TYPE_EXTENSION,
+ // NOTE: Add new action types only immediately above this line. Also,
+ // make sure the enum list in tools/metrics/histograms/histograms.xml is
+ // updated with any change in here.
+ RENDERER_TYPE_COUNT
+};
+
class StabilityMetricsHelperTest : public testing::Test {
protected:
StabilityMetricsHelperTest() : prefs_(new TestingPrefServiceSimple) {
@@ -52,6 +62,7 @@ TEST_F(StabilityMetricsHelperTest, BrowserChildProcessCrashed) {
TEST_F(StabilityMetricsHelperTest, LogRendererCrash) {
StabilityMetricsHelper helper(prefs());
+ base::HistogramTester histogram_tester;
// Crash and abnormal termination should increment renderer crash count.
helper.LogRendererCrash(false, base::TERMINATION_STATUS_PROCESS_CRASHED, 1);
@@ -59,6 +70,9 @@ TEST_F(StabilityMetricsHelperTest, LogRendererCrash) {
helper.LogRendererCrash(false, base::TERMINATION_STATUS_ABNORMAL_TERMINATION,
1);
+ // OOM should increment renderer crash count.
+ helper.LogRendererCrash(false, base::TERMINATION_STATUS_OOM, 1);
+
// Kill does not increment renderer crash count.
helper.LogRendererCrash(false, base::TERMINATION_STATUS_PROCESS_WAS_KILLED,
1);
@@ -72,7 +86,7 @@ TEST_F(StabilityMetricsHelperTest, LogRendererCrash) {
// be executed immediately.
helper.ProvideStabilityMetrics(&system_profile);
- EXPECT_EQ(2, system_profile.stability().renderer_crash_count());
+ EXPECT_EQ(3, system_profile.stability().renderer_crash_count());
EXPECT_EQ(1, system_profile.stability().renderer_failed_launch_count());
EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count());
@@ -81,6 +95,9 @@ TEST_F(StabilityMetricsHelperTest, LogRendererCrash) {
// Crash and abnormal termination should increment extension crash count.
helper.LogRendererCrash(true, base::TERMINATION_STATUS_PROCESS_CRASHED, 1);
+ // OOM should increment extension renderer crash count.
+ helper.LogRendererCrash(true, base::TERMINATION_STATUS_OOM, 1);
+
// Failed launch increments extension failed launch count.
helper.LogRendererCrash(true, base::TERMINATION_STATUS_LAUNCH_FAILED, 1);
@@ -88,9 +105,36 @@ TEST_F(StabilityMetricsHelperTest, LogRendererCrash) {
helper.ProvideStabilityMetrics(&system_profile);
EXPECT_EQ(0, system_profile.stability().renderer_crash_count());
- EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count());
+ EXPECT_EQ(2, system_profile.stability().extension_renderer_crash_count());
EXPECT_EQ(
1, system_profile.stability().extension_renderer_failed_launch_count());
+
+ // TERMINATION_STATUS_PROCESS_CRASHED, TERMINATION_STATUS_ABNORMAL_TERMINATION
+ // and TERMINATION_STATUS_OOM = 3.
+ histogram_tester.ExpectUniqueSample("CrashExitCodes.Renderer", 1, 3);
+ histogram_tester.ExpectBucketCount("BrowserRenderProcessHost.ChildCrashes",
+ RENDERER_TYPE_RENDERER, 3);
+
+ // TERMINATION_STATUS_PROCESS_CRASHED and TERMINATION_STATUS_OOM = 2.
+ histogram_tester.ExpectUniqueSample("CrashExitCodes.Extension", 1, 2);
+ histogram_tester.ExpectBucketCount("BrowserRenderProcessHost.ChildCrashes",
+ RENDERER_TYPE_EXTENSION, 2);
+
+ // One launch failure each.
+ histogram_tester.ExpectBucketCount(
+ "BrowserRenderProcessHost.ChildLaunchFailures", RENDERER_TYPE_RENDERER,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "BrowserRenderProcessHost.ChildLaunchFailures", RENDERER_TYPE_EXTENSION,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "BrowserRenderProcessHost.ChildLaunchFailureCodes", 1, 2);
+
+ // TERMINATION_STATUS_PROCESS_WAS_KILLED for a renderer.
+ histogram_tester.ExpectBucketCount("BrowserRenderProcessHost.ChildKills",
+ RENDERER_TYPE_RENDERER, 1);
+ histogram_tester.ExpectBucketCount("BrowserRenderProcessHost.ChildKills",
+ RENDERER_TYPE_EXTENSION, 0);
}
} // namespace metrics
« no previous file with comments | « components/metrics/stability_metrics_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698