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

Side by Side Diff: user_collector_test.cc

Issue 6297004: crash-reporter: Add diagnostics to help diagnose failures in the wild (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git@master
Patch Set: clarify Created 9 years, 11 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 | Annotate | Revision Log
« user_collector.cc ('K') | « user_collector.cc ('k') | 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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <unistd.h> 5 #include <unistd.h>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "crash-reporter/system_logging_mock.h" 8 #include "crash-reporter/system_logging_mock.h"
9 #include "crash-reporter/user_collector.h" 9 #include "crash-reporter/user_collector.h"
10 #include "crash-reporter/test_helpers.h" 10 #include "crash-reporter/test_helpers.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 EXPECT_EQ(golden, contents); 47 EXPECT_EQ(golden, contents);
48 } 48 }
49 49
50 SystemLoggingMock logging_; 50 SystemLoggingMock logging_;
51 UserCollector collector_; 51 UserCollector collector_;
52 pid_t pid_; 52 pid_t pid_;
53 }; 53 };
54 54
55 TEST_F(UserCollectorTest, EnableOK) { 55 TEST_F(UserCollectorTest, EnableOK) {
56 ASSERT_TRUE(collector_.Enable()); 56 ASSERT_TRUE(collector_.Enable());
57 ExpectFileEquals("|/my/path --signal=%s --pid=%p", "test/core_pattern"); 57 ExpectFileEquals("|/my/path --signal=%s --pid=%p --exec_name=%e",
58 "test/core_pattern");
58 ExpectFileEquals("4", "test/core_pipe_limit"); 59 ExpectFileEquals("4", "test/core_pipe_limit");
59 ASSERT_EQ(s_crashes, 0); 60 ASSERT_EQ(s_crashes, 0);
60 ASSERT_NE(logging_.log().find("Enabling user crash handling"), 61 ASSERT_NE(logging_.log().find("Enabling user crash handling"),
61 std::string::npos); 62 std::string::npos);
62 } 63 }
63 64
64 TEST_F(UserCollectorTest, EnableNoPatternFileAccess) { 65 TEST_F(UserCollectorTest, EnableNoPatternFileAccess) {
65 collector_.set_core_pattern_file("/does_not_exist"); 66 collector_.set_core_pattern_file("/does_not_exist");
66 ASSERT_FALSE(collector_.Enable()); 67 ASSERT_FALSE(collector_.Enable());
67 ASSERT_EQ(s_crashes, 0); 68 ASSERT_EQ(s_crashes, 0);
(...skipping 29 matching lines...) Expand all
97 ASSERT_FALSE(collector_.Disable()); 98 ASSERT_FALSE(collector_.Disable());
98 ASSERT_EQ(s_crashes, 0); 99 ASSERT_EQ(s_crashes, 0);
99 ASSERT_NE(logging_.log().find("Disabling user crash handling"), 100 ASSERT_NE(logging_.log().find("Disabling user crash handling"),
100 std::string::npos); 101 std::string::npos);
101 ASSERT_NE(logging_.log().find("Unable to write /does_not_exist"), 102 ASSERT_NE(logging_.log().find("Unable to write /does_not_exist"),
102 std::string::npos); 103 std::string::npos);
103 } 104 }
104 105
105 TEST_F(UserCollectorTest, HandleCrashWithoutMetrics) { 106 TEST_F(UserCollectorTest, HandleCrashWithoutMetrics) {
106 s_metrics = false; 107 s_metrics = false;
107 collector_.HandleCrash(10, 20, "foobar"); 108 collector_.HandleCrash(10, 20, NULL, "foobar");
108 ASSERT_NE(std::string::npos, 109 ASSERT_NE(std::string::npos,
109 logging_.log().find( 110 logging_.log().find(
110 "Received crash notification for foobar[20] sig 10")); 111 "Received crash notification for foobar[20] sig 10"));
111 ASSERT_EQ(s_crashes, 0); 112 ASSERT_EQ(s_crashes, 0);
112 } 113 }
113 114
114 TEST_F(UserCollectorTest, HandleNonChromeCrashWithMetrics) { 115 TEST_F(UserCollectorTest, HandleNonChromeCrashWithMetrics) {
115 s_metrics = true; 116 s_metrics = true;
116 collector_.HandleCrash(2, 5, "chromeos-wm"); 117 collector_.HandleCrash(2, 5, NULL, "chromeos-wm");
117 ASSERT_NE(std::string::npos, 118 ASSERT_NE(std::string::npos,
118 logging_.log().find( 119 logging_.log().find(
119 "Received crash notification for chromeos-wm[5] sig 2")); 120 "Received crash notification for chromeos-wm[5] sig 2"));
120 ASSERT_EQ(s_crashes, 1); 121 ASSERT_EQ(s_crashes, 1);
121 } 122 }
122 123
123 TEST_F(UserCollectorTest, HandleChromeCrashWithMetrics) { 124 TEST_F(UserCollectorTest, HandleChromeCrashWithMetrics) {
124 s_metrics = true; 125 s_metrics = true;
125 collector_.HandleCrash(2, 5, "chrome"); 126 collector_.HandleCrash(2, 5, NULL, "chrome");
126 ASSERT_NE(std::string::npos, 127 ASSERT_NE(std::string::npos,
127 logging_.log().find( 128 logging_.log().find(
128 "Received crash notification for chrome[5] sig 2")); 129 "Received crash notification for chrome[5] sig 2"));
129 ASSERT_NE(std::string::npos, 130 ASSERT_NE(std::string::npos,
130 logging_.log().find("(ignoring - chrome crash)")); 131 logging_.log().find("(ignoring - chrome crash)"));
131 ASSERT_EQ(s_crashes, 0); 132 ASSERT_EQ(s_crashes, 0);
132 } 133 }
133 134
134 TEST_F(UserCollectorTest, GetProcessPath) { 135 TEST_F(UserCollectorTest, GetProcessPath) {
135 FilePath path = collector_.GetProcessPath(100); 136 FilePath path = collector_.GetProcessPath(100);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 EXPECT_EQ(expectations[i].exists, 276 EXPECT_EQ(expectations[i].exists,
276 file_util::PathExists( 277 file_util::PathExists(
277 container_path.Append(expectations[i].name))); 278 container_path.Append(expectations[i].name)));
278 } 279 }
279 } 280 }
280 281
281 int main(int argc, char **argv) { 282 int main(int argc, char **argv) {
282 ::testing::InitGoogleTest(&argc, argv); 283 ::testing::InitGoogleTest(&argc, argv);
283 return RUN_ALL_TESTS(); 284 return RUN_ALL_TESTS();
284 } 285 }
OLDNEW
« user_collector.cc ('K') | « user_collector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698