| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 "components/browser_watcher/postmortem_report_collector.h" | 5 #include "components/browser_watcher/postmortem_report_collector.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 MOCK_METHOD1(DeleteReport, | 104 MOCK_METHOD1(DeleteReport, |
| 105 CrashReportDatabase::OperationStatus(const UUID& uuid)); | 105 CrashReportDatabase::OperationStatus(const UUID& uuid)); |
| 106 MOCK_METHOD1(RequestUpload, | 106 MOCK_METHOD1(RequestUpload, |
| 107 CrashReportDatabase::OperationStatus(const UUID& uuid)); | 107 CrashReportDatabase::OperationStatus(const UUID& uuid)); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 // Used for testing CollectAndSubmitForUpload. | 110 // Used for testing CollectAndSubmitForUpload. |
| 111 class MockPostmortemReportCollector : public PostmortemReportCollector { | 111 class MockPostmortemReportCollector : public PostmortemReportCollector { |
| 112 public: | 112 public: |
| 113 MockPostmortemReportCollector() | 113 MockPostmortemReportCollector() |
| 114 : PostmortemReportCollector(kProductName, kVersionNumber, kChannelName) {} | 114 : PostmortemReportCollector(kProductName, |
| 115 kVersionNumber, |
| 116 kChannelName, |
| 117 nullptr) {} |
| 115 | 118 |
| 116 // A function that returns a unique_ptr cannot be mocked, so mock a function | 119 // A function that returns a unique_ptr cannot be mocked, so mock a function |
| 117 // that returns a raw pointer instead. | 120 // that returns a raw pointer instead. |
| 118 CollectionStatus Collect(const base::FilePath& debug_state_file, | 121 CollectionStatus Collect(const base::FilePath& debug_state_file, |
| 119 std::unique_ptr<StabilityReport>* report) override { | 122 std::unique_ptr<StabilityReport>* report) override { |
| 120 DCHECK_NE(nullptr, report); | 123 DCHECK_NE(nullptr, report); |
| 121 report->reset(CollectRaw(debug_state_file)); | 124 report->reset(CollectRaw(debug_state_file)); |
| 122 return SUCCESS; | 125 return SUCCESS; |
| 123 } | 126 } |
| 124 | 127 |
| 125 MOCK_METHOD3(GetDebugStateFilePaths, | 128 MOCK_METHOD3(GetDebugStateFilePaths, |
| 126 std::vector<base::FilePath>( | 129 std::vector<base::FilePath>( |
| 127 const base::FilePath& debug_info_dir, | 130 const base::FilePath& debug_info_dir, |
| 128 const base::FilePath::StringType& debug_file_pattern, | 131 const base::FilePath::StringType& debug_file_pattern, |
| 129 const std::set<base::FilePath>&)); | 132 const std::set<base::FilePath>&)); |
| 130 MOCK_METHOD1(CollectRaw, StabilityReport*(const base::FilePath&)); | 133 MOCK_METHOD1(CollectRaw, StabilityReport*(const base::FilePath&)); |
| 131 MOCK_METHOD4(WriteReportToMinidump, | 134 MOCK_METHOD4(WriteReportToMinidump, |
| 132 bool(StabilityReport* report, | 135 bool(StabilityReport* report, |
| 133 const crashpad::UUID& client_id, | 136 const crashpad::UUID& client_id, |
| 134 const crashpad::UUID& report_id, | 137 const crashpad::UUID& report_id, |
| 135 base::PlatformFile minidump_file)); | 138 base::PlatformFile minidump_file)); |
| 136 }; | 139 }; |
| 137 | 140 |
| 141 class MockSystemSessionAnalyzer : public SystemSessionAnalyzer { |
| 142 public: |
| 143 MockSystemSessionAnalyzer() : SystemSessionAnalyzer(nullptr) {} |
| 144 MOCK_METHOD1(IsSessionUnclean, Status(base::Time timestamp)); |
| 145 }; |
| 146 |
| 138 // Checks if two proto messages are the same based on their serializations. Note | 147 // Checks if two proto messages are the same based on their serializations. Note |
| 139 // this only works if serialization is deterministic, which is not guaranteed. | 148 // this only works if serialization is deterministic, which is not guaranteed. |
| 140 // In practice, serialization is deterministic (even for protocol buffers with | 149 // In practice, serialization is deterministic (even for protocol buffers with |
| 141 // maps) and such matchers are common in the Chromium code base. Also note that | 150 // maps) and such matchers are common in the Chromium code base. Also note that |
| 142 // in the context of this test, false positive matches are the problem and these | 151 // in the context of this test, false positive matches are the problem and these |
| 143 // are not possible (otherwise serialization would be ambiguous). False | 152 // are not possible (otherwise serialization would be ambiguous). False |
| 144 // negatives would lead to test failure and developer action. Alternatives are: | 153 // negatives would lead to test failure and developer action. Alternatives are: |
| 145 // 1) a generic matcher (likely not possible without reflections, missing from | 154 // 1) a generic matcher (likely not possible without reflections, missing from |
| 146 // lite runtime), 2) a specialized matcher or 3) implementing deterministic | 155 // lite runtime), 2) a specialized matcher or 3) implementing deterministic |
| 147 // serialization. | 156 // serialization. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 ASSERT_NE(file.get(), nullptr); | 287 ASSERT_NE(file.get(), nullptr); |
| 279 expected_paths.push_back(path); | 288 expected_paths.push_back(path); |
| 280 | 289 |
| 281 // Does not match the pattern. | 290 // Does not match the pattern. |
| 282 path = temp_dir.GetPath().AppendASCII("bar.baz"); | 291 path = temp_dir.GetPath().AppendASCII("bar.baz"); |
| 283 file.reset(base::OpenFile(path, "w")); | 292 file.reset(base::OpenFile(path, "w")); |
| 284 ASSERT_NE(file.get(), nullptr); | 293 ASSERT_NE(file.get(), nullptr); |
| 285 } | 294 } |
| 286 | 295 |
| 287 PostmortemReportCollector collector(kProductName, kVersionNumber, | 296 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 288 kChannelName); | 297 kChannelName, nullptr); |
| 289 EXPECT_THAT( | 298 EXPECT_THAT( |
| 290 collector.GetDebugStateFilePaths( | 299 collector.GetDebugStateFilePaths( |
| 291 temp_dir.GetPath(), FILE_PATH_LITERAL("foo*.pma"), excluded_paths), | 300 temp_dir.GetPath(), FILE_PATH_LITERAL("foo*.pma"), excluded_paths), |
| 292 testing::UnorderedElementsAreArray(expected_paths)); | 301 testing::UnorderedElementsAreArray(expected_paths)); |
| 293 } | 302 } |
| 294 | 303 |
| 295 TEST(PostmortemReportCollectorTest, CollectEmptyFile) { | 304 TEST(PostmortemReportCollectorTest, CollectEmptyFile) { |
| 296 // Create an empty file. | 305 // Create an empty file. |
| 297 base::ScopedTempDir temp_dir; | 306 base::ScopedTempDir temp_dir; |
| 298 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 307 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 299 base::FilePath file_path = temp_dir.GetPath().AppendASCII("empty.pma"); | 308 base::FilePath file_path = temp_dir.GetPath().AppendASCII("empty.pma"); |
| 300 { | 309 { |
| 301 base::ScopedFILE file(base::OpenFile(file_path, "w")); | 310 base::ScopedFILE file(base::OpenFile(file_path, "w")); |
| 302 ASSERT_NE(file.get(), nullptr); | 311 ASSERT_NE(file.get(), nullptr); |
| 303 } | 312 } |
| 304 ASSERT_TRUE(PathExists(file_path)); | 313 ASSERT_TRUE(PathExists(file_path)); |
| 305 | 314 |
| 306 // Validate collection: an empty file cannot suppport an analyzer. | 315 // Validate collection: an empty file cannot suppport an analyzer. |
| 307 PostmortemReportCollector collector(kProductName, kVersionNumber, | 316 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 308 kChannelName); | 317 kChannelName, nullptr); |
| 309 std::unique_ptr<StabilityReport> report; | 318 std::unique_ptr<StabilityReport> report; |
| 310 ASSERT_EQ(PostmortemReportCollector::ANALYZER_CREATION_FAILED, | 319 ASSERT_EQ(PostmortemReportCollector::ANALYZER_CREATION_FAILED, |
| 311 collector.Collect(file_path, &report)); | 320 collector.Collect(file_path, &report)); |
| 312 } | 321 } |
| 313 | 322 |
| 314 TEST(PostmortemReportCollectorTest, CollectRandomFile) { | 323 TEST(PostmortemReportCollectorTest, CollectRandomFile) { |
| 315 // Create a file with content we don't expect to be valid for a debug file. | 324 // Create a file with content we don't expect to be valid for a debug file. |
| 316 base::ScopedTempDir temp_dir; | 325 base::ScopedTempDir temp_dir; |
| 317 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 326 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 318 base::FilePath file_path = | 327 base::FilePath file_path = |
| 319 temp_dir.GetPath().AppendASCII("invalid_content.pma"); | 328 temp_dir.GetPath().AppendASCII("invalid_content.pma"); |
| 320 { | 329 { |
| 321 base::ScopedFILE file(base::OpenFile(file_path, "w")); | 330 base::ScopedFILE file(base::OpenFile(file_path, "w")); |
| 322 ASSERT_NE(file.get(), nullptr); | 331 ASSERT_NE(file.get(), nullptr); |
| 323 // Assuming this size is greater than the minimum size of a debug file. | 332 // Assuming this size is greater than the minimum size of a debug file. |
| 324 std::vector<uint8_t> data(1024); | 333 std::vector<uint8_t> data(1024); |
| 325 for (size_t i = 0; i < data.size(); ++i) | 334 for (size_t i = 0; i < data.size(); ++i) |
| 326 data[i] = i % UINT8_MAX; | 335 data[i] = i % UINT8_MAX; |
| 327 ASSERT_EQ(data.size(), | 336 ASSERT_EQ(data.size(), |
| 328 fwrite(&data.at(0), sizeof(uint8_t), data.size(), file.get())); | 337 fwrite(&data.at(0), sizeof(uint8_t), data.size(), file.get())); |
| 329 } | 338 } |
| 330 ASSERT_TRUE(PathExists(file_path)); | 339 ASSERT_TRUE(PathExists(file_path)); |
| 331 | 340 |
| 332 // Validate collection: random content appears as though there is not | 341 // Validate collection: random content appears as though there is not |
| 333 // stability data. | 342 // stability data. |
| 334 PostmortemReportCollector collector(kProductName, kVersionNumber, | 343 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 335 kChannelName); | 344 kChannelName, nullptr); |
| 336 std::unique_ptr<StabilityReport> report; | 345 std::unique_ptr<StabilityReport> report; |
| 337 ASSERT_EQ(PostmortemReportCollector::DEBUG_FILE_NO_DATA, | 346 ASSERT_EQ(PostmortemReportCollector::DEBUG_FILE_NO_DATA, |
| 338 collector.Collect(file_path, &report)); | 347 collector.Collect(file_path, &report)); |
| 339 } | 348 } |
| 340 | 349 |
| 341 namespace { | 350 namespace { |
| 342 | 351 |
| 343 // Parameters for the activity tracking. | 352 // Parameters for the activity tracking. |
| 344 const size_t kFileSize = 2 * 1024; | 353 const size_t kFileSize = 2 * 1024; |
| 345 const int kStackDepth = 5; | 354 const int kStackDepth = 5; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // Add some user data. | 461 // Add some user data. |
| 453 ActivityTrackerMemoryAllocator user_data_allocator( | 462 ActivityTrackerMemoryAllocator user_data_allocator( |
| 454 allocator_.get(), GlobalActivityTracker::kTypeIdUserDataRecord, | 463 allocator_.get(), GlobalActivityTracker::kTypeIdUserDataRecord, |
| 455 GlobalActivityTracker::kTypeIdUserDataRecordFree, 1024U, 10U, false); | 464 GlobalActivityTracker::kTypeIdUserDataRecordFree, 1024U, 10U, false); |
| 456 std::unique_ptr<ActivityUserData> user_data = | 465 std::unique_ptr<ActivityUserData> user_data = |
| 457 tracker_->GetUserData(activity_id, &user_data_allocator); | 466 tracker_->GetUserData(activity_id, &user_data_allocator); |
| 458 user_data->SetInt("some_int", 42); | 467 user_data->SetInt("some_int", 42); |
| 459 | 468 |
| 460 // Validate collection returns the expected report. | 469 // Validate collection returns the expected report. |
| 461 PostmortemReportCollector collector(kProductName, kVersionNumber, | 470 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 462 kChannelName); | 471 kChannelName, nullptr); |
| 463 std::unique_ptr<StabilityReport> report; | 472 std::unique_ptr<StabilityReport> report; |
| 464 ASSERT_EQ(PostmortemReportCollector::SUCCESS, | 473 ASSERT_EQ(PostmortemReportCollector::SUCCESS, |
| 465 collector.Collect(debug_file_path(), &report)); | 474 collector.Collect(debug_file_path(), &report)); |
| 466 ASSERT_NE(nullptr, report); | 475 ASSERT_NE(nullptr, report); |
| 467 | 476 |
| 468 // Validate the report. | 477 // Validate the report. |
| 469 ASSERT_EQ(1, report->process_states_size()); | 478 ASSERT_EQ(1, report->process_states_size()); |
| 470 const ProcessState& process_state = report->process_states(0); | 479 const ProcessState& process_state = report->process_states(0); |
| 471 EXPECT_EQ(base::GetCurrentProcId(), process_state.process_id()); | 480 EXPECT_EQ(base::GetCurrentProcId(), process_state.process_id()); |
| 472 ASSERT_EQ(1, process_state.threads_size()); | 481 ASSERT_EQ(1, process_state.threads_size()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest, | 560 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest, |
| 552 LogCollection) { | 561 LogCollection) { |
| 553 // Record some log messages. | 562 // Record some log messages. |
| 554 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, | 563 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, |
| 555 "", 3); | 564 "", 3); |
| 556 GlobalActivityTracker::Get()->RecordLogMessage("hello world"); | 565 GlobalActivityTracker::Get()->RecordLogMessage("hello world"); |
| 557 GlobalActivityTracker::Get()->RecordLogMessage("foo bar"); | 566 GlobalActivityTracker::Get()->RecordLogMessage("foo bar"); |
| 558 | 567 |
| 559 // Collect the stability report. | 568 // Collect the stability report. |
| 560 PostmortemReportCollector collector(kProductName, kVersionNumber, | 569 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 561 kChannelName); | 570 kChannelName, nullptr); |
| 562 std::unique_ptr<StabilityReport> report; | 571 std::unique_ptr<StabilityReport> report; |
| 563 ASSERT_EQ(PostmortemReportCollector::SUCCESS, | 572 ASSERT_EQ(PostmortemReportCollector::SUCCESS, |
| 564 collector.Collect(debug_file_path(), &report)); | 573 collector.Collect(debug_file_path(), &report)); |
| 565 ASSERT_NE(nullptr, report); | 574 ASSERT_NE(nullptr, report); |
| 566 | 575 |
| 567 // Validate the report's log content. | 576 // Validate the report's log content. |
| 568 ASSERT_EQ(2, report->log_messages_size()); | 577 ASSERT_EQ(2, report->log_messages_size()); |
| 569 ASSERT_EQ("hello world", report->log_messages(0)); | 578 ASSERT_EQ("hello world", report->log_messages(0)); |
| 570 ASSERT_EQ("foo bar", report->log_messages(1)); | 579 ASSERT_EQ("foo bar", report->log_messages(1)); |
| 571 } | 580 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 583 global_data.SetString("string", "bar"); | 592 global_data.SetString("string", "bar"); |
| 584 global_data.SetChar("char", '9'); | 593 global_data.SetChar("char", '9'); |
| 585 global_data.SetInt("int", -9999); | 594 global_data.SetInt("int", -9999); |
| 586 global_data.SetUint("uint", 9999); | 595 global_data.SetUint("uint", 9999); |
| 587 global_data.SetBool("bool", true); | 596 global_data.SetBool("bool", true); |
| 588 global_data.SetReference("ref", string1, strlen(string1)); | 597 global_data.SetReference("ref", string1, strlen(string1)); |
| 589 global_data.SetStringReference("sref", string2); | 598 global_data.SetStringReference("sref", string2); |
| 590 | 599 |
| 591 // Collect the stability report. | 600 // Collect the stability report. |
| 592 PostmortemReportCollector collector(kProductName, kVersionNumber, | 601 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 593 kChannelName); | 602 kChannelName, nullptr); |
| 594 std::unique_ptr<StabilityReport> report; | 603 std::unique_ptr<StabilityReport> report; |
| 595 ASSERT_EQ(PostmortemReportCollector::SUCCESS, | 604 ASSERT_EQ(PostmortemReportCollector::SUCCESS, |
| 596 collector.Collect(debug_file_path(), &report)); | 605 collector.Collect(debug_file_path(), &report)); |
| 597 ASSERT_NE(nullptr, report); | 606 ASSERT_NE(nullptr, report); |
| 598 | 607 |
| 599 // Validate the report's user data. | 608 // Validate the report's user data. |
| 600 const auto& collected_data = report->global_data(); | 609 const auto& collected_data = report->global_data(); |
| 601 ASSERT_EQ(12U, collected_data.size()); | 610 ASSERT_EQ(12U, collected_data.size()); |
| 602 | 611 |
| 603 ASSERT_TRUE(base::ContainsKey(collected_data, "raw")); | 612 ASSERT_TRUE(base::ContainsKey(collected_data, "raw")); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // Record some data. | 663 // Record some data. |
| 655 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, | 664 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, |
| 656 "", 3); | 665 "", 3); |
| 657 ActivityUserData& global_data = GlobalActivityTracker::Get()->global_data(); | 666 ActivityUserData& global_data = GlobalActivityTracker::Get()->global_data(); |
| 658 global_data.SetString("string", "bar"); | 667 global_data.SetString("string", "bar"); |
| 659 global_data.SetString("FieldTrial.string", "bar"); | 668 global_data.SetString("FieldTrial.string", "bar"); |
| 660 global_data.SetString("FieldTrial.foo", "bar"); | 669 global_data.SetString("FieldTrial.foo", "bar"); |
| 661 | 670 |
| 662 // Collect the stability report. | 671 // Collect the stability report. |
| 663 PostmortemReportCollector collector(kProductName, kVersionNumber, | 672 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 664 kChannelName); | 673 kChannelName, nullptr); |
| 665 std::unique_ptr<StabilityReport> report; | 674 std::unique_ptr<StabilityReport> report; |
| 666 ASSERT_EQ(PostmortemReportCollector::SUCCESS, | 675 ASSERT_EQ(PostmortemReportCollector::SUCCESS, |
| 667 collector.Collect(debug_file_path(), &report)); | 676 collector.Collect(debug_file_path(), &report)); |
| 668 ASSERT_NE(nullptr, report); | 677 ASSERT_NE(nullptr, report); |
| 669 | 678 |
| 670 // Validate the report's experiment and global data. | 679 // Validate the report's experiment and global data. |
| 671 ASSERT_EQ(2, report->field_trials_size()); | 680 ASSERT_EQ(2, report->field_trials_size()); |
| 672 EXPECT_NE(0U, report->field_trials(0).name_id()); | 681 EXPECT_NE(0U, report->field_trials(0).name_id()); |
| 673 EXPECT_NE(0U, report->field_trials(0).group_id()); | 682 EXPECT_NE(0U, report->field_trials(0).group_id()); |
| 674 EXPECT_NE(0U, report->field_trials(1).name_id()); | 683 EXPECT_NE(0U, report->field_trials(1).name_id()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 697 crashpad::UUID debug_uuid; | 706 crashpad::UUID debug_uuid; |
| 698 debug_uuid.InitializeFromString("11223344-5566-7788-abcd-0123456789ab"); | 707 debug_uuid.InitializeFromString("11223344-5566-7788-abcd-0123456789ab"); |
| 699 memcpy(module_info.identifier, &debug_uuid, sizeof(module_info.identifier)); | 708 memcpy(module_info.identifier, &debug_uuid, sizeof(module_info.identifier)); |
| 700 module_info.file = "foo"; | 709 module_info.file = "foo"; |
| 701 module_info.debug_file = "bar"; | 710 module_info.debug_file = "bar"; |
| 702 | 711 |
| 703 GlobalActivityTracker::Get()->RecordModuleInfo(module_info); | 712 GlobalActivityTracker::Get()->RecordModuleInfo(module_info); |
| 704 | 713 |
| 705 // Collect the stability report. | 714 // Collect the stability report. |
| 706 PostmortemReportCollector collector(kProductName, kVersionNumber, | 715 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 707 kChannelName); | 716 kChannelName, nullptr); |
| 708 std::unique_ptr<StabilityReport> report; | 717 std::unique_ptr<StabilityReport> report; |
| 709 ASSERT_EQ(PostmortemReportCollector::SUCCESS, | 718 ASSERT_EQ(PostmortemReportCollector::SUCCESS, |
| 710 collector.Collect(debug_file_path(), &report)); | 719 collector.Collect(debug_file_path(), &report)); |
| 711 ASSERT_NE(nullptr, report); | 720 ASSERT_NE(nullptr, report); |
| 712 | 721 |
| 713 // Validate the report's modules content. | 722 // Validate the report's modules content. |
| 714 ASSERT_EQ(1, report->process_states_size()); | 723 ASSERT_EQ(1, report->process_states_size()); |
| 715 const ProcessState& process_state = report->process_states(0); | 724 const ProcessState& process_state = report->process_states(0); |
| 716 ASSERT_EQ(1, process_state.modules_size()); | 725 ASSERT_EQ(1, process_state.modules_size()); |
| 717 | 726 |
| 718 const CodeModule collected_module = process_state.modules(0); | 727 const CodeModule collected_module = process_state.modules(0); |
| 719 EXPECT_EQ(module_info.address, | 728 EXPECT_EQ(module_info.address, |
| 720 static_cast<uintptr_t>(collected_module.base_address())); | 729 static_cast<uintptr_t>(collected_module.base_address())); |
| 721 EXPECT_EQ(module_info.size, static_cast<size_t>(collected_module.size())); | 730 EXPECT_EQ(module_info.size, static_cast<size_t>(collected_module.size())); |
| 722 EXPECT_EQ(module_info.file, collected_module.code_file()); | 731 EXPECT_EQ(module_info.file, collected_module.code_file()); |
| 723 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier()); | 732 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier()); |
| 724 EXPECT_EQ(module_info.debug_file, collected_module.debug_file()); | 733 EXPECT_EQ(module_info.debug_file, collected_module.debug_file()); |
| 725 EXPECT_EQ("1122334455667788ABCD0123456789AB1", | 734 EXPECT_EQ("1122334455667788ABCD0123456789AB1", |
| 726 collected_module.debug_identifier()); | 735 collected_module.debug_identifier()); |
| 727 EXPECT_EQ("", collected_module.version()); | 736 EXPECT_EQ("", collected_module.version()); |
| 728 EXPECT_EQ(0LL, collected_module.shrink_down_delta()); | 737 EXPECT_EQ(0LL, collected_module.shrink_down_delta()); |
| 729 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded()); | 738 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded()); |
| 730 } | 739 } |
| 731 | 740 |
| 741 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest, |
| 742 SystemStateTest) { |
| 743 // Setup. |
| 744 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, |
| 745 "", 3); |
| 746 ActivityUserData& global_data = GlobalActivityTracker::Get()->global_data(); |
| 747 global_data.SetInt(kStabilityStartTimestamp, 12345LL); |
| 748 |
| 749 // Collect. |
| 750 std::unique_ptr<MockSystemSessionAnalyzer> analyzer( |
| 751 new MockSystemSessionAnalyzer()); |
| 752 EXPECT_CALL(*analyzer, |
| 753 IsSessionUnclean(base::Time::FromInternalValue(12345LL))) |
| 754 .Times(1) |
| 755 .WillOnce(Return(SystemSessionAnalyzer::CLEAN)); |
| 756 PostmortemReportCollector collector(kProductName, kVersionNumber, |
| 757 kChannelName, std::move(analyzer)); |
| 758 std::unique_ptr<StabilityReport> report; |
| 759 ASSERT_EQ(PostmortemReportCollector::SUCCESS, |
| 760 collector.Collect(debug_file_path(), &report)); |
| 761 ASSERT_NE(nullptr, report); |
| 762 |
| 763 // Validate the report. |
| 764 ASSERT_EQ(SystemState::CLEAN, report->system_state().session_state()); |
| 765 } |
| 766 |
| 732 } // namespace browser_watcher | 767 } // namespace browser_watcher |
| OLD | NEW |