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

Side by Side Diff: crash_collector_test.cc

Issue 4018008: crash-reporter: Generate kernel crash signatures for server-side grouping of similar crashes (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Respond to petkov review 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_reporter.cc » ('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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 i = dictionary.find("f g"); 211 i = dictionary.find("f g");
212 EXPECT_TRUE(i != dictionary.end() && i->second == "h"); 212 EXPECT_TRUE(i != dictionary.end() && i->second == "h");
213 i = dictionary.find("i"); 213 i = dictionary.find("i");
214 EXPECT_TRUE(i != dictionary.end() && i->second == "j"); 214 EXPECT_TRUE(i != dictionary.end() && i->second == "j");
215 i = dictionary.find(""); 215 i = dictionary.find("");
216 EXPECT_TRUE(i != dictionary.end() && i->second == "k"); 216 EXPECT_TRUE(i != dictionary.end() && i->second == "k");
217 i = dictionary.find("l"); 217 i = dictionary.find("l");
218 EXPECT_TRUE(i != dictionary.end() && i->second == ""); 218 EXPECT_TRUE(i != dictionary.end() && i->second == "");
219 } 219 }
220 220
221 TEST_F(CrashCollectorTest, MetaData) {
222 FilePath meta_file = test_dir_.Append("generated.meta");
223 FilePath lsb_release = test_dir_.Append("lsb-release");
224 FilePath payload_file = test_dir_.Append("payload-file");
225 std::string contents;
226 collector_.lsb_release_ = lsb_release.value().c_str();
227 const char kLsbContents[] = "CHROMEOS_RELEASE_VERSION=version\n";
228 ASSERT_TRUE(
229 file_util::WriteFile(lsb_release,
230 kLsbContents, strlen(kLsbContents)));
231 const char kPayload[] = "foo";
232 ASSERT_TRUE(
233 file_util::WriteFile(payload_file,
234 kPayload, strlen(kPayload)));
235 collector_.AddCrashMetaData("foo", "bar");
236 collector_.WriteCrashMetaData(meta_file, "kernel", payload_file.value());
237 EXPECT_TRUE(file_util::ReadFileToString(meta_file, &contents));
238 EXPECT_EQ("foo=bar\n"
239 "exec_name=kernel\n"
240 "ver=version\n"
241 "payload_size=3\n"
242 "done=1\n", contents);
243 }
244
221 int main(int argc, char **argv) { 245 int main(int argc, char **argv) {
222 ::testing::InitGoogleTest(&argc, argv); 246 ::testing::InitGoogleTest(&argc, argv);
223 return RUN_ALL_TESTS(); 247 return RUN_ALL_TESTS();
224 } 248 }
OLDNEW
« no previous file with comments | « crash_collector.cc ('k') | crash_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698