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

Side by Side Diff: kernel_collector_test.cc

Issue 3436029: crash-reporter: Send OS version at time of crash and related improvements (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: respond to petkov review Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « kernel_collector.cc ('k') | user_collector.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/kernel_collector.h" 9 #include "crash-reporter/kernel_collector.h"
10 #include "crash-reporter/system_logging_mock.h" 10 #include "crash-reporter/system_logging_mock.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::string dump; 88 std::string dump;
89 ASSERT_FALSE(file_util::PathExists(test_kcrash_)); 89 ASSERT_FALSE(file_util::PathExists(test_kcrash_));
90 WriteStringToFile(test_kcrash_, "something"); 90 WriteStringToFile(test_kcrash_, "something");
91 ASSERT_TRUE(collector_.LoadPreservedDump(&dump)); 91 ASSERT_TRUE(collector_.LoadPreservedDump(&dump));
92 ASSERT_EQ("something", dump); 92 ASSERT_EQ("something", dump);
93 ASSERT_TRUE(collector_.ClearPreservedDump()); 93 ASSERT_TRUE(collector_.ClearPreservedDump());
94 ASSERT_TRUE(collector_.LoadPreservedDump(&dump)); 94 ASSERT_TRUE(collector_.LoadPreservedDump(&dump));
95 ASSERT_EQ(KernelCollector::kClearingSequence, dump); 95 ASSERT_EQ(KernelCollector::kClearingSequence, dump);
96 } 96 }
97 97
98 TEST_F(KernelCollectorTest, GetKernelCrashPath) {
99 FilePath root("/var/spool/crash");
100 struct tm tm = {0};
101 tm.tm_sec = 15;
102 tm.tm_min = 50;
103 tm.tm_hour = 13;
104 tm.tm_mday = 23;
105 tm.tm_mon = 4;
106 tm.tm_year = 110;
107 tm.tm_isdst = -1;
108 FilePath path = collector_.GetKernelCrashPath(root, mktime(&tm));
109 ASSERT_EQ("/var/spool/crash/kernel.20100523.135015.0.kcrash",
110 path.value());
111 }
112
113 TEST_F(KernelCollectorTest, CollectPreservedFileMissing) { 98 TEST_F(KernelCollectorTest, CollectPreservedFileMissing) {
114 ASSERT_FALSE(collector_.Collect()); 99 ASSERT_FALSE(collector_.Collect());
115 ASSERT_NE(logging_.log().find("Unable to read test/kcrash"), 100 ASSERT_NE(logging_.log().find("Unable to read test/kcrash"),
116 std::string::npos); 101 std::string::npos);
117 ASSERT_EQ(0, s_crashes); 102 ASSERT_EQ(0, s_crashes);
118 } 103 }
119 104
120 TEST_F(KernelCollectorTest, CollectNoCrash) { 105 TEST_F(KernelCollectorTest, CollectNoCrash) {
121 WriteStringToFile(test_kcrash_, ""); 106 WriteStringToFile(test_kcrash_, "");
122 ASSERT_FALSE(collector_.Collect()); 107 ASSERT_FALSE(collector_.Collect());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ASSERT_TRUE(file_util::ReadFileToString(FilePath(filename), &contents)); 162 ASSERT_TRUE(file_util::ReadFileToString(FilePath(filename), &contents));
178 ASSERT_EQ("something", contents); 163 ASSERT_EQ("something", contents);
179 164
180 CheckPreservedDumpClear(); 165 CheckPreservedDumpClear();
181 } 166 }
182 167
183 int main(int argc, char **argv) { 168 int main(int argc, char **argv) {
184 ::testing::InitGoogleTest(&argc, argv); 169 ::testing::InitGoogleTest(&argc, argv);
185 return RUN_ALL_TESTS(); 170 return RUN_ALL_TESTS();
186 } 171 }
OLDNEW
« no previous file with comments | « kernel_collector.cc ('k') | user_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698