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

Side by Side Diff: minidump/minidump_file_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 | « client/capture_context_mac_test.cc ('k') | minidump/minidump_memory_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 21 matching lines...) Expand all
32 32
33 TEST(MinidumpFileWriter, Empty) { 33 TEST(MinidumpFileWriter, Empty) {
34 MinidumpFileWriter minidump_file; 34 MinidumpFileWriter minidump_file;
35 StringFileWriter file_writer; 35 StringFileWriter file_writer;
36 ASSERT_TRUE(minidump_file.WriteEverything(&file_writer)); 36 ASSERT_TRUE(minidump_file.WriteEverything(&file_writer));
37 ASSERT_EQ(sizeof(MINIDUMP_HEADER), file_writer.string().size()); 37 ASSERT_EQ(sizeof(MINIDUMP_HEADER), file_writer.string().size());
38 38
39 const MINIDUMP_HEADER* header = 39 const MINIDUMP_HEADER* header =
40 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]); 40 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]);
41 41
42 VerifyMinidumpHeader(header, 0, 0); 42 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 0, 0));
43 if (Test::HasFatalFailure()) {
44 return;
45 }
46 } 43 }
47 44
48 class TestStream final : public internal::MinidumpStreamWriter { 45 class TestStream final : public internal::MinidumpStreamWriter {
49 public: 46 public:
50 TestStream(MinidumpStreamType stream_type, 47 TestStream(MinidumpStreamType stream_type,
51 size_t stream_size, 48 size_t stream_size,
52 uint8_t stream_value) 49 uint8_t stream_value)
53 : stream_data_(stream_size, stream_value), stream_type_(stream_type) {} 50 : stream_data_(stream_size, stream_value), stream_type_(stream_type) {}
54 51
55 ~TestStream() {} 52 ~TestStream() {}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 91
95 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 92 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
96 const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY); 93 const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
97 const size_t kFileSize = kStreamOffset + kStreamSize; 94 const size_t kFileSize = kStreamOffset + kStreamSize;
98 95
99 ASSERT_EQ(kFileSize, file_writer.string().size()); 96 ASSERT_EQ(kFileSize, file_writer.string().size());
100 97
101 const MINIDUMP_HEADER* header = 98 const MINIDUMP_HEADER* header =
102 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]); 99 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]);
103 100
104 VerifyMinidumpHeader(header, 1, kTimestamp); 101 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, kTimestamp));
105 if (Test::HasFatalFailure()) {
106 return;
107 }
108 102
109 const MINIDUMP_DIRECTORY* directory = 103 const MINIDUMP_DIRECTORY* directory =
110 reinterpret_cast<const MINIDUMP_DIRECTORY*>( 104 reinterpret_cast<const MINIDUMP_DIRECTORY*>(
111 &file_writer.string()[kDirectoryOffset]); 105 &file_writer.string()[kDirectoryOffset]);
112 106
113 EXPECT_EQ(kStreamType, directory->StreamType); 107 EXPECT_EQ(kStreamType, directory->StreamType);
114 EXPECT_EQ(kStreamSize, directory->Location.DataSize); 108 EXPECT_EQ(kStreamSize, directory->Location.DataSize);
115 EXPECT_EQ(kStreamOffset, directory->Location.Rva); 109 EXPECT_EQ(kStreamOffset, directory->Location.Rva);
116 110
117 const uint8_t* stream_data = 111 const uint8_t* stream_data =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const size_t kStream2Offset = kStream1Offset + kStream1Size + kStream2Padding; 151 const size_t kStream2Offset = kStream1Offset + kStream1Size + kStream2Padding;
158 const size_t kStream3Padding = 1; 152 const size_t kStream3Padding = 1;
159 const size_t kStream3Offset = kStream2Offset + kStream2Size + kStream3Padding; 153 const size_t kStream3Offset = kStream2Offset + kStream2Size + kStream3Padding;
160 const size_t kFileSize = kStream3Offset + kStream3Size; 154 const size_t kFileSize = kStream3Offset + kStream3Size;
161 155
162 ASSERT_EQ(kFileSize, file_writer.string().size()); 156 ASSERT_EQ(kFileSize, file_writer.string().size());
163 157
164 const MINIDUMP_HEADER* header = 158 const MINIDUMP_HEADER* header =
165 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]); 159 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]);
166 160
167 VerifyMinidumpHeader(header, 3, kTimestamp); 161 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 3, kTimestamp));
168 if (Test::HasFatalFailure()) {
169 return;
170 }
171 162
172 const MINIDUMP_DIRECTORY* directory = 163 const MINIDUMP_DIRECTORY* directory =
173 reinterpret_cast<const MINIDUMP_DIRECTORY*>( 164 reinterpret_cast<const MINIDUMP_DIRECTORY*>(
174 &file_writer.string()[kDirectoryOffset]); 165 &file_writer.string()[kDirectoryOffset]);
175 166
176 EXPECT_EQ(kStream1Type, directory[0].StreamType); 167 EXPECT_EQ(kStream1Type, directory[0].StreamType);
177 EXPECT_EQ(kStream1Size, directory[0].Location.DataSize); 168 EXPECT_EQ(kStream1Size, directory[0].Location.DataSize);
178 EXPECT_EQ(kStream1Offset, directory[0].Location.Rva); 169 EXPECT_EQ(kStream1Offset, directory[0].Location.Rva);
179 EXPECT_EQ(kStream2Type, directory[1].StreamType); 170 EXPECT_EQ(kStream2Type, directory[1].StreamType);
180 EXPECT_EQ(kStream2Size, directory[1].Location.DataSize); 171 EXPECT_EQ(kStream2Size, directory[1].Location.DataSize);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 213
223 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 214 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
224 const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY); 215 const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
225 const size_t kFileSize = kStreamOffset + kStreamSize; 216 const size_t kFileSize = kStreamOffset + kStreamSize;
226 217
227 ASSERT_EQ(kFileSize, file_writer.string().size()); 218 ASSERT_EQ(kFileSize, file_writer.string().size());
228 219
229 const MINIDUMP_HEADER* header = 220 const MINIDUMP_HEADER* header =
230 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]); 221 reinterpret_cast<const MINIDUMP_HEADER*>(&file_writer.string()[0]);
231 222
232 VerifyMinidumpHeader(header, 1, 0); 223 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
233 if (Test::HasFatalFailure()) {
234 return;
235 }
236 224
237 const MINIDUMP_DIRECTORY* directory = 225 const MINIDUMP_DIRECTORY* directory =
238 reinterpret_cast<const MINIDUMP_DIRECTORY*>( 226 reinterpret_cast<const MINIDUMP_DIRECTORY*>(
239 &file_writer.string()[kDirectoryOffset]); 227 &file_writer.string()[kDirectoryOffset]);
240 228
241 EXPECT_EQ(kStreamType, directory->StreamType); 229 EXPECT_EQ(kStreamType, directory->StreamType);
242 EXPECT_EQ(kStreamSize, directory->Location.DataSize); 230 EXPECT_EQ(kStreamSize, directory->Location.DataSize);
243 EXPECT_EQ(kStreamOffset, directory->Location.Rva); 231 EXPECT_EQ(kStreamOffset, directory->Location.Rva);
244 } 232 }
245 233
(...skipping 10 matching lines...) Expand all
256 const size_t kStream2Size = 3; 244 const size_t kStream2Size = 3;
257 const MinidumpStreamType kStream2Type = static_cast<MinidumpStreamType>(0x4d); 245 const MinidumpStreamType kStream2Type = static_cast<MinidumpStreamType>(0x4d);
258 const uint8_t kStream2Value = 0xa5; 246 const uint8_t kStream2Value = 0xa5;
259 TestStream stream2(kStream2Type, kStream2Size, kStream2Value); 247 TestStream stream2(kStream2Type, kStream2Size, kStream2Value);
260 ASSERT_DEATH(minidump_file.AddStream(&stream2), "already present"); 248 ASSERT_DEATH(minidump_file.AddStream(&stream2), "already present");
261 } 249 }
262 250
263 } // namespace 251 } // namespace
264 } // namespace test 252 } // namespace test
265 } // namespace crashpad 253 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/capture_context_mac_test.cc ('k') | minidump/minidump_memory_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698