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

Side by Side Diff: minidump/minidump_module_writer_test.cc

Issue 656703002: Convert NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix 80-column violations 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_module_writer.cc ('k') | minidump/minidump_string_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,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 sizeof(MINIDUMP_MODULE_LIST), 74 sizeof(MINIDUMP_MODULE_LIST),
75 file_writer.string().size()); 75 file_writer.string().size());
76 76
77 const MINIDUMP_MODULE_LIST* module_list; 77 const MINIDUMP_MODULE_LIST* module_list;
78 ASSERT_NO_FATAL_FAILURE( 78 ASSERT_NO_FATAL_FAILURE(
79 GetModuleListStream(file_writer.string(), &module_list)); 79 GetModuleListStream(file_writer.string(), &module_list));
80 80
81 EXPECT_EQ(0u, module_list->NumberOfModules); 81 EXPECT_EQ(0u, module_list->NumberOfModules);
82 } 82 }
83 83
84 // If |expected_pdb_name| is non-NULL, |codeview_record| is used to locate a 84 // If |expected_pdb_name| is not nullptr, |codeview_record| is used to locate a
85 // CodeView record in |file_contents|, and its fields are compared against the 85 // CodeView record in |file_contents|, and its fields are compared against the
86 // the |expected_pdb_*| values. If |expected_pdb_uuid| is supplied, the CodeView 86 // the |expected_pdb_*| values. If |expected_pdb_uuid| is supplied, the CodeView
87 // record must be a PDB 7.0 link, otherwise, it must be a PDB 2.0 link. If 87 // record must be a PDB 7.0 link, otherwise, it must be a PDB 2.0 link. If
88 // |expected_pdb_name| is NULL, |codeview_record| must not point to anything. 88 // |expected_pdb_name| is nullptr, |codeview_record| must not point to anything.
89 void ExpectCodeViewRecord(const MINIDUMP_LOCATION_DESCRIPTOR* codeview_record, 89 void ExpectCodeViewRecord(const MINIDUMP_LOCATION_DESCRIPTOR* codeview_record,
90 const std::string& file_contents, 90 const std::string& file_contents,
91 const char* expected_pdb_name, 91 const char* expected_pdb_name,
92 const UUID* expected_pdb_uuid, 92 const UUID* expected_pdb_uuid,
93 time_t expected_pdb_timestamp, 93 time_t expected_pdb_timestamp,
94 uint32_t expected_pdb_age) { 94 uint32_t expected_pdb_age) {
95 if (expected_pdb_name) { 95 if (expected_pdb_name) {
96 EXPECT_NE(0u, codeview_record->Rva); 96 EXPECT_NE(0u, codeview_record->Rva);
97 ASSERT_LE(codeview_record->Rva + codeview_record->DataSize, 97 ASSERT_LE(codeview_record->Rva + codeview_record->DataSize,
98 file_contents.size()); 98 file_contents.size());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 observed_pdb_name.resize(observed_pdb_name.size() - 1); 141 observed_pdb_name.resize(observed_pdb_name.size() - 1);
142 142
143 EXPECT_EQ(expected_pdb_name, observed_pdb_name); 143 EXPECT_EQ(expected_pdb_name, observed_pdb_name);
144 } else { 144 } else {
145 // There should be no CodeView record. 145 // There should be no CodeView record.
146 EXPECT_EQ(0u, codeview_record->DataSize); 146 EXPECT_EQ(0u, codeview_record->DataSize);
147 EXPECT_EQ(0u, codeview_record->Rva); 147 EXPECT_EQ(0u, codeview_record->Rva);
148 } 148 }
149 } 149 }
150 150
151 // If |expected_debug_name| is non-NULL, |misc_record| is used to locate a 151 // If |expected_debug_name| is not nullptr, |misc_record| is used to locate a
152 // miscellanous debugging record in |file_contents|, and its fields are compared 152 // miscellanous debugging record in |file_contents|, and its fields are compared
153 // against the the |expected_debug_*| values. If |expected_debug_name| is NULL, 153 // against the the |expected_debug_*| values. If |expected_debug_name| is
154 // |misc_record| must not point to anything. 154 // nullptr, |misc_record| must not point to anything.
155 void ExpectMiscellaneousDebugRecord( 155 void ExpectMiscellaneousDebugRecord(
156 const MINIDUMP_LOCATION_DESCRIPTOR* misc_record, 156 const MINIDUMP_LOCATION_DESCRIPTOR* misc_record,
157 const std::string& file_contents, 157 const std::string& file_contents,
158 const char* expected_debug_name, 158 const char* expected_debug_name,
159 uint32_t expected_debug_type, 159 uint32_t expected_debug_type,
160 bool expected_debug_utf16) { 160 bool expected_debug_utf16) {
161 if (expected_debug_name) { 161 if (expected_debug_name) {
162 EXPECT_GE(misc_record->DataSize, sizeof(IMAGE_DEBUG_MISC)); 162 EXPECT_GE(misc_record->DataSize, sizeof(IMAGE_DEBUG_MISC));
163 EXPECT_NE(0u, misc_record->Rva); 163 EXPECT_NE(0u, misc_record->Rva);
164 ASSERT_LE(misc_record->Rva + misc_record->DataSize, file_contents.size()); 164 ASSERT_LE(misc_record->Rva + misc_record->DataSize, file_contents.size());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ASSERT_NO_FATAL_FAILURE( 308 ASSERT_NO_FATAL_FAILURE(
309 GetModuleListStream(file_writer.string(), &module_list)); 309 GetModuleListStream(file_writer.string(), &module_list));
310 310
311 EXPECT_EQ(1u, module_list->NumberOfModules); 311 EXPECT_EQ(1u, module_list->NumberOfModules);
312 312
313 MINIDUMP_MODULE expected = {}; 313 MINIDUMP_MODULE expected = {};
314 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected, 314 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
315 &module_list->Modules[0], 315 &module_list->Modules[0],
316 file_writer.string(), 316 file_writer.string(),
317 kModuleName, 317 kModuleName,
318 NULL, 318 nullptr,
319 NULL, 319 nullptr,
320 0, 320 0,
321 0, 321 0,
322 NULL, 322 nullptr,
323 0, 323 0,
324 false)); 324 false));
325 } 325 }
326 326
327 TEST(MinidumpModuleWriter, OneModule) { 327 TEST(MinidumpModuleWriter, OneModule) {
328 MinidumpFileWriter minidump_file_writer; 328 MinidumpFileWriter minidump_file_writer;
329 MinidumpModuleListWriter module_list_writer; 329 MinidumpModuleListWriter module_list_writer;
330 330
331 const char kModuleName[] = "statically_linked"; 331 const char kModuleName[] = "statically_linked";
332 const uint64_t kModuleBase = 0x10da69000; 332 const uint64_t kModuleBase = 0x10da69000;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 EXPECT_EQ(1u, module_list->NumberOfModules); 473 EXPECT_EQ(1u, module_list->NumberOfModules);
474 474
475 MINIDUMP_MODULE expected = {}; 475 MINIDUMP_MODULE expected = {};
476 476
477 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected, 477 ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
478 &module_list->Modules[0], 478 &module_list->Modules[0],
479 file_writer.string(), 479 file_writer.string(),
480 kModuleName, 480 kModuleName,
481 kPDBName, 481 kPDBName,
482 NULL, 482 nullptr,
483 kPDBTimestamp, 483 kPDBTimestamp,
484 kPDBAge, 484 kPDBAge,
485 kDebugName, 485 kDebugName,
486 kDebugType, 486 kDebugType,
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
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 expected.SizeOfImage = kModuleSize0; 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 kModuleName0, 576 kModuleName0,
577 kPDBName0, 577 kPDBName0,
578 &pdb_uuid_0, 578 &pdb_uuid_0,
579 0, 579 0,
580 kPDBAge0, 580 kPDBAge0,
581 NULL, 581 nullptr,
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 = kModuleBase1; 589 expected.BaseOfImage = kModuleBase1;
590 expected.SizeOfImage = kModuleSize1; 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 kModuleName1, 595 kModuleName1,
596 NULL, 596 nullptr,
597 NULL, 597 nullptr,
598 0, 598 0,
599 0, 599 0,
600 NULL, 600 nullptr,
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 = kModuleBase2; 608 expected.BaseOfImage = kModuleBase2;
609 expected.SizeOfImage = kModuleSize2; 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 kModuleName2, 614 kModuleName2,
615 kPDBName2, 615 kPDBName2,
616 NULL, 616 nullptr,
617 kPDBTimestamp2, 617 kPDBTimestamp2,
618 kPDBAge2, 618 kPDBAge2,
619 NULL, 619 nullptr,
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_module_writer.cc ('k') | minidump/minidump_string_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698