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

Side by Side Diff: crash_collector_test.cc

Issue 4088003: crash-reporter: write conversion failure diagnostics into fake dmp files (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Add signature for error logs Created 10 years, 1 month 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
« no previous file with comments | « crash_collector.cc ('k') | crash_sender » ('j') | 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 "base/string_util.h" 8 #include "base/string_util.h"
9 #include "crash-reporter/crash_collector.h" 9 #include "crash-reporter/crash_collector.h"
10 #include "crash-reporter/system_logging_mock.h" 10 #include "crash-reporter/system_logging_mock.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 tm.tm_hour = 13; 113 tm.tm_hour = 13;
114 tm.tm_mday = 23; 114 tm.tm_mday = 23;
115 tm.tm_mon = 4; 115 tm.tm_mon = 4;
116 tm.tm_year = 110; 116 tm.tm_year = 110;
117 tm.tm_isdst = -1; 117 tm.tm_isdst = -1;
118 std::string basename = 118 std::string basename =
119 collector_.FormatDumpBasename("foo", mktime(&tm), 100); 119 collector_.FormatDumpBasename("foo", mktime(&tm), 100);
120 ASSERT_EQ("foo.20100523.135015.100", basename); 120 ASSERT_EQ("foo.20100523.135015.100", basename);
121 } 121 }
122 122
123 TEST_F(CrashCollectorTest, GetCrashPath) {
124 EXPECT_EQ("/var/spool/crash/myprog.20100101.1200.1234.core",
125 collector_.GetCrashPath(FilePath("/var/spool/crash"),
126 "myprog.20100101.1200.1234",
127 "core").value());
128 EXPECT_EQ("/home/chronos/user/crash/chrome.20100101.1200.1234.dmp",
129 collector_.GetCrashPath(FilePath("/home/chronos/user/crash"),
130 "chrome.20100101.1200.1234",
131 "dmp").value());
132 }
133
134
123 bool CrashCollectorTest::CheckHasCapacity() { 135 bool CrashCollectorTest::CheckHasCapacity() {
124 static const char kFullMessage[] = "Crash directory test already full"; 136 static const char kFullMessage[] = "Crash directory test already full";
125 bool has_capacity = collector_.CheckHasCapacity(test_dir_); 137 bool has_capacity = collector_.CheckHasCapacity(test_dir_);
126 bool has_message = (logging_.log().find(kFullMessage) != std::string::npos); 138 bool has_message = (logging_.log().find(kFullMessage) != std::string::npos);
127 EXPECT_EQ(has_message, !has_capacity); 139 EXPECT_EQ(has_message, !has_capacity);
128 return has_capacity; 140 return has_capacity;
129 } 141 }
130 142
131 TEST_F(CrashCollectorTest, CheckHasCapacityUsual) { 143 TEST_F(CrashCollectorTest, CheckHasCapacityUsual) {
132 // Test kMaxCrashDirectorySize - 1 non-meta files can be added. 144 // Test kMaxCrashDirectorySize - 1 non-meta files can be added.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 const char kPayload[] = "foo"; 243 const char kPayload[] = "foo";
232 ASSERT_TRUE( 244 ASSERT_TRUE(
233 file_util::WriteFile(payload_file, 245 file_util::WriteFile(payload_file,
234 kPayload, strlen(kPayload))); 246 kPayload, strlen(kPayload)));
235 collector_.AddCrashMetaData("foo", "bar"); 247 collector_.AddCrashMetaData("foo", "bar");
236 collector_.WriteCrashMetaData(meta_file, "kernel", payload_file.value()); 248 collector_.WriteCrashMetaData(meta_file, "kernel", payload_file.value());
237 EXPECT_TRUE(file_util::ReadFileToString(meta_file, &contents)); 249 EXPECT_TRUE(file_util::ReadFileToString(meta_file, &contents));
238 EXPECT_EQ("foo=bar\n" 250 EXPECT_EQ("foo=bar\n"
239 "exec_name=kernel\n" 251 "exec_name=kernel\n"
240 "ver=version\n" 252 "ver=version\n"
253 "payload=test/payload-file\n"
241 "payload_size=3\n" 254 "payload_size=3\n"
242 "done=1\n", contents); 255 "done=1\n", contents);
243 } 256 }
244 257
245 int main(int argc, char **argv) { 258 int main(int argc, char **argv) {
246 ::testing::InitGoogleTest(&argc, argv); 259 ::testing::InitGoogleTest(&argc, argv);
247 return RUN_ALL_TESTS(); 260 return RUN_ALL_TESTS();
248 } 261 }
OLDNEW
« no previous file with comments | « crash_collector.cc ('k') | crash_sender » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698