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

Side by Side Diff: minidump/minidump_memory_writer_test.cc

Issue 640383002: In tests, use ASSERT_NO_FATAL_FAILURE() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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_file_writer_test.cc ('k') | minidump/minidump_misc_info_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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const size_t kMemoryListStreamOffset = 43 const size_t kMemoryListStreamOffset =
44 kDirectoryOffset + expected_streams * sizeof(MINIDUMP_DIRECTORY); 44 kDirectoryOffset + expected_streams * sizeof(MINIDUMP_DIRECTORY);
45 const size_t kMemoryDescriptorsOffset = 45 const size_t kMemoryDescriptorsOffset =
46 kMemoryListStreamOffset + sizeof(MINIDUMP_MEMORY_LIST); 46 kMemoryListStreamOffset + sizeof(MINIDUMP_MEMORY_LIST);
47 47
48 ASSERT_GE(file_contents.size(), kMemoryDescriptorsOffset); 48 ASSERT_GE(file_contents.size(), kMemoryDescriptorsOffset);
49 49
50 const MINIDUMP_HEADER* header = 50 const MINIDUMP_HEADER* header =
51 reinterpret_cast<const MINIDUMP_HEADER*>(&file_contents[0]); 51 reinterpret_cast<const MINIDUMP_HEADER*>(&file_contents[0]);
52 52
53 VerifyMinidumpHeader(header, expected_streams, 0); 53 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, expected_streams, 0));
54 if (testing::Test::HasFatalFailure()) {
55 return;
56 }
57 54
58 const MINIDUMP_DIRECTORY* directory = 55 const MINIDUMP_DIRECTORY* directory =
59 reinterpret_cast<const MINIDUMP_DIRECTORY*>( 56 reinterpret_cast<const MINIDUMP_DIRECTORY*>(
60 &file_contents[kDirectoryOffset]); 57 &file_contents[kDirectoryOffset]);
61 58
62 if (expected_streams > 1) { 59 if (expected_streams > 1) {
63 ASSERT_EQ(kBogusStreamType, directory->StreamType); 60 ASSERT_EQ(kBogusStreamType, directory->StreamType);
64 ASSERT_EQ(0u, directory->Location.DataSize); 61 ASSERT_EQ(0u, directory->Location.DataSize);
65 ASSERT_EQ(kMemoryListStreamOffset, directory->Location.Rva); 62 ASSERT_EQ(kMemoryListStreamOffset, directory->Location.Rva);
66 ++directory; 63 ++directory;
(...skipping 19 matching lines...) Expand all
86 minidump_file_writer.AddStream(&memory_list_writer); 83 minidump_file_writer.AddStream(&memory_list_writer);
87 84
88 StringFileWriter file_writer; 85 StringFileWriter file_writer;
89 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 86 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
90 87
91 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 88 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
92 sizeof(MINIDUMP_MEMORY_LIST), 89 sizeof(MINIDUMP_MEMORY_LIST),
93 file_writer.string().size()); 90 file_writer.string().size());
94 91
95 const MINIDUMP_MEMORY_LIST* memory_list; 92 const MINIDUMP_MEMORY_LIST* memory_list;
96 GetMemoryListStream(file_writer.string(), &memory_list, 1); 93 ASSERT_NO_FATAL_FAILURE(
97 if (Test::HasFatalFailure()) { 94 GetMemoryListStream(file_writer.string(), &memory_list, 1));
98 return;
99 }
100 95
101 EXPECT_EQ(0u, memory_list->NumberOfMemoryRanges); 96 EXPECT_EQ(0u, memory_list->NumberOfMemoryRanges);
102 } 97 }
103 98
104 TEST(MinidumpMemoryWriter, OneMemoryRegion) { 99 TEST(MinidumpMemoryWriter, OneMemoryRegion) {
105 MinidumpFileWriter minidump_file_writer; 100 MinidumpFileWriter minidump_file_writer;
106 MinidumpMemoryListWriter memory_list_writer; 101 MinidumpMemoryListWriter memory_list_writer;
107 102
108 const uint64_t kBaseAddress = 0xfedcba9876543210; 103 const uint64_t kBaseAddress = 0xfedcba9876543210;
109 const uint64_t kSize = 0x1000; 104 const uint64_t kSize = 0x1000;
110 const uint8_t kValue = 'm'; 105 const uint8_t kValue = 'm';
111 106
112 TestMinidumpMemoryWriter memory_writer(kBaseAddress, kSize, kValue); 107 TestMinidumpMemoryWriter memory_writer(kBaseAddress, kSize, kValue);
113 memory_list_writer.AddMemory(&memory_writer); 108 memory_list_writer.AddMemory(&memory_writer);
114 109
115 minidump_file_writer.AddStream(&memory_list_writer); 110 minidump_file_writer.AddStream(&memory_list_writer);
116 111
117 StringFileWriter file_writer; 112 StringFileWriter file_writer;
118 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 113 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
119 114
120 const MINIDUMP_MEMORY_LIST* memory_list; 115 const MINIDUMP_MEMORY_LIST* memory_list;
121 GetMemoryListStream(file_writer.string(), &memory_list, 1); 116 ASSERT_NO_FATAL_FAILURE(
122 if (Test::HasFatalFailure()) { 117 GetMemoryListStream(file_writer.string(), &memory_list, 1));
123 return;
124 }
125 118
126 MINIDUMP_MEMORY_DESCRIPTOR expected; 119 MINIDUMP_MEMORY_DESCRIPTOR expected;
127 expected.StartOfMemoryRange = kBaseAddress; 120 expected.StartOfMemoryRange = kBaseAddress;
128 expected.Memory.DataSize = kSize; 121 expected.Memory.DataSize = kSize;
129 expected.Memory.Rva = 122 expected.Memory.Rva =
130 sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 123 sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
131 sizeof(MINIDUMP_MEMORY_LIST) + 124 sizeof(MINIDUMP_MEMORY_LIST) +
132 memory_list->NumberOfMemoryRanges * sizeof(MINIDUMP_MEMORY_DESCRIPTOR); 125 memory_list->NumberOfMemoryRanges * sizeof(MINIDUMP_MEMORY_DESCRIPTOR);
133 ExpectMinidumpMemoryDescriptorAndContents(&expected, 126 ExpectMinidumpMemoryDescriptorAndContents(&expected,
134 &memory_list->MemoryRanges[0], 127 &memory_list->MemoryRanges[0],
(...skipping 17 matching lines...) Expand all
152 memory_list_writer.AddMemory(&memory_writer_1); 145 memory_list_writer.AddMemory(&memory_writer_1);
153 TestMinidumpMemoryWriter memory_writer_2(kBaseAddress2, kSize2, kValue2); 146 TestMinidumpMemoryWriter memory_writer_2(kBaseAddress2, kSize2, kValue2);
154 memory_list_writer.AddMemory(&memory_writer_2); 147 memory_list_writer.AddMemory(&memory_writer_2);
155 148
156 minidump_file_writer.AddStream(&memory_list_writer); 149 minidump_file_writer.AddStream(&memory_list_writer);
157 150
158 StringFileWriter file_writer; 151 StringFileWriter file_writer;
159 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 152 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
160 153
161 const MINIDUMP_MEMORY_LIST* memory_list; 154 const MINIDUMP_MEMORY_LIST* memory_list;
162 GetMemoryListStream(file_writer.string(), &memory_list, 1); 155 ASSERT_NO_FATAL_FAILURE(
163 if (Test::HasFatalFailure()) { 156 GetMemoryListStream(file_writer.string(), &memory_list, 1));
164 return;
165 }
166 157
167 EXPECT_EQ(2u, memory_list->NumberOfMemoryRanges); 158 EXPECT_EQ(2u, memory_list->NumberOfMemoryRanges);
168 159
169 MINIDUMP_MEMORY_DESCRIPTOR expected; 160 MINIDUMP_MEMORY_DESCRIPTOR expected;
170 161
171 { 162 {
172 SCOPED_TRACE("region 0"); 163 SCOPED_TRACE("region 0");
173 164
174 expected.StartOfMemoryRange = kBaseAddress1; 165 expected.StartOfMemoryRange = kBaseAddress1;
175 expected.Memory.DataSize = kSize1; 166 expected.Memory.DataSize = kSize1;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 250
260 TestMinidumpMemoryWriter memory_writer(kBaseAddress2, kSize2, kValue2); 251 TestMinidumpMemoryWriter memory_writer(kBaseAddress2, kSize2, kValue2);
261 memory_list_writer.AddMemory(&memory_writer); 252 memory_list_writer.AddMemory(&memory_writer);
262 253
263 minidump_file_writer.AddStream(&memory_list_writer); 254 minidump_file_writer.AddStream(&memory_list_writer);
264 255
265 StringFileWriter file_writer; 256 StringFileWriter file_writer;
266 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 257 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
267 258
268 const MINIDUMP_MEMORY_LIST* memory_list; 259 const MINIDUMP_MEMORY_LIST* memory_list;
269 GetMemoryListStream(file_writer.string(), &memory_list, 2); 260 ASSERT_NO_FATAL_FAILURE(
270 if (Test::HasFatalFailure()) { 261 GetMemoryListStream(file_writer.string(), &memory_list, 2));
271 return;
272 }
273 262
274 EXPECT_EQ(2u, memory_list->NumberOfMemoryRanges); 263 EXPECT_EQ(2u, memory_list->NumberOfMemoryRanges);
275 264
276 MINIDUMP_MEMORY_DESCRIPTOR expected; 265 MINIDUMP_MEMORY_DESCRIPTOR expected;
277 266
278 { 267 {
279 SCOPED_TRACE("region 0"); 268 SCOPED_TRACE("region 0");
280 269
281 expected.StartOfMemoryRange = kBaseAddress1; 270 expected.StartOfMemoryRange = kBaseAddress1;
282 expected.Memory.DataSize = kSize1; 271 expected.Memory.DataSize = kSize1;
(...skipping 19 matching lines...) Expand all
302 &memory_list->MemoryRanges[1], 291 &memory_list->MemoryRanges[1],
303 file_writer.string(), 292 file_writer.string(),
304 kValue2, 293 kValue2,
305 true); 294 true);
306 } 295 }
307 } 296 }
308 297
309 } // namespace 298 } // namespace
310 } // namespace test 299 } // namespace test
311 } // namespace crashpad 300 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_file_writer_test.cc ('k') | minidump/minidump_misc_info_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698