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

Side by Side Diff: minidump/minidump_module_crashpad_info_writer_test.cc

Issue 936153002: Add FileReaderInterface. Move StringFileWriter to StringFile and (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Remove unused #include Created 5 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
« no previous file with comments | « minidump/minidump_misc_info_writer_test.cc ('k') | minidump/minidump_module_writer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_crashpad_info_writer.h" 15 #include "minidump/minidump_module_crashpad_info_writer.h"
16 16
17 #include <windows.h> 17 #include <windows.h>
18 #include <dbghelp.h> 18 #include <dbghelp.h>
19 19
20 #include "gtest/gtest.h" 20 #include "gtest/gtest.h"
21 #include "minidump/minidump_extensions.h" 21 #include "minidump/minidump_extensions.h"
22 #include "minidump/minidump_simple_string_dictionary_writer.h" 22 #include "minidump/minidump_simple_string_dictionary_writer.h"
23 #include "minidump/test/minidump_file_writer_test_util.h" 23 #include "minidump/test/minidump_file_writer_test_util.h"
24 #include "minidump/test/minidump_location_descriptor_list_test_util.h" 24 #include "minidump/test/minidump_location_descriptor_list_test_util.h"
25 #include "minidump/test/minidump_string_writer_test_util.h" 25 #include "minidump/test/minidump_string_writer_test_util.h"
26 #include "minidump/test/minidump_writable_test_util.h" 26 #include "minidump/test/minidump_writable_test_util.h"
27 #include "snapshot/test/test_module_snapshot.h" 27 #include "snapshot/test/test_module_snapshot.h"
28 #include "util/file/string_file_writer.h" 28 #include "util/file/string_file.h"
29 29
30 namespace crashpad { 30 namespace crashpad {
31 namespace test { 31 namespace test {
32 namespace { 32 namespace {
33 33
34 TEST(MinidumpModuleCrashpadInfoWriter, EmptyList) { 34 TEST(MinidumpModuleCrashpadInfoWriter, EmptyList) {
35 StringFileWriter file_writer; 35 StringFile string_file;
36 36
37 MinidumpModuleCrashpadInfoListWriter module_list_writer; 37 MinidumpModuleCrashpadInfoListWriter module_list_writer;
38 EXPECT_FALSE(module_list_writer.IsUseful()); 38 EXPECT_FALSE(module_list_writer.IsUseful());
39 39
40 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); 40 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file));
41 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList), 41 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList),
42 file_writer.string().size()); 42 string_file.string().size());
43 43
44 const MinidumpModuleCrashpadInfoList* module_list = 44 const MinidumpModuleCrashpadInfoList* module_list =
45 MinidumpLocationDescriptorListAtStart(file_writer.string(), 0); 45 MinidumpLocationDescriptorListAtStart(string_file.string(), 0);
46 ASSERT_TRUE(module_list); 46 ASSERT_TRUE(module_list);
47 } 47 }
48 48
49 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) { 49 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) {
50 StringFileWriter file_writer; 50 StringFile string_file;
51 51
52 MinidumpModuleCrashpadInfoListWriter module_list_writer; 52 MinidumpModuleCrashpadInfoListWriter module_list_writer;
53 auto module_writer = 53 auto module_writer =
54 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 54 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
55 EXPECT_FALSE(module_writer->IsUseful()); 55 EXPECT_FALSE(module_writer->IsUseful());
56 module_list_writer.AddModule(module_writer.Pass()); 56 module_list_writer.AddModule(module_writer.Pass());
57 57
58 EXPECT_TRUE(module_list_writer.IsUseful()); 58 EXPECT_TRUE(module_list_writer.IsUseful());
59 59
60 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); 60 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file));
61 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 61 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
62 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + 62 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) +
63 sizeof(MinidumpModuleCrashpadInfo), 63 sizeof(MinidumpModuleCrashpadInfo),
64 file_writer.string().size()); 64 string_file.string().size());
65 65
66 const MinidumpModuleCrashpadInfoList* module_list = 66 const MinidumpModuleCrashpadInfoList* module_list =
67 MinidumpLocationDescriptorListAtStart(file_writer.string(), 1); 67 MinidumpLocationDescriptorListAtStart(string_file.string(), 1);
68 ASSERT_TRUE(module_list); 68 ASSERT_TRUE(module_list);
69 69
70 const MinidumpModuleCrashpadInfo* module = 70 const MinidumpModuleCrashpadInfo* module =
71 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 71 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
72 file_writer.string(), module_list->children[0]); 72 string_file.string(), module_list->children[0]);
73 ASSERT_TRUE(module); 73 ASSERT_TRUE(module);
74 74
75 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 75 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
76 EXPECT_EQ(0u, module->minidump_module_list_index); 76 EXPECT_EQ(0u, module->minidump_module_list_index);
77 EXPECT_EQ(0u, module->list_annotations.DataSize); 77 EXPECT_EQ(0u, module->list_annotations.DataSize);
78 EXPECT_EQ(0u, module->list_annotations.Rva); 78 EXPECT_EQ(0u, module->list_annotations.Rva);
79 EXPECT_EQ(0u, module->simple_annotations.DataSize); 79 EXPECT_EQ(0u, module->simple_annotations.DataSize);
80 EXPECT_EQ(0u, module->simple_annotations.Rva); 80 EXPECT_EQ(0u, module->simple_annotations.Rva);
81 } 81 }
82 82
83 TEST(MinidumpModuleCrashpadInfoWriter, FullModule) { 83 TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
84 const uint32_t kMinidumpModuleListIndex = 1; 84 const uint32_t kMinidumpModuleListIndex = 1;
85 const char kKey[] = "key"; 85 const char kKey[] = "key";
86 const char kValue[] = "value"; 86 const char kValue[] = "value";
87 const char kEntry[] = "entry"; 87 const char kEntry[] = "entry";
88 std::vector<std::string> vector(1, std::string(kEntry)); 88 std::vector<std::string> vector(1, std::string(kEntry));
89 89
90 StringFileWriter file_writer; 90 StringFile string_file;
91 91
92 MinidumpModuleCrashpadInfoListWriter module_list_writer; 92 MinidumpModuleCrashpadInfoListWriter module_list_writer;
93 93
94 auto module_writer = 94 auto module_writer =
95 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 95 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
96 module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex); 96 module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex);
97 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter()); 97 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter());
98 string_list_writer->InitializeFromVector(vector); 98 string_list_writer->InitializeFromVector(vector);
99 module_writer->SetListAnnotations(string_list_writer.Pass()); 99 module_writer->SetListAnnotations(string_list_writer.Pass());
100 auto simple_string_dictionary_writer = 100 auto simple_string_dictionary_writer =
101 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 101 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
102 auto simple_string_dictionary_entry_writer = 102 auto simple_string_dictionary_entry_writer =
103 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 103 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
104 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue); 104 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue);
105 simple_string_dictionary_writer->AddEntry( 105 simple_string_dictionary_writer->AddEntry(
106 simple_string_dictionary_entry_writer.Pass()); 106 simple_string_dictionary_entry_writer.Pass());
107 module_writer->SetSimpleAnnotations(simple_string_dictionary_writer.Pass()); 107 module_writer->SetSimpleAnnotations(simple_string_dictionary_writer.Pass());
108 EXPECT_TRUE(module_writer->IsUseful()); 108 EXPECT_TRUE(module_writer->IsUseful());
109 module_list_writer.AddModule(module_writer.Pass()); 109 module_list_writer.AddModule(module_writer.Pass());
110 110
111 EXPECT_TRUE(module_list_writer.IsUseful()); 111 EXPECT_TRUE(module_list_writer.IsUseful());
112 112
113 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); 113 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file));
114 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 114 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
115 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + 115 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) +
116 sizeof(MinidumpModuleCrashpadInfo) + 116 sizeof(MinidumpModuleCrashpadInfo) +
117 sizeof(MinidumpRVAList) + 117 sizeof(MinidumpRVAList) +
118 sizeof(RVA) + 118 sizeof(RVA) +
119 sizeof(MinidumpSimpleStringDictionary) + 119 sizeof(MinidumpSimpleStringDictionary) +
120 sizeof(MinidumpSimpleStringDictionaryEntry) + 120 sizeof(MinidumpSimpleStringDictionaryEntry) +
121 sizeof(MinidumpUTF8String) + arraysize(kEntry) + 2 + // padding 121 sizeof(MinidumpUTF8String) + arraysize(kEntry) + 2 + // padding
122 sizeof(MinidumpUTF8String) + arraysize(kKey) + 122 sizeof(MinidumpUTF8String) + arraysize(kKey) +
123 sizeof(MinidumpUTF8String) + arraysize(kValue), 123 sizeof(MinidumpUTF8String) + arraysize(kValue),
124 file_writer.string().size()); 124 string_file.string().size());
125 125
126 const MinidumpModuleCrashpadInfoList* module_list = 126 const MinidumpModuleCrashpadInfoList* module_list =
127 MinidumpLocationDescriptorListAtStart(file_writer.string(), 1); 127 MinidumpLocationDescriptorListAtStart(string_file.string(), 1);
128 ASSERT_TRUE(module_list); 128 ASSERT_TRUE(module_list);
129 129
130 const MinidumpModuleCrashpadInfo* module = 130 const MinidumpModuleCrashpadInfo* module =
131 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 131 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
132 file_writer.string(), module_list->children[0]); 132 string_file.string(), module_list->children[0]);
133 ASSERT_TRUE(module); 133 ASSERT_TRUE(module);
134 134
135 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 135 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
136 EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index); 136 EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index);
137 EXPECT_NE(0u, module->list_annotations.DataSize); 137 EXPECT_NE(0u, module->list_annotations.DataSize);
138 EXPECT_NE(0u, module->list_annotations.Rva); 138 EXPECT_NE(0u, module->list_annotations.Rva);
139 EXPECT_NE(0u, module->simple_annotations.DataSize); 139 EXPECT_NE(0u, module->simple_annotations.DataSize);
140 EXPECT_NE(0u, module->simple_annotations.Rva); 140 EXPECT_NE(0u, module->simple_annotations.Rva);
141 141
142 const MinidumpRVAList* list_annotations = 142 const MinidumpRVAList* list_annotations =
143 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 143 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
144 file_writer.string(), module->list_annotations); 144 string_file.string(), module->list_annotations);
145 ASSERT_TRUE(list_annotations); 145 ASSERT_TRUE(list_annotations);
146 146
147 ASSERT_EQ(1u, list_annotations->count); 147 ASSERT_EQ(1u, list_annotations->count);
148 EXPECT_EQ(kEntry, MinidumpUTF8StringAtRVAAsString( 148 EXPECT_EQ(kEntry, MinidumpUTF8StringAtRVAAsString(
149 file_writer.string(), list_annotations->children[0])); 149 string_file.string(), list_annotations->children[0]));
150 150
151 const MinidumpSimpleStringDictionary* simple_annotations = 151 const MinidumpSimpleStringDictionary* simple_annotations =
152 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 152 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
153 file_writer.string(), module->simple_annotations); 153 string_file.string(), module->simple_annotations);
154 ASSERT_TRUE(simple_annotations); 154 ASSERT_TRUE(simple_annotations);
155 155
156 ASSERT_EQ(1u, simple_annotations->count); 156 ASSERT_EQ(1u, simple_annotations->count);
157 EXPECT_EQ(kKey, 157 EXPECT_EQ(kKey,
158 MinidumpUTF8StringAtRVAAsString( 158 MinidumpUTF8StringAtRVAAsString(
159 file_writer.string(), simple_annotations->entries[0].key)); 159 string_file.string(), simple_annotations->entries[0].key));
160 EXPECT_EQ(kValue, 160 EXPECT_EQ(kValue,
161 MinidumpUTF8StringAtRVAAsString( 161 MinidumpUTF8StringAtRVAAsString(
162 file_writer.string(), simple_annotations->entries[0].value)); 162 string_file.string(), simple_annotations->entries[0].value));
163 } 163 }
164 164
165 TEST(MinidumpModuleCrashpadInfoWriter, ThreeModules) { 165 TEST(MinidumpModuleCrashpadInfoWriter, ThreeModules) {
166 const uint32_t kMinidumpModuleListIndex0 = 0; 166 const uint32_t kMinidumpModuleListIndex0 = 0;
167 const char kKey0[] = "key"; 167 const char kKey0[] = "key";
168 const char kValue0[] = "value"; 168 const char kValue0[] = "value";
169 const uint32_t kMinidumpModuleListIndex1 = 2; 169 const uint32_t kMinidumpModuleListIndex1 = 2;
170 const uint32_t kMinidumpModuleListIndex2 = 5; 170 const uint32_t kMinidumpModuleListIndex2 = 5;
171 const char kKey2A[] = "K"; 171 const char kKey2A[] = "K";
172 const char kValue2A[] = "VVV"; 172 const char kValue2A[] = "VVV";
173 const char kKey2B[] = "river"; 173 const char kKey2B[] = "river";
174 const char kValue2B[] = "hudson"; 174 const char kValue2B[] = "hudson";
175 175
176 StringFileWriter file_writer; 176 StringFile string_file;
177 177
178 MinidumpModuleCrashpadInfoListWriter module_list_writer; 178 MinidumpModuleCrashpadInfoListWriter module_list_writer;
179 179
180 auto module_writer_0 = 180 auto module_writer_0 =
181 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 181 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
182 module_writer_0->SetMinidumpModuleListIndex(kMinidumpModuleListIndex0); 182 module_writer_0->SetMinidumpModuleListIndex(kMinidumpModuleListIndex0);
183 auto simple_string_dictionary_writer_0 = 183 auto simple_string_dictionary_writer_0 =
184 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 184 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
185 auto simple_string_dictionary_entry_writer_0 = 185 auto simple_string_dictionary_entry_writer_0 =
186 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 186 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
(...skipping 26 matching lines...) Expand all
213 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B); 213 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B);
214 simple_string_dictionary_writer_2->AddEntry( 214 simple_string_dictionary_writer_2->AddEntry(
215 simple_string_dictionary_entry_writer_2b.Pass()); 215 simple_string_dictionary_entry_writer_2b.Pass());
216 module_writer_2->SetSimpleAnnotations( 216 module_writer_2->SetSimpleAnnotations(
217 simple_string_dictionary_writer_2.Pass()); 217 simple_string_dictionary_writer_2.Pass());
218 EXPECT_TRUE(module_writer_2->IsUseful()); 218 EXPECT_TRUE(module_writer_2->IsUseful());
219 module_list_writer.AddModule(module_writer_2.Pass()); 219 module_list_writer.AddModule(module_writer_2.Pass());
220 220
221 EXPECT_TRUE(module_list_writer.IsUseful()); 221 EXPECT_TRUE(module_list_writer.IsUseful());
222 222
223 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); 223 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file));
224 224
225 const MinidumpModuleCrashpadInfoList* module_list = 225 const MinidumpModuleCrashpadInfoList* module_list =
226 MinidumpLocationDescriptorListAtStart(file_writer.string(), 3); 226 MinidumpLocationDescriptorListAtStart(string_file.string(), 3);
227 ASSERT_TRUE(module_list); 227 ASSERT_TRUE(module_list);
228 228
229 const MinidumpModuleCrashpadInfo* module_0 = 229 const MinidumpModuleCrashpadInfo* module_0 =
230 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 230 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
231 file_writer.string(), module_list->children[0]); 231 string_file.string(), module_list->children[0]);
232 ASSERT_TRUE(module_0); 232 ASSERT_TRUE(module_0);
233 233
234 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version); 234 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version);
235 EXPECT_EQ(kMinidumpModuleListIndex0, module_0->minidump_module_list_index); 235 EXPECT_EQ(kMinidumpModuleListIndex0, module_0->minidump_module_list_index);
236 236
237 const MinidumpRVAList* list_annotations_0 = 237 const MinidumpRVAList* list_annotations_0 =
238 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 238 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
239 file_writer.string(), module_0->list_annotations); 239 string_file.string(), module_0->list_annotations);
240 EXPECT_FALSE(list_annotations_0); 240 EXPECT_FALSE(list_annotations_0);
241 241
242 const MinidumpSimpleStringDictionary* simple_annotations_0 = 242 const MinidumpSimpleStringDictionary* simple_annotations_0 =
243 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 243 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
244 file_writer.string(), module_0->simple_annotations); 244 string_file.string(), module_0->simple_annotations);
245 ASSERT_TRUE(simple_annotations_0); 245 ASSERT_TRUE(simple_annotations_0);
246 246
247 ASSERT_EQ(1u, simple_annotations_0->count); 247 ASSERT_EQ(1u, simple_annotations_0->count);
248 EXPECT_EQ(kKey0, 248 EXPECT_EQ(kKey0,
249 MinidumpUTF8StringAtRVAAsString( 249 MinidumpUTF8StringAtRVAAsString(
250 file_writer.string(), simple_annotations_0->entries[0].key)); 250 string_file.string(), simple_annotations_0->entries[0].key));
251 EXPECT_EQ(kValue0, 251 EXPECT_EQ(kValue0,
252 MinidumpUTF8StringAtRVAAsString( 252 MinidumpUTF8StringAtRVAAsString(
253 file_writer.string(), simple_annotations_0->entries[0].value)); 253 string_file.string(), simple_annotations_0->entries[0].value));
254 254
255 const MinidumpModuleCrashpadInfo* module_1 = 255 const MinidumpModuleCrashpadInfo* module_1 =
256 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 256 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
257 file_writer.string(), module_list->children[1]); 257 string_file.string(), module_list->children[1]);
258 ASSERT_TRUE(module_1); 258 ASSERT_TRUE(module_1);
259 259
260 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_1->version); 260 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_1->version);
261 EXPECT_EQ(kMinidumpModuleListIndex1, module_1->minidump_module_list_index); 261 EXPECT_EQ(kMinidumpModuleListIndex1, module_1->minidump_module_list_index);
262 262
263 const MinidumpRVAList* list_annotations_1 = 263 const MinidumpRVAList* list_annotations_1 =
264 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 264 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
265 file_writer.string(), module_1->list_annotations); 265 string_file.string(), module_1->list_annotations);
266 EXPECT_FALSE(list_annotations_1); 266 EXPECT_FALSE(list_annotations_1);
267 267
268 const MinidumpSimpleStringDictionary* simple_annotations_1 = 268 const MinidumpSimpleStringDictionary* simple_annotations_1 =
269 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 269 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
270 file_writer.string(), module_1->simple_annotations); 270 string_file.string(), module_1->simple_annotations);
271 EXPECT_FALSE(simple_annotations_1); 271 EXPECT_FALSE(simple_annotations_1);
272 272
273 const MinidumpModuleCrashpadInfo* module_2 = 273 const MinidumpModuleCrashpadInfo* module_2 =
274 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 274 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
275 file_writer.string(), module_list->children[2]); 275 string_file.string(), module_list->children[2]);
276 ASSERT_TRUE(module_2); 276 ASSERT_TRUE(module_2);
277 277
278 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version); 278 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version);
279 EXPECT_EQ(kMinidumpModuleListIndex2, module_2->minidump_module_list_index); 279 EXPECT_EQ(kMinidumpModuleListIndex2, module_2->minidump_module_list_index);
280 280
281 const MinidumpRVAList* list_annotations_2 = 281 const MinidumpRVAList* list_annotations_2 =
282 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 282 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
283 file_writer.string(), module_2->list_annotations); 283 string_file.string(), module_2->list_annotations);
284 EXPECT_FALSE(list_annotations_2); 284 EXPECT_FALSE(list_annotations_2);
285 285
286 const MinidumpSimpleStringDictionary* simple_annotations_2 = 286 const MinidumpSimpleStringDictionary* simple_annotations_2 =
287 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 287 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
288 file_writer.string(), module_2->simple_annotations); 288 string_file.string(), module_2->simple_annotations);
289 ASSERT_TRUE(simple_annotations_2); 289 ASSERT_TRUE(simple_annotations_2);
290 290
291 ASSERT_EQ(2u, simple_annotations_2->count); 291 ASSERT_EQ(2u, simple_annotations_2->count);
292 EXPECT_EQ(kKey2A, 292 EXPECT_EQ(kKey2A,
293 MinidumpUTF8StringAtRVAAsString( 293 MinidumpUTF8StringAtRVAAsString(
294 file_writer.string(), simple_annotations_2->entries[0].key)); 294 string_file.string(), simple_annotations_2->entries[0].key));
295 EXPECT_EQ(kValue2A, 295 EXPECT_EQ(kValue2A,
296 MinidumpUTF8StringAtRVAAsString( 296 MinidumpUTF8StringAtRVAAsString(
297 file_writer.string(), simple_annotations_2->entries[0].value)); 297 string_file.string(), simple_annotations_2->entries[0].value));
298 EXPECT_EQ(kKey2B, 298 EXPECT_EQ(kKey2B,
299 MinidumpUTF8StringAtRVAAsString( 299 MinidumpUTF8StringAtRVAAsString(
300 file_writer.string(), simple_annotations_2->entries[1].key)); 300 string_file.string(), simple_annotations_2->entries[1].key));
301 EXPECT_EQ(kValue2B, 301 EXPECT_EQ(kValue2B,
302 MinidumpUTF8StringAtRVAAsString( 302 MinidumpUTF8StringAtRVAAsString(
303 file_writer.string(), simple_annotations_2->entries[1].value)); 303 string_file.string(), simple_annotations_2->entries[1].value));
304 } 304 }
305 305
306 TEST(MinidumpModuleCrashpadInfoWriter, InitializeFromSnapshot) { 306 TEST(MinidumpModuleCrashpadInfoWriter, InitializeFromSnapshot) {
307 const char kKey0A[] = "k"; 307 const char kKey0A[] = "k";
308 const char kValue0A[] = "value"; 308 const char kValue0A[] = "value";
309 const char kKey0B[] = "hudson"; 309 const char kKey0B[] = "hudson";
310 const char kValue0B[] = "estuary"; 310 const char kValue0B[] = "estuary";
311 const char kKey2[] = "k"; 311 const char kKey2[] = "k";
312 const char kValue2[] = "different_value"; 312 const char kValue2[] = "different_value";
313 const char kEntry3A[] = "list"; 313 const char kEntry3A[] = "list";
(...skipping 23 matching lines...) Expand all
337 std::vector<std::string> annotations_vector_3; 337 std::vector<std::string> annotations_vector_3;
338 annotations_vector_3.push_back(kEntry3A); 338 annotations_vector_3.push_back(kEntry3A);
339 annotations_vector_3.push_back(kEntry3B); 339 annotations_vector_3.push_back(kEntry3B);
340 module_snapshot_3.SetAnnotationsVector(annotations_vector_3); 340 module_snapshot_3.SetAnnotationsVector(annotations_vector_3);
341 module_snapshots.push_back(&module_snapshot_3); 341 module_snapshots.push_back(&module_snapshot_3);
342 342
343 MinidumpModuleCrashpadInfoListWriter module_list_writer; 343 MinidumpModuleCrashpadInfoListWriter module_list_writer;
344 module_list_writer.InitializeFromSnapshot(module_snapshots); 344 module_list_writer.InitializeFromSnapshot(module_snapshots);
345 EXPECT_TRUE(module_list_writer.IsUseful()); 345 EXPECT_TRUE(module_list_writer.IsUseful());
346 346
347 StringFileWriter file_writer; 347 StringFile string_file;
348 ASSERT_TRUE(module_list_writer.WriteEverything(&file_writer)); 348 ASSERT_TRUE(module_list_writer.WriteEverything(&string_file));
349 349
350 const MinidumpModuleCrashpadInfoList* module_list = 350 const MinidumpModuleCrashpadInfoList* module_list =
351 MinidumpLocationDescriptorListAtStart(file_writer.string(), 3); 351 MinidumpLocationDescriptorListAtStart(string_file.string(), 3);
352 ASSERT_TRUE(module_list); 352 ASSERT_TRUE(module_list);
353 353
354 const MinidumpModuleCrashpadInfo* module_0 = 354 const MinidumpModuleCrashpadInfo* module_0 =
355 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 355 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
356 file_writer.string(), module_list->children[0]); 356 string_file.string(), module_list->children[0]);
357 ASSERT_TRUE(module_0); 357 ASSERT_TRUE(module_0);
358 358
359 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version); 359 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version);
360 EXPECT_EQ(0u, module_0->minidump_module_list_index); 360 EXPECT_EQ(0u, module_0->minidump_module_list_index);
361 361
362 const MinidumpRVAList* list_annotations_0 = 362 const MinidumpRVAList* list_annotations_0 =
363 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 363 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
364 file_writer.string(), module_0->list_annotations); 364 string_file.string(), module_0->list_annotations);
365 EXPECT_FALSE(list_annotations_0); 365 EXPECT_FALSE(list_annotations_0);
366 366
367 const MinidumpSimpleStringDictionary* simple_annotations_0 = 367 const MinidumpSimpleStringDictionary* simple_annotations_0 =
368 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 368 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
369 file_writer.string(), module_0->simple_annotations); 369 string_file.string(), module_0->simple_annotations);
370 ASSERT_TRUE(simple_annotations_0); 370 ASSERT_TRUE(simple_annotations_0);
371 371
372 ASSERT_EQ(annotations_simple_map_0.size(), simple_annotations_0->count); 372 ASSERT_EQ(annotations_simple_map_0.size(), simple_annotations_0->count);
373 EXPECT_EQ(kKey0B, 373 EXPECT_EQ(kKey0B,
374 MinidumpUTF8StringAtRVAAsString( 374 MinidumpUTF8StringAtRVAAsString(
375 file_writer.string(), simple_annotations_0->entries[0].key)); 375 string_file.string(), simple_annotations_0->entries[0].key));
376 EXPECT_EQ(kValue0B, 376 EXPECT_EQ(kValue0B,
377 MinidumpUTF8StringAtRVAAsString( 377 MinidumpUTF8StringAtRVAAsString(
378 file_writer.string(), simple_annotations_0->entries[0].value)); 378 string_file.string(), simple_annotations_0->entries[0].value));
379 EXPECT_EQ(kKey0A, 379 EXPECT_EQ(kKey0A,
380 MinidumpUTF8StringAtRVAAsString( 380 MinidumpUTF8StringAtRVAAsString(
381 file_writer.string(), simple_annotations_0->entries[1].key)); 381 string_file.string(), simple_annotations_0->entries[1].key));
382 EXPECT_EQ(kValue0A, 382 EXPECT_EQ(kValue0A,
383 MinidumpUTF8StringAtRVAAsString( 383 MinidumpUTF8StringAtRVAAsString(
384 file_writer.string(), simple_annotations_0->entries[1].value)); 384 string_file.string(), simple_annotations_0->entries[1].value));
385 385
386 const MinidumpModuleCrashpadInfo* module_2 = 386 const MinidumpModuleCrashpadInfo* module_2 =
387 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 387 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
388 file_writer.string(), module_list->children[1]); 388 string_file.string(), module_list->children[1]);
389 ASSERT_TRUE(module_2); 389 ASSERT_TRUE(module_2);
390 390
391 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version); 391 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version);
392 EXPECT_EQ(2u, module_2->minidump_module_list_index); 392 EXPECT_EQ(2u, module_2->minidump_module_list_index);
393 393
394 const MinidumpRVAList* list_annotations_2 = 394 const MinidumpRVAList* list_annotations_2 =
395 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 395 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
396 file_writer.string(), module_2->list_annotations); 396 string_file.string(), module_2->list_annotations);
397 EXPECT_FALSE(list_annotations_2); 397 EXPECT_FALSE(list_annotations_2);
398 398
399 const MinidumpSimpleStringDictionary* simple_annotations_2 = 399 const MinidumpSimpleStringDictionary* simple_annotations_2 =
400 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 400 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
401 file_writer.string(), module_2->simple_annotations); 401 string_file.string(), module_2->simple_annotations);
402 ASSERT_TRUE(simple_annotations_2); 402 ASSERT_TRUE(simple_annotations_2);
403 403
404 ASSERT_EQ(annotations_simple_map_2.size(), simple_annotations_2->count); 404 ASSERT_EQ(annotations_simple_map_2.size(), simple_annotations_2->count);
405 EXPECT_EQ(kKey2, 405 EXPECT_EQ(kKey2,
406 MinidumpUTF8StringAtRVAAsString( 406 MinidumpUTF8StringAtRVAAsString(
407 file_writer.string(), simple_annotations_2->entries[0].key)); 407 string_file.string(), simple_annotations_2->entries[0].key));
408 EXPECT_EQ(kValue2, 408 EXPECT_EQ(kValue2,
409 MinidumpUTF8StringAtRVAAsString( 409 MinidumpUTF8StringAtRVAAsString(
410 file_writer.string(), simple_annotations_2->entries[0].value)); 410 string_file.string(), simple_annotations_2->entries[0].value));
411 411
412 const MinidumpModuleCrashpadInfo* module_3 = 412 const MinidumpModuleCrashpadInfo* module_3 =
413 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 413 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
414 file_writer.string(), module_list->children[2]); 414 string_file.string(), module_list->children[2]);
415 ASSERT_TRUE(module_3); 415 ASSERT_TRUE(module_3);
416 416
417 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_3->version); 417 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_3->version);
418 EXPECT_EQ(3u, module_3->minidump_module_list_index); 418 EXPECT_EQ(3u, module_3->minidump_module_list_index);
419 419
420 const MinidumpRVAList* list_annotations_3 = 420 const MinidumpRVAList* list_annotations_3 =
421 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 421 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
422 file_writer.string(), module_3->list_annotations); 422 string_file.string(), module_3->list_annotations);
423 ASSERT_TRUE(list_annotations_3); 423 ASSERT_TRUE(list_annotations_3);
424 424
425 ASSERT_EQ(annotations_vector_3.size(), list_annotations_3->count); 425 ASSERT_EQ(annotations_vector_3.size(), list_annotations_3->count);
426 EXPECT_EQ(kEntry3A, 426 EXPECT_EQ(kEntry3A,
427 MinidumpUTF8StringAtRVAAsString( 427 MinidumpUTF8StringAtRVAAsString(
428 file_writer.string(), list_annotations_3->children[0])); 428 string_file.string(), list_annotations_3->children[0]));
429 EXPECT_EQ(kEntry3B, 429 EXPECT_EQ(kEntry3B,
430 MinidumpUTF8StringAtRVAAsString( 430 MinidumpUTF8StringAtRVAAsString(
431 file_writer.string(), list_annotations_3->children[1])); 431 string_file.string(), list_annotations_3->children[1]));
432 432
433 const MinidumpSimpleStringDictionary* simple_annotations_3 = 433 const MinidumpSimpleStringDictionary* simple_annotations_3 =
434 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 434 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
435 file_writer.string(), module_3->simple_annotations); 435 string_file.string(), module_3->simple_annotations);
436 EXPECT_FALSE(simple_annotations_3); 436 EXPECT_FALSE(simple_annotations_3);
437 } 437 }
438 438
439 } // namespace 439 } // namespace
440 } // namespace test 440 } // namespace test
441 } // namespace crashpad 441 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_misc_info_writer_test.cc ('k') | minidump/minidump_module_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698