OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |