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

Unified Diff: user_collector_test.cc

Issue 5814001: crash-reporter: Capture and send recent update_engine logs when it crashes (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git@master
Patch Set: Respond to petkov review Created 10 years 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
« user_collector.cc ('K') | « 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 faa168912cf4fd2a94dae05e12ad550dd045424e..942123fcb08d33850422513319c751e0388a5781 100644
--- a/user_collector_test.cc
+++ b/user_collector_test.cc
@@ -32,8 +32,10 @@ class UserCollectorTest : public ::testing::Test {
IsMetrics,
&logging_,
false);
+ file_util::Delete(FilePath("test"), true);
mkdir("test", 0777);
collector_.set_core_pattern_file("test/core_pattern");
+ collector_.set_core_pipe_limit_file("test/core_pipe_limit");
pid_ = getpid();
}
protected:
@@ -53,12 +55,13 @@ class UserCollectorTest : public ::testing::Test {
TEST_F(UserCollectorTest, EnableOK) {
ASSERT_TRUE(collector_.Enable());
ExpectFileEquals("|/my/path --signal=%s --pid=%p", "test/core_pattern");
+ ExpectFileEquals("4", "test/core_pipe_limit");
ASSERT_EQ(s_crashes, 0);
ASSERT_NE(logging_.log().find("Enabling user crash handling"),
std::string::npos);
}
-TEST_F(UserCollectorTest, EnableNoFileAccess) {
+TEST_F(UserCollectorTest, EnableNoPatternFileAccess) {
collector_.set_core_pattern_file("/does_not_exist");
ASSERT_FALSE(collector_.Enable());
ASSERT_EQ(s_crashes, 0);
@@ -68,6 +71,19 @@ TEST_F(UserCollectorTest, EnableNoFileAccess) {
std::string::npos);
}
+TEST_F(UserCollectorTest, EnableNoPipeLimitFileAccess) {
+ collector_.set_core_pipe_limit_file("/does_not_exist");
+ ASSERT_FALSE(collector_.Enable());
+ ASSERT_EQ(s_crashes, 0);
+ // Core pattern should not be written if we cannot access the pipe limit
+ // or otherwise we may set a pattern that results in infinite recursion.
+ ASSERT_FALSE(file_util::PathExists(FilePath("test/core_pattern")));
+ ASSERT_NE(logging_.log().find("Enabling user crash handling"),
+ std::string::npos);
+ ASSERT_NE(logging_.log().find("Unable to write /does_not_exist"),
+ std::string::npos);
+}
+
TEST_F(UserCollectorTest, DisableOK) {
ASSERT_TRUE(collector_.Disable());
ExpectFileEquals("core", "test/core_pattern");
« 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