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_writable.h" | 15 #include "minidump/minidump_writable.h" |
16 | 16 |
17 #include <string> | 17 #include <string> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "gtest/gtest.h" | 21 #include "gtest/gtest.h" |
22 #include "util/file/string_file_writer.h" | 22 #include "util/file/string_file.h" |
23 | 23 |
24 namespace crashpad { | 24 namespace crashpad { |
25 namespace test { | 25 namespace test { |
26 namespace { | 26 namespace { |
27 | 27 |
28 class BaseTestMinidumpWritable : public crashpad::internal::MinidumpWritable { | 28 class BaseTestMinidumpWritable : public crashpad::internal::MinidumpWritable { |
29 public: | 29 public: |
30 BaseTestMinidumpWritable() | 30 BaseTestMinidumpWritable() |
31 : MinidumpWritable(), | 31 : MinidumpWritable(), |
32 children_(), | 32 children_(), |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return rv; | 138 return rv; |
139 } | 139 } |
140 | 140 |
141 private: | 141 private: |
142 std::string data_; | 142 std::string data_; |
143 | 143 |
144 DISALLOW_COPY_AND_ASSIGN(TestStringMinidumpWritable); | 144 DISALLOW_COPY_AND_ASSIGN(TestStringMinidumpWritable); |
145 }; | 145 }; |
146 | 146 |
147 TEST(MinidumpWritable, MinidumpWritable) { | 147 TEST(MinidumpWritable, MinidumpWritable) { |
148 StringFileWriter writer; | 148 StringFile string_file; |
149 | 149 |
150 { | 150 { |
151 SCOPED_TRACE("empty"); | 151 SCOPED_TRACE("empty"); |
152 writer.Reset(); | 152 string_file.Reset(); |
153 TestStringMinidumpWritable string_writable; | 153 TestStringMinidumpWritable string_writable; |
154 EXPECT_TRUE(string_writable.WriteEverything(&writer)); | 154 EXPECT_TRUE(string_writable.WriteEverything(&string_file)); |
155 EXPECT_TRUE(writer.string().empty()); | 155 EXPECT_TRUE(string_file.string().empty()); |
156 string_writable.Verify(); | 156 string_writable.Verify(); |
157 } | 157 } |
158 | 158 |
159 { | 159 { |
160 SCOPED_TRACE("childless"); | 160 SCOPED_TRACE("childless"); |
161 writer.Reset(); | 161 string_file.Reset(); |
162 TestStringMinidumpWritable string_writable; | 162 TestStringMinidumpWritable string_writable; |
163 string_writable.SetData("a"); | 163 string_writable.SetData("a"); |
164 EXPECT_TRUE(string_writable.WriteEverything(&writer)); | 164 EXPECT_TRUE(string_writable.WriteEverything(&string_file)); |
165 EXPECT_EQ(1u, writer.string().size()); | 165 EXPECT_EQ(1u, string_file.string().size()); |
166 EXPECT_EQ("a", writer.string()); | 166 EXPECT_EQ("a", string_file.string()); |
167 string_writable.Verify(); | 167 string_writable.Verify(); |
168 } | 168 } |
169 | 169 |
170 { | 170 { |
171 SCOPED_TRACE("parent-child"); | 171 SCOPED_TRACE("parent-child"); |
172 writer.Reset(); | 172 string_file.Reset(); |
173 TestStringMinidumpWritable parent; | 173 TestStringMinidumpWritable parent; |
174 parent.SetData("b"); | 174 parent.SetData("b"); |
175 TestStringMinidumpWritable child; | 175 TestStringMinidumpWritable child; |
176 child.SetData("c"); | 176 child.SetData("c"); |
177 parent.AddChild(&child); | 177 parent.AddChild(&child); |
178 EXPECT_TRUE(parent.WriteEverything(&writer)); | 178 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
179 EXPECT_EQ(5u, writer.string().size()); | 179 EXPECT_EQ(5u, string_file.string().size()); |
180 EXPECT_EQ(std::string("b\0\0\0c", 5), writer.string()); | 180 EXPECT_EQ(std::string("b\0\0\0c", 5), string_file.string()); |
181 parent.Verify(); | 181 parent.Verify(); |
182 } | 182 } |
183 | 183 |
184 { | 184 { |
185 SCOPED_TRACE("base alignment 2"); | 185 SCOPED_TRACE("base alignment 2"); |
186 writer.Reset(); | 186 string_file.Reset(); |
187 TestStringMinidumpWritable parent; | 187 TestStringMinidumpWritable parent; |
188 parent.SetData("de"); | 188 parent.SetData("de"); |
189 TestStringMinidumpWritable child; | 189 TestStringMinidumpWritable child; |
190 child.SetData("f"); | 190 child.SetData("f"); |
191 parent.AddChild(&child); | 191 parent.AddChild(&child); |
192 EXPECT_TRUE(parent.WriteEverything(&writer)); | 192 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
193 EXPECT_EQ(5u, writer.string().size()); | 193 EXPECT_EQ(5u, string_file.string().size()); |
194 EXPECT_EQ(std::string("de\0\0f", 5), writer.string()); | 194 EXPECT_EQ(std::string("de\0\0f", 5), string_file.string()); |
195 parent.Verify(); | 195 parent.Verify(); |
196 } | 196 } |
197 | 197 |
198 { | 198 { |
199 SCOPED_TRACE("base alignment 3"); | 199 SCOPED_TRACE("base alignment 3"); |
200 writer.Reset(); | 200 string_file.Reset(); |
201 TestStringMinidumpWritable parent; | 201 TestStringMinidumpWritable parent; |
202 parent.SetData("ghi"); | 202 parent.SetData("ghi"); |
203 TestStringMinidumpWritable child; | 203 TestStringMinidumpWritable child; |
204 child.SetData("j"); | 204 child.SetData("j"); |
205 parent.AddChild(&child); | 205 parent.AddChild(&child); |
206 EXPECT_TRUE(parent.WriteEverything(&writer)); | 206 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
207 EXPECT_EQ(5u, writer.string().size()); | 207 EXPECT_EQ(5u, string_file.string().size()); |
208 EXPECT_EQ(std::string("ghi\0j", 5), writer.string()); | 208 EXPECT_EQ(std::string("ghi\0j", 5), string_file.string()); |
209 parent.Verify(); | 209 parent.Verify(); |
210 } | 210 } |
211 | 211 |
212 { | 212 { |
213 SCOPED_TRACE("base alignment 4"); | 213 SCOPED_TRACE("base alignment 4"); |
214 writer.Reset(); | 214 string_file.Reset(); |
215 TestStringMinidumpWritable parent; | 215 TestStringMinidumpWritable parent; |
216 parent.SetData("klmn"); | 216 parent.SetData("klmn"); |
217 TestStringMinidumpWritable child; | 217 TestStringMinidumpWritable child; |
218 child.SetData("o"); | 218 child.SetData("o"); |
219 parent.AddChild(&child); | 219 parent.AddChild(&child); |
220 EXPECT_TRUE(parent.WriteEverything(&writer)); | 220 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
221 EXPECT_EQ(5u, writer.string().size()); | 221 EXPECT_EQ(5u, string_file.string().size()); |
222 EXPECT_EQ("klmno", writer.string()); | 222 EXPECT_EQ("klmno", string_file.string()); |
223 parent.Verify(); | 223 parent.Verify(); |
224 } | 224 } |
225 | 225 |
226 { | 226 { |
227 SCOPED_TRACE("base alignment 5"); | 227 SCOPED_TRACE("base alignment 5"); |
228 writer.Reset(); | 228 string_file.Reset(); |
229 TestStringMinidumpWritable parent; | 229 TestStringMinidumpWritable parent; |
230 parent.SetData("pqrst"); | 230 parent.SetData("pqrst"); |
231 TestStringMinidumpWritable child; | 231 TestStringMinidumpWritable child; |
232 child.SetData("u"); | 232 child.SetData("u"); |
233 parent.AddChild(&child); | 233 parent.AddChild(&child); |
234 EXPECT_TRUE(parent.WriteEverything(&writer)); | 234 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
235 EXPECT_EQ(9u, writer.string().size()); | 235 EXPECT_EQ(9u, string_file.string().size()); |
236 EXPECT_EQ(std::string("pqrst\0\0\0u", 9), writer.string()); | 236 EXPECT_EQ(std::string("pqrst\0\0\0u", 9), string_file.string()); |
237 parent.Verify(); | 237 parent.Verify(); |
238 } | 238 } |
239 | 239 |
240 { | 240 { |
241 SCOPED_TRACE("two children"); | 241 SCOPED_TRACE("two children"); |
242 writer.Reset(); | 242 string_file.Reset(); |
243 TestStringMinidumpWritable parent; | 243 TestStringMinidumpWritable parent; |
244 parent.SetData("parent"); | 244 parent.SetData("parent"); |
245 TestStringMinidumpWritable child_0; | 245 TestStringMinidumpWritable child_0; |
246 child_0.SetData("child_0"); | 246 child_0.SetData("child_0"); |
247 parent.AddChild(&child_0); | 247 parent.AddChild(&child_0); |
248 TestStringMinidumpWritable child_1; | 248 TestStringMinidumpWritable child_1; |
249 child_1.SetData("child_1"); | 249 child_1.SetData("child_1"); |
250 parent.AddChild(&child_1); | 250 parent.AddChild(&child_1); |
251 EXPECT_TRUE(parent.WriteEverything(&writer)); | 251 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
252 EXPECT_EQ(23u, writer.string().size()); | 252 EXPECT_EQ(23u, string_file.string().size()); |
253 EXPECT_EQ(std::string("parent\0\0child_0\0child_1", 23), writer.string()); | 253 EXPECT_EQ(std::string("parent\0\0child_0\0child_1", 23), string_file.string(
)); |
254 parent.Verify(); | 254 parent.Verify(); |
255 } | 255 } |
256 | 256 |
257 { | 257 { |
258 SCOPED_TRACE("grandchild"); | 258 SCOPED_TRACE("grandchild"); |
259 writer.Reset(); | 259 string_file.Reset(); |
260 TestStringMinidumpWritable parent; | 260 TestStringMinidumpWritable parent; |
261 parent.SetData("parent"); | 261 parent.SetData("parent"); |
262 TestStringMinidumpWritable child; | 262 TestStringMinidumpWritable child; |
263 child.SetData("child"); | 263 child.SetData("child"); |
264 parent.AddChild(&child); | 264 parent.AddChild(&child); |
265 TestStringMinidumpWritable grandchild; | 265 TestStringMinidumpWritable grandchild; |
266 grandchild.SetData("grandchild"); | 266 grandchild.SetData("grandchild"); |
267 child.AddChild(&grandchild); | 267 child.AddChild(&grandchild); |
268 EXPECT_TRUE(parent.WriteEverything(&writer)); | 268 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
269 EXPECT_EQ(26u, writer.string().size()); | 269 EXPECT_EQ(26u, string_file.string().size()); |
270 EXPECT_EQ(std::string("parent\0\0child\0\0\0grandchild", 26), | 270 EXPECT_EQ(std::string("parent\0\0child\0\0\0grandchild", 26), |
271 writer.string()); | 271 string_file.string()); |
272 parent.Verify(); | 272 parent.Verify(); |
273 } | 273 } |
274 | 274 |
275 { | 275 { |
276 SCOPED_TRACE("grandchild with empty parent"); | 276 SCOPED_TRACE("grandchild with empty parent"); |
277 writer.Reset(); | 277 string_file.Reset(); |
278 TestStringMinidumpWritable parent; | 278 TestStringMinidumpWritable parent; |
279 TestStringMinidumpWritable child; | 279 TestStringMinidumpWritable child; |
280 child.SetData("child"); | 280 child.SetData("child"); |
281 parent.AddChild(&child); | 281 parent.AddChild(&child); |
282 TestStringMinidumpWritable grandchild; | 282 TestStringMinidumpWritable grandchild; |
283 grandchild.SetData("grandchild"); | 283 grandchild.SetData("grandchild"); |
284 child.AddChild(&grandchild); | 284 child.AddChild(&grandchild); |
285 EXPECT_TRUE(parent.WriteEverything(&writer)); | 285 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
286 EXPECT_EQ(18u, writer.string().size()); | 286 EXPECT_EQ(18u, string_file.string().size()); |
287 EXPECT_EQ(std::string("child\0\0\0grandchild", 18), writer.string()); | 287 EXPECT_EQ(std::string("child\0\0\0grandchild", 18), string_file.string()); |
288 parent.Verify(); | 288 parent.Verify(); |
289 } | 289 } |
290 | 290 |
291 { | 291 { |
292 SCOPED_TRACE("grandchild with empty child"); | 292 SCOPED_TRACE("grandchild with empty child"); |
293 writer.Reset(); | 293 string_file.Reset(); |
294 TestStringMinidumpWritable parent; | 294 TestStringMinidumpWritable parent; |
295 parent.SetData("parent"); | 295 parent.SetData("parent"); |
296 TestStringMinidumpWritable child; | 296 TestStringMinidumpWritable child; |
297 parent.AddChild(&child); | 297 parent.AddChild(&child); |
298 TestStringMinidumpWritable grandchild; | 298 TestStringMinidumpWritable grandchild; |
299 grandchild.SetData("grandchild"); | 299 grandchild.SetData("grandchild"); |
300 child.AddChild(&grandchild); | 300 child.AddChild(&grandchild); |
301 EXPECT_TRUE(parent.WriteEverything(&writer)); | 301 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
302 EXPECT_EQ(18u, writer.string().size()); | 302 EXPECT_EQ(18u, string_file.string().size()); |
303 EXPECT_EQ(std::string("parent\0\0grandchild", 18), writer.string()); | 303 EXPECT_EQ(std::string("parent\0\0grandchild", 18), string_file.string()); |
304 parent.Verify(); | 304 parent.Verify(); |
305 } | 305 } |
306 | 306 |
307 { | 307 { |
308 SCOPED_TRACE("grandchild with empty grandchild"); | 308 SCOPED_TRACE("grandchild with empty grandchild"); |
309 writer.Reset(); | 309 string_file.Reset(); |
310 TestStringMinidumpWritable parent; | 310 TestStringMinidumpWritable parent; |
311 parent.SetData("parent"); | 311 parent.SetData("parent"); |
312 TestStringMinidumpWritable child; | 312 TestStringMinidumpWritable child; |
313 child.SetData("child"); | 313 child.SetData("child"); |
314 parent.AddChild(&child); | 314 parent.AddChild(&child); |
315 TestStringMinidumpWritable grandchild; | 315 TestStringMinidumpWritable grandchild; |
316 child.AddChild(&grandchild); | 316 child.AddChild(&grandchild); |
317 EXPECT_TRUE(parent.WriteEverything(&writer)); | 317 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
318 EXPECT_EQ(13u, writer.string().size()); | 318 EXPECT_EQ(13u, string_file.string().size()); |
319 EXPECT_EQ(std::string("parent\0\0child", 13), writer.string()); | 319 EXPECT_EQ(std::string("parent\0\0child", 13), string_file.string()); |
320 parent.Verify(); | 320 parent.Verify(); |
321 } | 321 } |
322 | 322 |
323 { | 323 { |
324 SCOPED_TRACE("grandchild with late-phase grandchild"); | 324 SCOPED_TRACE("grandchild with late-phase grandchild"); |
325 writer.Reset(); | 325 string_file.Reset(); |
326 TestStringMinidumpWritable parent; | 326 TestStringMinidumpWritable parent; |
327 parent.SetData("parent"); | 327 parent.SetData("parent"); |
328 TestStringMinidumpWritable child; | 328 TestStringMinidumpWritable child; |
329 child.SetData("child"); | 329 child.SetData("child"); |
330 parent.AddChild(&child); | 330 parent.AddChild(&child); |
331 TestStringMinidumpWritable grandchild; | 331 TestStringMinidumpWritable grandchild; |
332 grandchild.SetData("grandchild"); | 332 grandchild.SetData("grandchild"); |
333 grandchild.SetPhaseLate(); | 333 grandchild.SetPhaseLate(); |
334 child.AddChild(&grandchild); | 334 child.AddChild(&grandchild); |
335 EXPECT_TRUE(parent.WriteEverything(&writer)); | 335 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
336 EXPECT_EQ(26u, writer.string().size()); | 336 EXPECT_EQ(26u, string_file.string().size()); |
337 EXPECT_EQ(std::string("parent\0\0child\0\0\0grandchild", 26), | 337 EXPECT_EQ(std::string("parent\0\0child\0\0\0grandchild", 26), |
338 writer.string()); | 338 string_file.string()); |
339 parent.Verify(); | 339 parent.Verify(); |
340 } | 340 } |
341 | 341 |
342 { | 342 { |
343 SCOPED_TRACE("grandchild with late-phase child"); | 343 SCOPED_TRACE("grandchild with late-phase child"); |
344 writer.Reset(); | 344 string_file.Reset(); |
345 TestStringMinidumpWritable parent; | 345 TestStringMinidumpWritable parent; |
346 parent.SetData("parent"); | 346 parent.SetData("parent"); |
347 TestStringMinidumpWritable child; | 347 TestStringMinidumpWritable child; |
348 child.SetData("child"); | 348 child.SetData("child"); |
349 child.SetPhaseLate(); | 349 child.SetPhaseLate(); |
350 parent.AddChild(&child); | 350 parent.AddChild(&child); |
351 TestStringMinidumpWritable grandchild; | 351 TestStringMinidumpWritable grandchild; |
352 grandchild.SetData("grandchild"); | 352 grandchild.SetData("grandchild"); |
353 child.AddChild(&grandchild); | 353 child.AddChild(&grandchild); |
354 EXPECT_TRUE(parent.WriteEverything(&writer)); | 354 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
355 EXPECT_EQ(25u, writer.string().size()); | 355 EXPECT_EQ(25u, string_file.string().size()); |
356 EXPECT_EQ(std::string("parent\0\0grandchild\0\0child", 25), | 356 EXPECT_EQ(std::string("parent\0\0grandchild\0\0child", 25), |
357 writer.string()); | 357 string_file.string()); |
358 parent.Verify(); | 358 parent.Verify(); |
359 } | 359 } |
360 | 360 |
361 { | 361 { |
362 SCOPED_TRACE("family tree"); | 362 SCOPED_TRACE("family tree"); |
363 writer.Reset(); | 363 string_file.Reset(); |
364 TestStringMinidumpWritable parent; | 364 TestStringMinidumpWritable parent; |
365 parent.SetData("P.."); | 365 parent.SetData("P.."); |
366 TestStringMinidumpWritable child_0; | 366 TestStringMinidumpWritable child_0; |
367 child_0.SetData("C0."); | 367 child_0.SetData("C0."); |
368 parent.AddChild(&child_0); | 368 parent.AddChild(&child_0); |
369 TestStringMinidumpWritable child_1; | 369 TestStringMinidumpWritable child_1; |
370 child_1.SetData("C1."); | 370 child_1.SetData("C1."); |
371 parent.AddChild(&child_1); | 371 parent.AddChild(&child_1); |
372 TestStringMinidumpWritable grandchild_00; | 372 TestStringMinidumpWritable grandchild_00; |
373 grandchild_00.SetData("G00"); | 373 grandchild_00.SetData("G00"); |
374 child_0.AddChild(&grandchild_00); | 374 child_0.AddChild(&grandchild_00); |
375 TestStringMinidumpWritable grandchild_01; | 375 TestStringMinidumpWritable grandchild_01; |
376 grandchild_01.SetData("G01"); | 376 grandchild_01.SetData("G01"); |
377 child_0.AddChild(&grandchild_01); | 377 child_0.AddChild(&grandchild_01); |
378 TestStringMinidumpWritable grandchild_10; | 378 TestStringMinidumpWritable grandchild_10; |
379 grandchild_10.SetData("G10"); | 379 grandchild_10.SetData("G10"); |
380 child_1.AddChild(&grandchild_10); | 380 child_1.AddChild(&grandchild_10); |
381 TestStringMinidumpWritable grandchild_11; | 381 TestStringMinidumpWritable grandchild_11; |
382 grandchild_11.SetData("G11"); | 382 grandchild_11.SetData("G11"); |
383 child_1.AddChild(&grandchild_11); | 383 child_1.AddChild(&grandchild_11); |
384 EXPECT_TRUE(parent.WriteEverything(&writer)); | 384 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
385 EXPECT_EQ(27u, writer.string().size()); | 385 EXPECT_EQ(27u, string_file.string().size()); |
386 EXPECT_EQ(std::string("P..\0C0.\0G00\0G01\0C1.\0G10\0G11", 27), | 386 EXPECT_EQ(std::string("P..\0C0.\0G00\0G01\0C1.\0G10\0G11", 27), |
387 writer.string()); | 387 string_file.string()); |
388 parent.Verify(); | 388 parent.Verify(); |
389 } | 389 } |
390 | 390 |
391 { | 391 { |
392 SCOPED_TRACE("family tree with C0 late"); | 392 SCOPED_TRACE("family tree with C0 late"); |
393 writer.Reset(); | 393 string_file.Reset(); |
394 TestStringMinidumpWritable parent; | 394 TestStringMinidumpWritable parent; |
395 parent.SetData("P.."); | 395 parent.SetData("P.."); |
396 TestStringMinidumpWritable child_0; | 396 TestStringMinidumpWritable child_0; |
397 child_0.SetData("C0."); | 397 child_0.SetData("C0."); |
398 child_0.SetPhaseLate(); | 398 child_0.SetPhaseLate(); |
399 parent.AddChild(&child_0); | 399 parent.AddChild(&child_0); |
400 TestStringMinidumpWritable child_1; | 400 TestStringMinidumpWritable child_1; |
401 child_1.SetData("C1."); | 401 child_1.SetData("C1."); |
402 parent.AddChild(&child_1); | 402 parent.AddChild(&child_1); |
403 TestStringMinidumpWritable grandchild_00; | 403 TestStringMinidumpWritable grandchild_00; |
404 grandchild_00.SetData("G00"); | 404 grandchild_00.SetData("G00"); |
405 child_0.AddChild(&grandchild_00); | 405 child_0.AddChild(&grandchild_00); |
406 TestStringMinidumpWritable grandchild_01; | 406 TestStringMinidumpWritable grandchild_01; |
407 grandchild_01.SetData("G01"); | 407 grandchild_01.SetData("G01"); |
408 child_0.AddChild(&grandchild_01); | 408 child_0.AddChild(&grandchild_01); |
409 TestStringMinidumpWritable grandchild_10; | 409 TestStringMinidumpWritable grandchild_10; |
410 grandchild_10.SetData("G10"); | 410 grandchild_10.SetData("G10"); |
411 child_1.AddChild(&grandchild_10); | 411 child_1.AddChild(&grandchild_10); |
412 TestStringMinidumpWritable grandchild_11; | 412 TestStringMinidumpWritable grandchild_11; |
413 grandchild_11.SetData("G11"); | 413 grandchild_11.SetData("G11"); |
414 child_1.AddChild(&grandchild_11); | 414 child_1.AddChild(&grandchild_11); |
415 EXPECT_TRUE(parent.WriteEverything(&writer)); | 415 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
416 EXPECT_EQ(27u, writer.string().size()); | 416 EXPECT_EQ(27u, string_file.string().size()); |
417 EXPECT_EQ(std::string("P..\0G00\0G01\0C1.\0G10\0G11\0C0.", 27), | 417 EXPECT_EQ(std::string("P..\0G00\0G01\0C1.\0G10\0G11\0C0.", 27), |
418 writer.string()); | 418 string_file.string()); |
419 parent.Verify(); | 419 parent.Verify(); |
420 } | 420 } |
421 | 421 |
422 { | 422 { |
423 SCOPED_TRACE("family tree with G0 late"); | 423 SCOPED_TRACE("family tree with G0 late"); |
424 writer.Reset(); | 424 string_file.Reset(); |
425 TestStringMinidumpWritable parent; | 425 TestStringMinidumpWritable parent; |
426 parent.SetData("P.."); | 426 parent.SetData("P.."); |
427 TestStringMinidumpWritable child_0; | 427 TestStringMinidumpWritable child_0; |
428 child_0.SetData("C0."); | 428 child_0.SetData("C0."); |
429 parent.AddChild(&child_0); | 429 parent.AddChild(&child_0); |
430 TestStringMinidumpWritable child_1; | 430 TestStringMinidumpWritable child_1; |
431 child_1.SetData("C1."); | 431 child_1.SetData("C1."); |
432 parent.AddChild(&child_1); | 432 parent.AddChild(&child_1); |
433 TestStringMinidumpWritable grandchild_00; | 433 TestStringMinidumpWritable grandchild_00; |
434 grandchild_00.SetData("G00"); | 434 grandchild_00.SetData("G00"); |
435 grandchild_00.SetPhaseLate(); | 435 grandchild_00.SetPhaseLate(); |
436 child_0.AddChild(&grandchild_00); | 436 child_0.AddChild(&grandchild_00); |
437 TestStringMinidumpWritable grandchild_01; | 437 TestStringMinidumpWritable grandchild_01; |
438 grandchild_01.SetData("G01"); | 438 grandchild_01.SetData("G01"); |
439 grandchild_01.SetPhaseLate(); | 439 grandchild_01.SetPhaseLate(); |
440 child_0.AddChild(&grandchild_01); | 440 child_0.AddChild(&grandchild_01); |
441 TestStringMinidumpWritable grandchild_10; | 441 TestStringMinidumpWritable grandchild_10; |
442 grandchild_10.SetData("G10"); | 442 grandchild_10.SetData("G10"); |
443 child_1.AddChild(&grandchild_10); | 443 child_1.AddChild(&grandchild_10); |
444 TestStringMinidumpWritable grandchild_11; | 444 TestStringMinidumpWritable grandchild_11; |
445 grandchild_11.SetData("G11"); | 445 grandchild_11.SetData("G11"); |
446 child_1.AddChild(&grandchild_11); | 446 child_1.AddChild(&grandchild_11); |
447 EXPECT_TRUE(parent.WriteEverything(&writer)); | 447 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
448 EXPECT_EQ(27u, writer.string().size()); | 448 EXPECT_EQ(27u, string_file.string().size()); |
449 EXPECT_EQ(std::string("P..\0C0.\0C1.\0G10\0G11\0G00\0G01", 27), | 449 EXPECT_EQ(std::string("P..\0C0.\0C1.\0G10\0G11\0G00\0G01", 27), |
450 writer.string()); | 450 string_file.string()); |
451 parent.Verify(); | 451 parent.Verify(); |
452 } | 452 } |
453 | 453 |
454 { | 454 { |
455 SCOPED_TRACE("align 1"); | 455 SCOPED_TRACE("align 1"); |
456 writer.Reset(); | 456 string_file.Reset(); |
457 TestStringMinidumpWritable parent; | 457 TestStringMinidumpWritable parent; |
458 parent.SetData("p"); | 458 parent.SetData("p"); |
459 TestStringMinidumpWritable child; | 459 TestStringMinidumpWritable child; |
460 child.SetData("c"); | 460 child.SetData("c"); |
461 child.SetAlignment(1); | 461 child.SetAlignment(1); |
462 parent.AddChild(&child); | 462 parent.AddChild(&child); |
463 EXPECT_TRUE(parent.WriteEverything(&writer)); | 463 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
464 EXPECT_EQ(2u, writer.string().size()); | 464 EXPECT_EQ(2u, string_file.string().size()); |
465 EXPECT_EQ("pc", writer.string()); | 465 EXPECT_EQ("pc", string_file.string()); |
466 parent.Verify(); | 466 parent.Verify(); |
467 } | 467 } |
468 | 468 |
469 { | 469 { |
470 SCOPED_TRACE("align 2"); | 470 SCOPED_TRACE("align 2"); |
471 writer.Reset(); | 471 string_file.Reset(); |
472 TestStringMinidumpWritable parent; | 472 TestStringMinidumpWritable parent; |
473 parent.SetData("p"); | 473 parent.SetData("p"); |
474 TestStringMinidumpWritable child; | 474 TestStringMinidumpWritable child; |
475 child.SetData("c"); | 475 child.SetData("c"); |
476 child.SetAlignment(2); | 476 child.SetAlignment(2); |
477 parent.AddChild(&child); | 477 parent.AddChild(&child); |
478 EXPECT_TRUE(parent.WriteEverything(&writer)); | 478 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
479 EXPECT_EQ(3u, writer.string().size()); | 479 EXPECT_EQ(3u, string_file.string().size()); |
480 EXPECT_EQ(std::string("p\0c", 3), writer.string()); | 480 EXPECT_EQ(std::string("p\0c", 3), string_file.string()); |
481 parent.Verify(); | 481 parent.Verify(); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 class TestRVAMinidumpWritable final : public BaseTestMinidumpWritable { | 485 class TestRVAMinidumpWritable final : public BaseTestMinidumpWritable { |
486 public: | 486 public: |
487 TestRVAMinidumpWritable() : BaseTestMinidumpWritable(), rva_() {} | 487 TestRVAMinidumpWritable() : BaseTestMinidumpWritable(), rva_() {} |
488 | 488 |
489 ~TestRVAMinidumpWritable() {} | 489 ~TestRVAMinidumpWritable() {} |
490 | 490 |
(...skipping 15 matching lines...) Expand all Loading... |
506 RVA rva_; | 506 RVA rva_; |
507 | 507 |
508 DISALLOW_COPY_AND_ASSIGN(TestRVAMinidumpWritable); | 508 DISALLOW_COPY_AND_ASSIGN(TestRVAMinidumpWritable); |
509 }; | 509 }; |
510 | 510 |
511 RVA RVAAtIndex(const std::string& string, size_t index) { | 511 RVA RVAAtIndex(const std::string& string, size_t index) { |
512 return *reinterpret_cast<const RVA*>(&string[index * sizeof(RVA)]); | 512 return *reinterpret_cast<const RVA*>(&string[index * sizeof(RVA)]); |
513 } | 513 } |
514 | 514 |
515 TEST(MinidumpWritable, RVA) { | 515 TEST(MinidumpWritable, RVA) { |
516 StringFileWriter writer; | 516 StringFile string_file; |
517 | 517 |
518 { | 518 { |
519 SCOPED_TRACE("unset"); | 519 SCOPED_TRACE("unset"); |
520 writer.Reset(); | 520 string_file.Reset(); |
521 TestRVAMinidumpWritable rva_writable; | 521 TestRVAMinidumpWritable rva_writable; |
522 EXPECT_TRUE(rva_writable.WriteEverything(&writer)); | 522 EXPECT_TRUE(rva_writable.WriteEverything(&string_file)); |
523 | 523 |
524 ASSERT_EQ(sizeof(RVA), writer.string().size()); | 524 ASSERT_EQ(sizeof(RVA), string_file.string().size()); |
525 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(writer.string(), 0)); | 525 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(string_file.string(), 0)); |
526 rva_writable.Verify(); | 526 rva_writable.Verify(); |
527 } | 527 } |
528 | 528 |
529 { | 529 { |
530 SCOPED_TRACE("self"); | 530 SCOPED_TRACE("self"); |
531 writer.Reset(); | 531 string_file.Reset(); |
532 TestRVAMinidumpWritable rva_writable; | 532 TestRVAMinidumpWritable rva_writable; |
533 rva_writable.SetRVA(&rva_writable); | 533 rva_writable.SetRVA(&rva_writable); |
534 EXPECT_TRUE(rva_writable.WriteEverything(&writer)); | 534 EXPECT_TRUE(rva_writable.WriteEverything(&string_file)); |
535 | 535 |
536 ASSERT_EQ(sizeof(RVA), writer.string().size()); | 536 ASSERT_EQ(sizeof(RVA), string_file.string().size()); |
537 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(writer.string(), 0)); | 537 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(string_file.string(), 0)); |
538 rva_writable.Verify(); | 538 rva_writable.Verify(); |
539 } | 539 } |
540 | 540 |
541 { | 541 { |
542 SCOPED_TRACE("parent-child self"); | 542 SCOPED_TRACE("parent-child self"); |
543 writer.Reset(); | 543 string_file.Reset(); |
544 TestRVAMinidumpWritable parent; | 544 TestRVAMinidumpWritable parent; |
545 parent.SetRVA(&parent); | 545 parent.SetRVA(&parent); |
546 TestRVAMinidumpWritable child; | 546 TestRVAMinidumpWritable child; |
547 child.SetRVA(&child); | 547 child.SetRVA(&child); |
548 parent.AddChild(&child); | 548 parent.AddChild(&child); |
549 EXPECT_TRUE(parent.WriteEverything(&writer)); | 549 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
550 | 550 |
551 ASSERT_EQ(2 * sizeof(RVA), writer.string().size()); | 551 ASSERT_EQ(2 * sizeof(RVA), string_file.string().size()); |
552 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(writer.string(), 0)); | 552 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(string_file.string(), 0)); |
553 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 1)); | 553 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 1)); |
554 parent.Verify(); | 554 parent.Verify(); |
555 } | 555 } |
556 | 556 |
557 { | 557 { |
558 SCOPED_TRACE("parent-child only"); | 558 SCOPED_TRACE("parent-child only"); |
559 writer.Reset(); | 559 string_file.Reset(); |
560 TestRVAMinidumpWritable parent; | 560 TestRVAMinidumpWritable parent; |
561 TestRVAMinidumpWritable child; | 561 TestRVAMinidumpWritable child; |
562 parent.SetRVA(&child); | 562 parent.SetRVA(&child); |
563 parent.AddChild(&child); | 563 parent.AddChild(&child); |
564 EXPECT_TRUE(parent.WriteEverything(&writer)); | 564 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
565 | 565 |
566 ASSERT_EQ(2 * sizeof(RVA), writer.string().size()); | 566 ASSERT_EQ(2 * sizeof(RVA), string_file.string().size()); |
567 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 0)); | 567 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 0)); |
568 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(writer.string(), 1)); | 568 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(string_file.string(), 1)); |
569 parent.Verify(); | 569 parent.Verify(); |
570 } | 570 } |
571 | 571 |
572 { | 572 { |
573 SCOPED_TRACE("parent-child circular"); | 573 SCOPED_TRACE("parent-child circular"); |
574 writer.Reset(); | 574 string_file.Reset(); |
575 TestRVAMinidumpWritable parent; | 575 TestRVAMinidumpWritable parent; |
576 TestRVAMinidumpWritable child; | 576 TestRVAMinidumpWritable child; |
577 parent.SetRVA(&child); | 577 parent.SetRVA(&child); |
578 child.SetRVA(&parent); | 578 child.SetRVA(&parent); |
579 parent.AddChild(&child); | 579 parent.AddChild(&child); |
580 EXPECT_TRUE(parent.WriteEverything(&writer)); | 580 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
581 | 581 |
582 ASSERT_EQ(2 * sizeof(RVA), writer.string().size()); | 582 ASSERT_EQ(2 * sizeof(RVA), string_file.string().size()); |
583 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 0)); | 583 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 0)); |
584 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(writer.string(), 1)); | 584 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(string_file.string(), 1)); |
585 parent.Verify(); | 585 parent.Verify(); |
586 } | 586 } |
587 | 587 |
588 { | 588 { |
589 SCOPED_TRACE("grandchildren"); | 589 SCOPED_TRACE("grandchildren"); |
590 writer.Reset(); | 590 string_file.Reset(); |
591 TestRVAMinidumpWritable parent; | 591 TestRVAMinidumpWritable parent; |
592 TestRVAMinidumpWritable child; | 592 TestRVAMinidumpWritable child; |
593 parent.SetRVA(&child); | 593 parent.SetRVA(&child); |
594 parent.AddChild(&child); | 594 parent.AddChild(&child); |
595 TestRVAMinidumpWritable grandchild_0; | 595 TestRVAMinidumpWritable grandchild_0; |
596 grandchild_0.SetRVA(&child); | 596 grandchild_0.SetRVA(&child); |
597 child.AddChild(&grandchild_0); | 597 child.AddChild(&grandchild_0); |
598 TestRVAMinidumpWritable grandchild_1; | 598 TestRVAMinidumpWritable grandchild_1; |
599 grandchild_1.SetRVA(&child); | 599 grandchild_1.SetRVA(&child); |
600 child.AddChild(&grandchild_1); | 600 child.AddChild(&grandchild_1); |
601 TestRVAMinidumpWritable grandchild_2; | 601 TestRVAMinidumpWritable grandchild_2; |
602 grandchild_2.SetRVA(&child); | 602 grandchild_2.SetRVA(&child); |
603 child.AddChild(&grandchild_2); | 603 child.AddChild(&grandchild_2); |
604 EXPECT_TRUE(parent.WriteEverything(&writer)); | 604 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
605 | 605 |
606 ASSERT_EQ(5 * sizeof(RVA), writer.string().size()); | 606 ASSERT_EQ(5 * sizeof(RVA), string_file.string().size()); |
607 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 0)); | 607 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 0)); |
608 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(writer.string(), 1)); | 608 EXPECT_EQ(0 * sizeof(RVA), RVAAtIndex(string_file.string(), 1)); |
609 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 2)); | 609 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 2)); |
610 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 3)); | 610 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 3)); |
611 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(writer.string(), 4)); | 611 EXPECT_EQ(1 * sizeof(RVA), RVAAtIndex(string_file.string(), 4)); |
612 parent.Verify(); | 612 parent.Verify(); |
613 } | 613 } |
614 } | 614 } |
615 | 615 |
616 class TestLocationDescriptorMinidumpWritable final | 616 class TestLocationDescriptorMinidumpWritable final |
617 : public BaseTestMinidumpWritable { | 617 : public BaseTestMinidumpWritable { |
618 public: | 618 public: |
619 TestLocationDescriptorMinidumpWritable() | 619 TestLocationDescriptorMinidumpWritable() |
620 : BaseTestMinidumpWritable(), location_descriptor_(), string_() {} | 620 : BaseTestMinidumpWritable(), location_descriptor_(), string_() {} |
621 | 621 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; | 659 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; |
660 char string[1]; | 660 char string[1]; |
661 }; | 661 }; |
662 | 662 |
663 const LocationDescriptorAndData* LDDAtIndex(const std::string& string, | 663 const LocationDescriptorAndData* LDDAtIndex(const std::string& string, |
664 size_t index) { | 664 size_t index) { |
665 return reinterpret_cast<const LocationDescriptorAndData*>(&string[index]); | 665 return reinterpret_cast<const LocationDescriptorAndData*>(&string[index]); |
666 } | 666 } |
667 | 667 |
668 TEST(MinidumpWritable, LocationDescriptor) { | 668 TEST(MinidumpWritable, LocationDescriptor) { |
669 StringFileWriter writer; | 669 StringFile string_file; |
670 | 670 |
671 { | 671 { |
672 SCOPED_TRACE("unset"); | 672 SCOPED_TRACE("unset"); |
673 writer.Reset(); | 673 string_file.Reset(); |
674 TestLocationDescriptorMinidumpWritable location_descriptor_writable; | 674 TestLocationDescriptorMinidumpWritable location_descriptor_writable; |
675 EXPECT_TRUE(location_descriptor_writable.WriteEverything(&writer)); | 675 EXPECT_TRUE(location_descriptor_writable.WriteEverything(&string_file)); |
676 | 676 |
677 ASSERT_EQ(9u, writer.string().size()); | 677 ASSERT_EQ(9u, string_file.string().size()); |
678 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 678 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
679 EXPECT_EQ(0u, ldd->location_descriptor.DataSize); | 679 EXPECT_EQ(0u, ldd->location_descriptor.DataSize); |
680 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 680 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
681 location_descriptor_writable.Verify(); | 681 location_descriptor_writable.Verify(); |
682 } | 682 } |
683 | 683 |
684 { | 684 { |
685 SCOPED_TRACE("self"); | 685 SCOPED_TRACE("self"); |
686 writer.Reset(); | 686 string_file.Reset(); |
687 TestLocationDescriptorMinidumpWritable location_descriptor_writable; | 687 TestLocationDescriptorMinidumpWritable location_descriptor_writable; |
688 location_descriptor_writable.SetLocationDescriptor( | 688 location_descriptor_writable.SetLocationDescriptor( |
689 &location_descriptor_writable); | 689 &location_descriptor_writable); |
690 EXPECT_TRUE(location_descriptor_writable.WriteEverything(&writer)); | 690 EXPECT_TRUE(location_descriptor_writable.WriteEverything(&string_file)); |
691 | 691 |
692 ASSERT_EQ(9u, writer.string().size()); | 692 ASSERT_EQ(9u, string_file.string().size()); |
693 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 693 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
694 EXPECT_EQ(9u, ldd->location_descriptor.DataSize); | 694 EXPECT_EQ(9u, ldd->location_descriptor.DataSize); |
695 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 695 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
696 location_descriptor_writable.Verify(); | 696 location_descriptor_writable.Verify(); |
697 } | 697 } |
698 | 698 |
699 { | 699 { |
700 SCOPED_TRACE("self with data"); | 700 SCOPED_TRACE("self with data"); |
701 writer.Reset(); | 701 string_file.Reset(); |
702 TestLocationDescriptorMinidumpWritable location_descriptor_writable; | 702 TestLocationDescriptorMinidumpWritable location_descriptor_writable; |
703 location_descriptor_writable.SetLocationDescriptor( | 703 location_descriptor_writable.SetLocationDescriptor( |
704 &location_descriptor_writable); | 704 &location_descriptor_writable); |
705 location_descriptor_writable.SetString("zz"); | 705 location_descriptor_writable.SetString("zz"); |
706 EXPECT_TRUE(location_descriptor_writable.WriteEverything(&writer)); | 706 EXPECT_TRUE(location_descriptor_writable.WriteEverything(&string_file)); |
707 | 707 |
708 ASSERT_EQ(11u, writer.string().size()); | 708 ASSERT_EQ(11u, string_file.string().size()); |
709 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 709 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
710 EXPECT_EQ(11u, ldd->location_descriptor.DataSize); | 710 EXPECT_EQ(11u, ldd->location_descriptor.DataSize); |
711 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 711 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
712 EXPECT_STREQ("zz", ldd->string); | 712 EXPECT_STREQ("zz", ldd->string); |
713 location_descriptor_writable.Verify(); | 713 location_descriptor_writable.Verify(); |
714 } | 714 } |
715 | 715 |
716 { | 716 { |
717 SCOPED_TRACE("parent-child self"); | 717 SCOPED_TRACE("parent-child self"); |
718 writer.Reset(); | 718 string_file.Reset(); |
719 TestLocationDescriptorMinidumpWritable parent; | 719 TestLocationDescriptorMinidumpWritable parent; |
720 parent.SetLocationDescriptor(&parent); | 720 parent.SetLocationDescriptor(&parent); |
721 parent.SetString("yy"); | 721 parent.SetString("yy"); |
722 TestLocationDescriptorMinidumpWritable child; | 722 TestLocationDescriptorMinidumpWritable child; |
723 child.SetLocationDescriptor(&child); | 723 child.SetLocationDescriptor(&child); |
724 child.SetString("x"); | 724 child.SetString("x"); |
725 parent.AddChild(&child); | 725 parent.AddChild(&child); |
726 EXPECT_TRUE(parent.WriteEverything(&writer)); | 726 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
727 | 727 |
728 ASSERT_EQ(22u, writer.string().size()); | 728 ASSERT_EQ(22u, string_file.string().size()); |
729 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 729 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
730 EXPECT_EQ(11u, ldd->location_descriptor.DataSize); | 730 EXPECT_EQ(11u, ldd->location_descriptor.DataSize); |
731 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 731 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
732 EXPECT_STREQ("yy", ldd->string); | 732 EXPECT_STREQ("yy", ldd->string); |
733 ldd = LDDAtIndex(writer.string(), 12); | 733 ldd = LDDAtIndex(string_file.string(), 12); |
734 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); | 734 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); |
735 EXPECT_EQ(12u, ldd->location_descriptor.Rva); | 735 EXPECT_EQ(12u, ldd->location_descriptor.Rva); |
736 EXPECT_STREQ("x", ldd->string); | 736 EXPECT_STREQ("x", ldd->string); |
737 parent.Verify(); | 737 parent.Verify(); |
738 } | 738 } |
739 | 739 |
740 { | 740 { |
741 SCOPED_TRACE("parent-child only"); | 741 SCOPED_TRACE("parent-child only"); |
742 writer.Reset(); | 742 string_file.Reset(); |
743 TestLocationDescriptorMinidumpWritable parent; | 743 TestLocationDescriptorMinidumpWritable parent; |
744 TestLocationDescriptorMinidumpWritable child; | 744 TestLocationDescriptorMinidumpWritable child; |
745 parent.SetLocationDescriptor(&child); | 745 parent.SetLocationDescriptor(&child); |
746 parent.SetString("www"); | 746 parent.SetString("www"); |
747 child.SetString("vv"); | 747 child.SetString("vv"); |
748 parent.AddChild(&child); | 748 parent.AddChild(&child); |
749 EXPECT_TRUE(parent.WriteEverything(&writer)); | 749 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
750 | 750 |
751 ASSERT_EQ(23u, writer.string().size()); | 751 ASSERT_EQ(23u, string_file.string().size()); |
752 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 752 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
753 EXPECT_EQ(11u, ldd->location_descriptor.DataSize); | 753 EXPECT_EQ(11u, ldd->location_descriptor.DataSize); |
754 EXPECT_EQ(12u, ldd->location_descriptor.Rva); | 754 EXPECT_EQ(12u, ldd->location_descriptor.Rva); |
755 EXPECT_STREQ("www", ldd->string); | 755 EXPECT_STREQ("www", ldd->string); |
756 ldd = LDDAtIndex(writer.string(), 12); | 756 ldd = LDDAtIndex(string_file.string(), 12); |
757 EXPECT_EQ(0u, ldd->location_descriptor.DataSize); | 757 EXPECT_EQ(0u, ldd->location_descriptor.DataSize); |
758 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 758 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
759 EXPECT_STREQ("vv", ldd->string); | 759 EXPECT_STREQ("vv", ldd->string); |
760 parent.Verify(); | 760 parent.Verify(); |
761 } | 761 } |
762 | 762 |
763 { | 763 { |
764 SCOPED_TRACE("parent-child circular"); | 764 SCOPED_TRACE("parent-child circular"); |
765 writer.Reset(); | 765 string_file.Reset(); |
766 TestLocationDescriptorMinidumpWritable parent; | 766 TestLocationDescriptorMinidumpWritable parent; |
767 TestLocationDescriptorMinidumpWritable child; | 767 TestLocationDescriptorMinidumpWritable child; |
768 parent.SetLocationDescriptor(&child); | 768 parent.SetLocationDescriptor(&child); |
769 parent.SetString("uuuu"); | 769 parent.SetString("uuuu"); |
770 child.SetLocationDescriptor(&parent); | 770 child.SetLocationDescriptor(&parent); |
771 child.SetString("tttt"); | 771 child.SetString("tttt"); |
772 parent.AddChild(&child); | 772 parent.AddChild(&child); |
773 EXPECT_TRUE(parent.WriteEverything(&writer)); | 773 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
774 | 774 |
775 ASSERT_EQ(29u, writer.string().size()); | 775 ASSERT_EQ(29u, string_file.string().size()); |
776 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 776 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
777 EXPECT_EQ(13u, ldd->location_descriptor.DataSize); | 777 EXPECT_EQ(13u, ldd->location_descriptor.DataSize); |
778 EXPECT_EQ(16u, ldd->location_descriptor.Rva); | 778 EXPECT_EQ(16u, ldd->location_descriptor.Rva); |
779 EXPECT_STREQ("uuuu", ldd->string); | 779 EXPECT_STREQ("uuuu", ldd->string); |
780 ldd = LDDAtIndex(writer.string(), 16); | 780 ldd = LDDAtIndex(string_file.string(), 16); |
781 EXPECT_EQ(13u, ldd->location_descriptor.DataSize); | 781 EXPECT_EQ(13u, ldd->location_descriptor.DataSize); |
782 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 782 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
783 EXPECT_STREQ("tttt", ldd->string); | 783 EXPECT_STREQ("tttt", ldd->string); |
784 parent.Verify(); | 784 parent.Verify(); |
785 } | 785 } |
786 | 786 |
787 { | 787 { |
788 SCOPED_TRACE("grandchildren"); | 788 SCOPED_TRACE("grandchildren"); |
789 writer.Reset(); | 789 string_file.Reset(); |
790 TestLocationDescriptorMinidumpWritable parent; | 790 TestLocationDescriptorMinidumpWritable parent; |
791 TestLocationDescriptorMinidumpWritable child; | 791 TestLocationDescriptorMinidumpWritable child; |
792 parent.SetLocationDescriptor(&child); | 792 parent.SetLocationDescriptor(&child); |
793 parent.SetString("s"); | 793 parent.SetString("s"); |
794 parent.AddChild(&child); | 794 parent.AddChild(&child); |
795 child.SetString("r"); | 795 child.SetString("r"); |
796 TestLocationDescriptorMinidumpWritable grandchild_0; | 796 TestLocationDescriptorMinidumpWritable grandchild_0; |
797 grandchild_0.SetLocationDescriptor(&child); | 797 grandchild_0.SetLocationDescriptor(&child); |
798 grandchild_0.SetString("q"); | 798 grandchild_0.SetString("q"); |
799 child.AddChild(&grandchild_0); | 799 child.AddChild(&grandchild_0); |
800 TestLocationDescriptorMinidumpWritable grandchild_1; | 800 TestLocationDescriptorMinidumpWritable grandchild_1; |
801 grandchild_1.SetLocationDescriptor(&child); | 801 grandchild_1.SetLocationDescriptor(&child); |
802 grandchild_1.SetString("p"); | 802 grandchild_1.SetString("p"); |
803 child.AddChild(&grandchild_1); | 803 child.AddChild(&grandchild_1); |
804 TestLocationDescriptorMinidumpWritable grandchild_2; | 804 TestLocationDescriptorMinidumpWritable grandchild_2; |
805 grandchild_2.SetLocationDescriptor(&child); | 805 grandchild_2.SetLocationDescriptor(&child); |
806 grandchild_2.SetString("o"); | 806 grandchild_2.SetString("o"); |
807 child.AddChild(&grandchild_2); | 807 child.AddChild(&grandchild_2); |
808 EXPECT_TRUE(parent.WriteEverything(&writer)); | 808 EXPECT_TRUE(parent.WriteEverything(&string_file)); |
809 | 809 |
810 ASSERT_EQ(58u, writer.string().size()); | 810 ASSERT_EQ(58u, string_file.string().size()); |
811 const LocationDescriptorAndData* ldd = LDDAtIndex(writer.string(), 0); | 811 const LocationDescriptorAndData* ldd = LDDAtIndex(string_file.string(), 0); |
812 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); | 812 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); |
813 EXPECT_EQ(12u, ldd->location_descriptor.Rva); | 813 EXPECT_EQ(12u, ldd->location_descriptor.Rva); |
814 EXPECT_STREQ("s", ldd->string); | 814 EXPECT_STREQ("s", ldd->string); |
815 ldd = LDDAtIndex(writer.string(), 12); | 815 ldd = LDDAtIndex(string_file.string(), 12); |
816 EXPECT_EQ(0u, ldd->location_descriptor.DataSize); | 816 EXPECT_EQ(0u, ldd->location_descriptor.DataSize); |
817 EXPECT_EQ(0u, ldd->location_descriptor.Rva); | 817 EXPECT_EQ(0u, ldd->location_descriptor.Rva); |
818 EXPECT_STREQ("r", ldd->string); | 818 EXPECT_STREQ("r", ldd->string); |
819 ldd = LDDAtIndex(writer.string(), 24); | 819 ldd = LDDAtIndex(string_file.string(), 24); |
820 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); | 820 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); |
821 EXPECT_EQ(12u, ldd->location_descriptor.Rva); | 821 EXPECT_EQ(12u, ldd->location_descriptor.Rva); |
822 EXPECT_STREQ("q", ldd->string); | 822 EXPECT_STREQ("q", ldd->string); |
823 ldd = LDDAtIndex(writer.string(), 36); | 823 ldd = LDDAtIndex(string_file.string(), 36); |
824 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); | 824 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); |
825 EXPECT_EQ(12u, ldd->location_descriptor.Rva); | 825 EXPECT_EQ(12u, ldd->location_descriptor.Rva); |
826 EXPECT_STREQ("p", ldd->string); | 826 EXPECT_STREQ("p", ldd->string); |
827 ldd = LDDAtIndex(writer.string(), 48); | 827 ldd = LDDAtIndex(string_file.string(), 48); |
828 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); | 828 EXPECT_EQ(10u, ldd->location_descriptor.DataSize); |
829 EXPECT_EQ(12u, ldd->location_descriptor.Rva); | 829 EXPECT_EQ(12u, ldd->location_descriptor.Rva); |
830 EXPECT_STREQ("o", ldd->string); | 830 EXPECT_STREQ("o", ldd->string); |
831 parent.Verify(); | 831 parent.Verify(); |
832 } | 832 } |
833 } | 833 } |
834 | 834 |
835 } // namespace | 835 } // namespace |
836 } // namespace test | 836 } // namespace test |
837 } // namespace crashpad | 837 } // namespace crashpad |
OLD | NEW |