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, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 file_contents, directory[0].Location); | 43 file_contents, directory[0].Location); |
44 ASSERT_TRUE(*crashpad_info); | 44 ASSERT_TRUE(*crashpad_info); |
45 | 45 |
46 *module_list = | 46 *module_list = |
47 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfoList>( | 47 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfoList>( |
48 file_contents, (*crashpad_info)->module_list); | 48 file_contents, (*crashpad_info)->module_list); |
49 } | 49 } |
50 | 50 |
51 TEST(MinidumpCrashpadInfoWriter, Empty) { | 51 TEST(MinidumpCrashpadInfoWriter, Empty) { |
52 MinidumpFileWriter minidump_file_writer; | 52 MinidumpFileWriter minidump_file_writer; |
53 MinidumpCrashpadInfoWriter crashpad_info_writer; | 53 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); |
54 | 54 |
55 minidump_file_writer.AddStream(&crashpad_info_writer); | 55 minidump_file_writer.AddStream(crashpad_info_writer.Pass()); |
56 | 56 |
57 StringFileWriter file_writer; | 57 StringFileWriter file_writer; |
58 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 58 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
59 | 59 |
60 const MinidumpCrashpadInfo* crashpad_info; | 60 const MinidumpCrashpadInfo* crashpad_info; |
61 const MinidumpModuleCrashpadInfoList* module_list; | 61 const MinidumpModuleCrashpadInfoList* module_list; |
62 | 62 |
63 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( | 63 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( |
64 file_writer.string(), &crashpad_info, &module_list)); | 64 file_writer.string(), &crashpad_info, &module_list)); |
65 | 65 |
66 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); | 66 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); |
67 EXPECT_FALSE(module_list); | 67 EXPECT_FALSE(module_list); |
68 } | 68 } |
69 | 69 |
70 TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) { | 70 TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) { |
71 const uint32_t kMinidumpModuleListIndex = 3; | 71 const uint32_t kMinidumpModuleListIndex = 3; |
72 | 72 |
73 MinidumpFileWriter minidump_file_writer; | 73 MinidumpFileWriter minidump_file_writer; |
74 MinidumpCrashpadInfoWriter crashpad_info_writer; | 74 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); |
75 | 75 |
76 minidump_file_writer.AddStream(&crashpad_info_writer); | 76 auto module_list_writer = |
| 77 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); |
| 78 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
| 79 module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex); |
| 80 module_list_writer->AddModule(module_writer.Pass()); |
| 81 crashpad_info_writer->SetModuleList(module_list_writer.Pass()); |
77 | 82 |
78 MinidumpModuleCrashpadInfoListWriter module_list_writer; | 83 minidump_file_writer.AddStream(crashpad_info_writer.Pass()); |
79 MinidumpModuleCrashpadInfoWriter module_writer; | |
80 module_writer.SetMinidumpModuleListIndex(kMinidumpModuleListIndex); | |
81 module_list_writer.AddModule(&module_writer); | |
82 crashpad_info_writer.SetModuleList(&module_list_writer); | |
83 | 84 |
84 StringFileWriter file_writer; | 85 StringFileWriter file_writer; |
85 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 86 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
86 | 87 |
87 const MinidumpCrashpadInfo* crashpad_info; | 88 const MinidumpCrashpadInfo* crashpad_info; |
88 const MinidumpModuleCrashpadInfoList* module_list; | 89 const MinidumpModuleCrashpadInfoList* module_list; |
89 | 90 |
90 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( | 91 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( |
91 file_writer.string(), &crashpad_info, &module_list)); | 92 file_writer.string(), &crashpad_info, &module_list)); |
92 | 93 |
93 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); | 94 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); |
94 ASSERT_TRUE(module_list); | 95 ASSERT_TRUE(module_list); |
95 ASSERT_EQ(1u, module_list->count); | 96 ASSERT_EQ(1u, module_list->count); |
96 | 97 |
97 const MinidumpModuleCrashpadInfo* module = | 98 const MinidumpModuleCrashpadInfo* module = |
98 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( | 99 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( |
99 file_writer.string(), module_list->modules[0]); | 100 file_writer.string(), module_list->modules[0]); |
100 ASSERT_TRUE(module); | 101 ASSERT_TRUE(module); |
101 | 102 |
102 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); | 103 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); |
103 EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index); | 104 EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index); |
104 EXPECT_EQ(0u, module->simple_annotations.DataSize); | 105 EXPECT_EQ(0u, module->simple_annotations.DataSize); |
105 EXPECT_EQ(0u, module->simple_annotations.Rva); | 106 EXPECT_EQ(0u, module->simple_annotations.Rva); |
106 } | 107 } |
107 | 108 |
108 } // namespace | 109 } // namespace |
109 } // namespace test | 110 } // namespace test |
110 } // namespace crashpad | 111 } // namespace crashpad |
OLD | NEW |