OLD | NEW |
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 "gflags/gflags.h" | 10 #include "gflags/gflags.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 logging_.clear(); | 147 logging_.clear(); |
148 args.clear(); | 148 args.clear(); |
149 args.push_back(kBinBash); | 149 args.push_back(kBinBash); |
150 args.push_back("-c"); | 150 args.push_back("-c"); |
151 args.push_back("kill -SEGV $$"); | 151 args.push_back("kill -SEGV $$"); |
152 EXPECT_EQ(-1, collector_.ForkExecAndPipe(args, output_file)); | 152 EXPECT_EQ(-1, collector_.ForkExecAndPipe(args, output_file)); |
153 EXPECT_NE(std::string::npos, | 153 EXPECT_NE(std::string::npos, |
154 logging_.log().find("Process did not exit normally")); | 154 logging_.log().find("Process did not exit normally")); |
155 } | 155 } |
156 | 156 |
157 TEST_F(UserCollectorTest, HandleCrashWithoutMetrics) { | 157 TEST_F(UserCollectorTest, HandleNonChromeCrashWithoutMetrics) { |
158 s_metrics = false; | 158 s_metrics = false; |
159 collector_.HandleCrash(10, 20, "foobar"); | 159 collector_.HandleCrash(10, 20, "foobar"); |
160 ASSERT_NE(logging_.log().find( | 160 ASSERT_NE(std::string::npos, |
161 "Received crash notification for foobar[20] sig 10"), | 161 logging_.log().find( |
162 std::string::npos); | 162 "Received crash notification for foobar[20] sig 10")); |
163 ASSERT_EQ(s_crashes, 0); | 163 ASSERT_EQ(s_crashes, 0); |
164 } | 164 } |
165 | 165 |
166 TEST_F(UserCollectorTest, HandleCrashWithMetrics) { | 166 TEST_F(UserCollectorTest, HandleNonChromeCrashWithMetrics) { |
| 167 s_metrics = true; |
| 168 collector_.HandleCrash(2, 5, "chromeos-wm"); |
| 169 ASSERT_NE(std::string::npos, |
| 170 logging_.log().find( |
| 171 "Received crash notification for chromeos-wm[5] sig 2")); |
| 172 ASSERT_EQ(s_crashes, 1); |
| 173 } |
| 174 |
| 175 TEST_F(UserCollectorTest, HandleChromeCrashWithMetrics) { |
167 s_metrics = true; | 176 s_metrics = true; |
168 collector_.HandleCrash(2, 5, "chrome"); | 177 collector_.HandleCrash(2, 5, "chrome"); |
169 ASSERT_NE(logging_.log().find( | 178 ASSERT_NE(std::string::npos, |
170 "Received crash notification for chrome[5] sig 2"), | 179 logging_.log().find( |
171 std::string::npos); | 180 "Received crash notification for chrome[5] sig 2")); |
172 ASSERT_EQ(s_crashes, 1); | 181 ASSERT_NE(std::string::npos, |
| 182 logging_.log().find("(ignoring - chrome crash)")); |
| 183 ASSERT_EQ(s_crashes, 0); |
173 } | 184 } |
174 | 185 |
175 TEST_F(UserCollectorTest, GetProcessPath) { | 186 TEST_F(UserCollectorTest, GetProcessPath) { |
176 FilePath path = collector_.GetProcessPath(100); | 187 FilePath path = collector_.GetProcessPath(100); |
177 ASSERT_EQ("/proc/100", path.value()); | 188 ASSERT_EQ("/proc/100", path.value()); |
178 } | 189 } |
179 | 190 |
180 TEST_F(UserCollectorTest, GetSymlinkTarget) { | 191 TEST_F(UserCollectorTest, GetSymlinkTarget) { |
181 FilePath result; | 192 FilePath result; |
182 ASSERT_FALSE(collector_.GetSymlinkTarget(FilePath("/does_not_exist"), | 193 ASSERT_FALSE(collector_.GetSymlinkTarget(FilePath("/does_not_exist"), |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 EXPECT_EQ(expectations[i].exists, | 327 EXPECT_EQ(expectations[i].exists, |
317 file_util::PathExists( | 328 file_util::PathExists( |
318 container_path.Append(expectations[i].name))); | 329 container_path.Append(expectations[i].name))); |
319 } | 330 } |
320 } | 331 } |
321 | 332 |
322 int main(int argc, char **argv) { | 333 int main(int argc, char **argv) { |
323 ::testing::InitGoogleTest(&argc, argv); | 334 ::testing::InitGoogleTest(&argc, argv); |
324 return RUN_ALL_TESTS(); | 335 return RUN_ALL_TESTS(); |
325 } | 336 } |
OLD | NEW |