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

Unified Diff: user_collector_test.cc

Issue 6480009: crash-reporter: when exe symlink read fails send diags and still ignore chrome crashes (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crash-reporter.git@master
Patch Set: Created 9 years, 10 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 | « user_collector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: user_collector_test.cc
diff --git a/user_collector_test.cc b/user_collector_test.cc
index 53e227cf01f9de8b78abe6529df2a03226c1c7d5..9a1d687efddb9e0e7959848e462ad35e42faf02a 100644
--- a/user_collector_test.cc
+++ b/user_collector_test.cc
@@ -158,6 +158,17 @@ TEST_F(UserCollectorTest, HandleChromeCrashWithMetrics) {
ASSERT_EQ(s_crashes, 0);
}
+TEST_F(UserCollectorTest, HandleSuppliedChromeCrashWithMetrics) {
+ s_metrics = true;
+ collector_.HandleCrash("0:2:chrome", NULL);
+ ASSERT_NE(std::string::npos,
+ logging_.log().find(
+ "Received crash notification for supplied_chrome[0] sig 2"));
+ ASSERT_NE(std::string::npos,
+ logging_.log().find("(ignoring - chrome crash)"));
+ ASSERT_EQ(s_crashes, 0);
+}
+
TEST_F(UserCollectorTest, GetProcessPath) {
FilePath path = collector_.GetProcessPath(100);
ASSERT_EQ("/proc/100", path.value());
@@ -167,7 +178,9 @@ TEST_F(UserCollectorTest, GetSymlinkTarget) {
FilePath result;
ASSERT_FALSE(collector_.GetSymlinkTarget(FilePath("/does_not_exist"),
&result));
-
+ ASSERT_NE(std::string::npos,
+ logging_.log().find(
+ "Readlink failed on /does_not_exist with 2"));
std::string long_link;
for (int i = 0; i < 50; ++i)
long_link += "0123456789";
@@ -185,6 +198,29 @@ TEST_F(UserCollectorTest, GetSymlinkTarget) {
}
}
+TEST_F(UserCollectorTest, GetExecutableBaseNameFromPid) {
+ std::string base_name;
+ EXPECT_FALSE(collector_.GetExecutableBaseNameFromPid(0, &base_name));
+ EXPECT_NE(std::string::npos,
+ logging_.log().find(
+ "Readlink failed on /proc/0/exe with 2"));
+ EXPECT_NE(std::string::npos,
+ logging_.log().find(
+ "GetSymlinkTarget failed - Path "
+ "/proc/0 DirectoryExists: 0"));
+ EXPECT_NE(std::string::npos,
+ logging_.log().find(
+ "stat /proc/0/exe failed: -1 2"));
+
+ logging_.clear();
+ pid_t my_pid = getpid();
+ EXPECT_TRUE(collector_.GetExecutableBaseNameFromPid(my_pid, &base_name));
+ EXPECT_EQ(std::string::npos,
+ logging_.log().find(
+ "Readlink failed"));
+ EXPECT_EQ("user_collector_test", base_name);
+}
+
TEST_F(UserCollectorTest, GetIdFromStatus) {
int id = 1;
EXPECT_FALSE(collector_.GetIdFromStatus(UserCollector::kUserId,
« no previous file with comments | « user_collector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698