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

Side by Side Diff: minidump/minidump_module_writer_test.cc

Issue 643683003: minidump: Use variable names in tests that match parallel array indices (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rebase Created 6 years, 2 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_memory_writer_test.cc ('k') | no next file » | 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,
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 kDebugUTF16)); 487 kDebugUTF16));
488 } 488 }
489 489
490 TEST(MinidumpModuleWriter, ThreeModules) { 490 TEST(MinidumpModuleWriter, ThreeModules) {
491 // As good exercise, this test uses three modules, one with a PDB 7.0 link as 491 // As good exercise, this test uses three modules, one with a PDB 7.0 link as
492 // its CodeView record, one with no CodeView record, and one with a PDB 2.0 492 // its CodeView record, one with no CodeView record, and one with a PDB 2.0
493 // link as its CodeView record. 493 // link as its CodeView record.
494 MinidumpFileWriter minidump_file_writer; 494 MinidumpFileWriter minidump_file_writer;
495 MinidumpModuleListWriter module_list_writer; 495 MinidumpModuleListWriter module_list_writer;
496 496
497 const char kModuleName1[] = "main"; 497 const char kModuleName0[] = "main";
498 const uint64_t kModuleBase1 = 0x100101000; 498 const uint64_t kModuleBase0 = 0x100101000;
499 const uint32_t kModuleSize1 = 0xf000; 499 const uint32_t kModuleSize0 = 0xf000;
500 const char kPDBName1[] = "main"; 500 const char kPDBName0[] = "main";
501 const uint8_t kPDBUUIDBytes1[16] = 501 const uint8_t kPDBUUIDBytes0[16] =
502 {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 502 {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11,
503 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99}; 503 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
504 UUID pdb_uuid_1; 504 UUID pdb_uuid_0;
505 pdb_uuid_1.InitializeFromBytes(kPDBUUIDBytes1); 505 pdb_uuid_0.InitializeFromBytes(kPDBUUIDBytes0);
506 const uint32_t kPDBAge1 = 0; 506 const uint32_t kPDBAge0 = 0;
507 507
508 const char kModuleName2[] = "ld.so"; 508 const char kModuleName1[] = "ld.so";
509 const uint64_t kModuleBase2 = 0x200202000; 509 const uint64_t kModuleBase1 = 0x200202000;
510 const uint32_t kModuleSize2 = 0x1e000; 510 const uint32_t kModuleSize1 = 0x1e000;
511 511
512 const char kModuleName3[] = "libc.so"; 512 const char kModuleName2[] = "libc.so";
513 const uint64_t kModuleBase3 = 0x300303000; 513 const uint64_t kModuleBase2 = 0x300303000;
514 const uint32_t kModuleSize3 = 0x2d000; 514 const uint32_t kModuleSize2 = 0x2d000;
515 const char kPDBName3[] = "libc.so"; 515 const char kPDBName2[] = "libc.so";
516 const time_t kPDBTimestamp3 = 0x386d4380; 516 const time_t kPDBTimestamp2 = 0x386d4380;
517 const uint32_t kPDBAge3 = 2; 517 const uint32_t kPDBAge2 = 2;
518
519 MinidumpModuleWriter module_writer_0;
520 module_writer_0.SetName(kModuleName0);
521 module_writer_0.SetImageBaseAddress(kModuleBase0);
522 module_writer_0.SetImageSize(kModuleSize0);
523
524 MinidumpModuleCodeViewRecordPDB70Writer codeview_pdb70_writer_0;
525 codeview_pdb70_writer_0.SetPDBName(kPDBName0);
526 codeview_pdb70_writer_0.SetUUIDAndAge(pdb_uuid_0, kPDBAge0);
527 module_writer_0.SetCodeViewRecord(&codeview_pdb70_writer_0);
528
529 module_list_writer.AddModule(&module_writer_0);
518 530
519 MinidumpModuleWriter module_writer_1; 531 MinidumpModuleWriter module_writer_1;
520 module_writer_1.SetName(kModuleName1); 532 module_writer_1.SetName(kModuleName1);
521 module_writer_1.SetImageBaseAddress(kModuleBase1); 533 module_writer_1.SetImageBaseAddress(kModuleBase1);
522 module_writer_1.SetImageSize(kModuleSize1); 534 module_writer_1.SetImageSize(kModuleSize1);
523 535
524 MinidumpModuleCodeViewRecordPDB70Writer codeview_pdb70_writer_1;
525 codeview_pdb70_writer_1.SetPDBName(kPDBName1);
526 codeview_pdb70_writer_1.SetUUIDAndAge(pdb_uuid_1, kPDBAge1);
527 module_writer_1.SetCodeViewRecord(&codeview_pdb70_writer_1);
528
529 module_list_writer.AddModule(&module_writer_1); 536 module_list_writer.AddModule(&module_writer_1);
530 537
531 MinidumpModuleWriter module_writer_2; 538 MinidumpModuleWriter module_writer_2;
532 module_writer_2.SetName(kModuleName2); 539 module_writer_2.SetName(kModuleName2);
533 module_writer_2.SetImageBaseAddress(kModuleBase2); 540 module_writer_2.SetImageBaseAddress(kModuleBase2);
534 module_writer_2.SetImageSize(kModuleSize2); 541 module_writer_2.SetImageSize(kModuleSize2);
535 542
543 MinidumpModuleCodeViewRecordPDB20Writer codeview_pdb70_writer_2;
544 codeview_pdb70_writer_2.SetPDBName(kPDBName2);
545 codeview_pdb70_writer_2.SetTimestampAndAge(kPDBTimestamp2, kPDBAge2);
546 module_writer_2.SetCodeViewRecord(&codeview_pdb70_writer_2);
547
536 module_list_writer.AddModule(&module_writer_2); 548 module_list_writer.AddModule(&module_writer_2);
537 549
538 MinidumpModuleWriter module_writer_3;
539 module_writer_3.SetName(kModuleName3);
540 module_writer_3.SetImageBaseAddress(kModuleBase3);
541 module_writer_3.SetImageSize(kModuleSize3);
542
543 MinidumpModuleCodeViewRecordPDB20Writer codeview_pdb70_writer_3;
544 codeview_pdb70_writer_3.SetPDBName(kPDBName3);
545 codeview_pdb70_writer_3.SetTimestampAndAge(kPDBTimestamp3, kPDBAge3);
546 module_writer_3.SetCodeViewRecord(&codeview_pdb70_writer_3);
547
548 module_list_writer.AddModule(&module_writer_3);
549
550 minidump_file_writer.AddStream(&module_list_writer); 550 minidump_file_writer.AddStream(&module_list_writer);
551 551
552 StringFileWriter file_writer; 552 StringFileWriter file_writer;
553 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 553 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
554 554
555 ASSERT_GT(file_writer.string().size(), 555 ASSERT_GT(file_writer.string().size(),
556 sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 556 sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
557 sizeof(MINIDUMP_MODULE_LIST) + 1 * sizeof(MINIDUMP_MODULE)); 557 sizeof(MINIDUMP_MODULE_LIST) + 1 * sizeof(MINIDUMP_MODULE));
558 558
559 const MINIDUMP_MODULE_LIST* module_list; 559 const MINIDUMP_MODULE_LIST* module_list;
560 ASSERT_NO_FATAL_FAILURE( 560 ASSERT_NO_FATAL_FAILURE(
561 GetModuleListStream(file_writer.string(), &module_list)); 561 GetModuleListStream(file_writer.string(), &module_list));
562 562
563 EXPECT_EQ(3u, module_list->NumberOfModules); 563 EXPECT_EQ(3u, module_list->NumberOfModules);
564 564
565 MINIDUMP_MODULE expected = {}; 565 MINIDUMP_MODULE expected = {};
566 566
567 { 567 {
568 SCOPED_TRACE("module 0"); 568 SCOPED_TRACE("module 0");
569 569
570 expected.BaseOfImage = kModuleBase1; 570 expected.BaseOfImage = kModuleBase0;
571 expected.SizeOfImage = kModuleSize1; 571 expected.SizeOfImage = kModuleSize0;
572 572
573 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected, 573 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
574 &module_list->Modules[0], 574 &module_list->Modules[0],
575 file_writer.string(), 575 file_writer.string(),
576 kModuleName1, 576 kModuleName0,
577 kPDBName1, 577 kPDBName0,
578 &pdb_uuid_1, 578 &pdb_uuid_0,
579 0, 579 0,
580 kPDBAge1, 580 kPDBAge0,
581 NULL, 581 NULL,
582 0, 582 0,
583 false)); 583 false));
584 } 584 }
585 585
586 { 586 {
587 SCOPED_TRACE("module 1"); 587 SCOPED_TRACE("module 1");
588 588
589 expected.BaseOfImage = kModuleBase2; 589 expected.BaseOfImage = kModuleBase1;
590 expected.SizeOfImage = kModuleSize2; 590 expected.SizeOfImage = kModuleSize1;
591 591
592 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected, 592 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
593 &module_list->Modules[1], 593 &module_list->Modules[1],
594 file_writer.string(), 594 file_writer.string(),
595 kModuleName2, 595 kModuleName1,
596 NULL, 596 NULL,
597 NULL, 597 NULL,
598 0, 598 0,
599 0, 599 0,
600 NULL, 600 NULL,
601 0, 601 0,
602 false)); 602 false));
603 } 603 }
604 604
605 { 605 {
606 SCOPED_TRACE("module 2"); 606 SCOPED_TRACE("module 2");
607 607
608 expected.BaseOfImage = kModuleBase3; 608 expected.BaseOfImage = kModuleBase2;
609 expected.SizeOfImage = kModuleSize3; 609 expected.SizeOfImage = kModuleSize2;
610 610
611 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected, 611 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
612 &module_list->Modules[2], 612 &module_list->Modules[2],
613 file_writer.string(), 613 file_writer.string(),
614 kModuleName3, 614 kModuleName2,
615 kPDBName3, 615 kPDBName2,
616 NULL, 616 NULL,
617 kPDBTimestamp3, 617 kPDBTimestamp2,
618 kPDBAge3, 618 kPDBAge2,
619 NULL, 619 NULL,
620 0, 620 0,
621 false)); 621 false));
622 } 622 }
623 } 623 }
624 624
625 TEST(MinidumpSystemInfoWriterDeathTest, NoModuleName) { 625 TEST(MinidumpSystemInfoWriterDeathTest, NoModuleName) {
626 MinidumpFileWriter minidump_file_writer; 626 MinidumpFileWriter minidump_file_writer;
627 MinidumpModuleListWriter module_list_writer; 627 MinidumpModuleListWriter module_list_writer;
628 MinidumpModuleWriter module_writer; 628 MinidumpModuleWriter module_writer;
629 module_list_writer.AddModule(&module_writer); 629 module_list_writer.AddModule(&module_writer);
630 minidump_file_writer.AddStream(&module_list_writer); 630 minidump_file_writer.AddStream(&module_list_writer);
631 631
632 StringFileWriter file_writer; 632 StringFileWriter file_writer;
633 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "name_"); 633 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "name_");
634 } 634 }
635 635
636 } // namespace 636 } // namespace
637 } // namespace test 637 } // namespace test
638 } // namespace crashpad 638 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_memory_writer_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698