OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "minidump/minidump_module_writer.h" | 15 #include "minidump/minidump_module_writer.h" |
16 | 16 |
17 #include <windows.h> | 17 #include <windows.h> |
18 #include <dbghelp.h> | 18 #include <dbghelp.h> |
19 #include <stdint.h> | 19 #include <stdint.h> |
20 #include <string.h> | 20 #include <string.h> |
21 #include <sys/types.h> | 21 #include <sys/types.h> |
22 | 22 |
| 23 #include "base/format_macros.h" |
23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
24 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
25 #include "gtest/gtest.h" | 26 #include "gtest/gtest.h" |
26 #include "minidump/minidump_extensions.h" | 27 #include "minidump/minidump_extensions.h" |
27 #include "minidump/minidump_file_writer.h" | 28 #include "minidump/minidump_file_writer.h" |
28 #include "minidump/test/minidump_file_writer_test_util.h" | 29 #include "minidump/test/minidump_file_writer_test_util.h" |
29 #include "minidump/test/minidump_string_writer_test_util.h" | 30 #include "minidump/test/minidump_string_writer_test_util.h" |
30 #include "minidump/test/minidump_writable_test_util.h" | 31 #include "minidump/test/minidump_writable_test_util.h" |
31 #include "snapshot/test/test_module_snapshot.h" | 32 #include "snapshot/test/test_module_snapshot.h" |
32 #include "util/file/string_file_writer.h" | 33 #include "util/file/string_file_writer.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 StringFileWriter file_writer; | 723 StringFileWriter file_writer; |
723 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 724 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
724 | 725 |
725 const MINIDUMP_MODULE_LIST* module_list = nullptr; | 726 const MINIDUMP_MODULE_LIST* module_list = nullptr; |
726 ASSERT_NO_FATAL_FAILURE( | 727 ASSERT_NO_FATAL_FAILURE( |
727 GetModuleListStream(file_writer.string(), &module_list)); | 728 GetModuleListStream(file_writer.string(), &module_list)); |
728 | 729 |
729 ASSERT_EQ(3u, module_list->NumberOfModules); | 730 ASSERT_EQ(3u, module_list->NumberOfModules); |
730 | 731 |
731 for (size_t index = 0; index < module_list->NumberOfModules; ++index) { | 732 for (size_t index = 0; index < module_list->NumberOfModules; ++index) { |
732 SCOPED_TRACE(base::StringPrintf("index %zu", index)); | 733 SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index)); |
733 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expect_modules[index], | 734 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expect_modules[index], |
734 &module_list->Modules[index], | 735 &module_list->Modules[index], |
735 file_writer.string(), | 736 file_writer.string(), |
736 module_paths[index], | 737 module_paths[index], |
737 module_names[index], | 738 module_names[index], |
738 &uuids[index], | 739 &uuids[index], |
739 0, | 740 0, |
740 0, | 741 0, |
741 nullptr, | 742 nullptr, |
742 0, | 743 0, |
743 false)); | 744 false)); |
744 } | 745 } |
745 } | 746 } |
746 | 747 |
747 TEST(MinidumpModuleWriterDeathTest, NoModuleName) { | 748 TEST(MinidumpModuleWriterDeathTest, NoModuleName) { |
748 MinidumpFileWriter minidump_file_writer; | 749 MinidumpFileWriter minidump_file_writer; |
749 auto module_list_writer = make_scoped_ptr(new MinidumpModuleListWriter()); | 750 auto module_list_writer = make_scoped_ptr(new MinidumpModuleListWriter()); |
750 auto module_writer = make_scoped_ptr(new MinidumpModuleWriter()); | 751 auto module_writer = make_scoped_ptr(new MinidumpModuleWriter()); |
751 module_list_writer->AddModule(module_writer.Pass()); | 752 module_list_writer->AddModule(module_writer.Pass()); |
752 minidump_file_writer.AddStream(module_list_writer.Pass()); | 753 minidump_file_writer.AddStream(module_list_writer.Pass()); |
753 | 754 |
754 StringFileWriter file_writer; | 755 StringFileWriter file_writer; |
755 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "name_"); | 756 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "name_"); |
756 } | 757 } |
757 | 758 |
758 } // namespace | 759 } // namespace |
759 } // namespace test | 760 } // namespace test |
760 } // namespace crashpad | 761 } // namespace crashpad |
OLD | NEW |