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

Side by Side Diff: components/browser_watcher/postmortem_report_collector_unittest.cc

Issue 2649773008: Collect module information from the stability file (Closed)
Patch Set: More signed/unsigned Created 3 years, 10 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
OLDNEW
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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 global_data.SetStringReference("sref", string2); 578 global_data.SetStringReference("sref", string2);
579 579
580 // Collect the stability report. 580 // Collect the stability report.
581 PostmortemReportCollector collector(kProductName, kVersionNumber, 581 PostmortemReportCollector collector(kProductName, kVersionNumber,
582 kChannelName); 582 kChannelName);
583 std::unique_ptr<StabilityReport> report; 583 std::unique_ptr<StabilityReport> report;
584 ASSERT_EQ(PostmortemReportCollector::SUCCESS, 584 ASSERT_EQ(PostmortemReportCollector::SUCCESS,
585 collector.Collect(debug_file_path(), &report)); 585 collector.Collect(debug_file_path(), &report));
586 ASSERT_NE(nullptr, report); 586 ASSERT_NE(nullptr, report);
587 587
588 // Validate the report's log content. 588 // Validate the report's user data.
589 const auto& collected_data = report->global_data(); 589 const auto& collected_data = report->global_data();
590 ASSERT_EQ(8U, collected_data.size()); 590 ASSERT_EQ(8U, collected_data.size());
591 591
592 ASSERT_TRUE(base::ContainsKey(collected_data, "raw")); 592 ASSERT_TRUE(base::ContainsKey(collected_data, "raw"));
593 EXPECT_EQ(TypedValue::kBytesValue, collected_data.at("raw").value_case()); 593 EXPECT_EQ(TypedValue::kBytesValue, collected_data.at("raw").value_case());
594 EXPECT_EQ("foo", collected_data.at("raw").bytes_value()); 594 EXPECT_EQ("foo", collected_data.at("raw").bytes_value());
595 595
596 ASSERT_TRUE(base::ContainsKey(collected_data, "string")); 596 ASSERT_TRUE(base::ContainsKey(collected_data, "string"));
597 EXPECT_EQ(TypedValue::kStringValue, collected_data.at("string").value_case()); 597 EXPECT_EQ(TypedValue::kStringValue, collected_data.at("string").value_case());
598 EXPECT_EQ("bar", collected_data.at("string").string_value()); 598 EXPECT_EQ("bar", collected_data.at("string").string_value());
(...skipping 22 matching lines...) Expand all
621 621
622 ASSERT_TRUE(base::ContainsKey(collected_data, "sref")); 622 ASSERT_TRUE(base::ContainsKey(collected_data, "sref"));
623 EXPECT_EQ(TypedValue::kStringReference, 623 EXPECT_EQ(TypedValue::kStringReference,
624 collected_data.at("sref").value_case()); 624 collected_data.at("sref").value_case());
625 const TypedValue::Reference& sref = 625 const TypedValue::Reference& sref =
626 collected_data.at("sref").string_reference(); 626 collected_data.at("sref").string_reference();
627 EXPECT_EQ(reinterpret_cast<uintptr_t>(string2), sref.address()); 627 EXPECT_EQ(reinterpret_cast<uintptr_t>(string2), sref.address());
628 EXPECT_EQ(strlen(string2), static_cast<uint64_t>(sref.size())); 628 EXPECT_EQ(strlen(string2), static_cast<uint64_t>(sref.size()));
629 } 629 }
630 630
631 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest,
632 ModuleCollection) {
633 // Record some module information.
634 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL,
635 "", 3);
636
637 base::debug::GlobalActivityTracker::ModuleInfo module_info = {};
638 module_info.is_loaded = true;
639 module_info.address = 0x123456;
640 module_info.load_time = 1111LL;
641 module_info.size = 0x2d000;
642 module_info.timestamp = 0xCAFECAFE;
643 module_info.age = 1;
644 crashpad::UUID debug_uuid;
645 debug_uuid.InitializeFromString("11223344-5566-7788-abcd-0123456789ab");
646 memcpy(module_info.identifier, &debug_uuid, sizeof(module_info.identifier));
647 module_info.file = "foo";
648 module_info.debug_file = "bar";
649
650 GlobalActivityTracker::Get()->RecordModuleInfo(module_info);
651
652 // Collect the stability report.
653 PostmortemReportCollector collector(kProductName, kVersionNumber,
654 kChannelName);
655 std::unique_ptr<StabilityReport> report;
656 ASSERT_EQ(PostmortemReportCollector::SUCCESS,
657 collector.Collect(debug_file_path(), &report));
658 ASSERT_NE(nullptr, report);
659
660 // Validate the report's log content.
bcwhite 2017/01/27 18:48:26 modules content
manzagop (departed) 2017/01/27 19:25:22 Done.
661 ASSERT_EQ(1, report->process_states_size());
662 const ProcessState& process_state = report->process_states(0);
663 ASSERT_EQ(1, process_state.modules_size());
664
665 const CodeModule collected_module = process_state.modules(0);
666 EXPECT_EQ(module_info.address,
667 static_cast<uintptr_t>(collected_module.base_address()));
668 EXPECT_EQ(module_info.size, static_cast<size_t>(collected_module.size()));
669 EXPECT_EQ(module_info.file, collected_module.code_file());
670 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier());
671 EXPECT_EQ(module_info.debug_file, collected_module.debug_file());
672 EXPECT_EQ("1122334455667788ABCD0123456789AB1",
673 collected_module.debug_identifier());
674 EXPECT_EQ("", collected_module.version());
675 EXPECT_EQ(0ULL, collected_module.shrink_down_delta());
676 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded());
677 }
678
631 } // namespace browser_watcher 679 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698