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

Side by Side Diff: minidump/minidump_system_info_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_module_writer_test.cc ('k') | util/mac/mac_util_test.mm » ('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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const size_t kCSDVersionOffset = 44 const size_t kCSDVersionOffset =
45 kSystemInfoStreamOffset + sizeof(MINIDUMP_SYSTEM_INFO); 45 kSystemInfoStreamOffset + sizeof(MINIDUMP_SYSTEM_INFO);
46 const size_t kFileSize = 46 const size_t kFileSize =
47 kCSDVersionOffset + sizeof(MINIDUMP_STRING) + kCSDVersionBytesWithNUL; 47 kCSDVersionOffset + sizeof(MINIDUMP_STRING) + kCSDVersionBytesWithNUL;
48 48
49 ASSERT_EQ(kFileSize, file_contents.size()); 49 ASSERT_EQ(kFileSize, file_contents.size());
50 50
51 const MINIDUMP_HEADER* header = 51 const MINIDUMP_HEADER* header =
52 reinterpret_cast<const MINIDUMP_HEADER*>(&file_contents[0]); 52 reinterpret_cast<const MINIDUMP_HEADER*>(&file_contents[0]);
53 53
54 VerifyMinidumpHeader(header, 1, 0); 54 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
55 if (testing::Test::HasFatalFailure()) {
56 return;
57 }
58 55
59 const MINIDUMP_DIRECTORY* directory = 56 const MINIDUMP_DIRECTORY* directory =
60 reinterpret_cast<const MINIDUMP_DIRECTORY*>( 57 reinterpret_cast<const MINIDUMP_DIRECTORY*>(
61 &file_contents[kDirectoryOffset]); 58 &file_contents[kDirectoryOffset]);
62 59
63 ASSERT_EQ(kMinidumpStreamTypeSystemInfo, directory->StreamType); 60 ASSERT_EQ(kMinidumpStreamTypeSystemInfo, directory->StreamType);
64 ASSERT_EQ(sizeof(MINIDUMP_SYSTEM_INFO), directory->Location.DataSize); 61 ASSERT_EQ(sizeof(MINIDUMP_SYSTEM_INFO), directory->Location.DataSize);
65 ASSERT_EQ(kSystemInfoStreamOffset, directory->Location.Rva); 62 ASSERT_EQ(kSystemInfoStreamOffset, directory->Location.Rva);
66 63
67 *system_info = reinterpret_cast<const MINIDUMP_SYSTEM_INFO*>( 64 *system_info = reinterpret_cast<const MINIDUMP_SYSTEM_INFO*>(
(...skipping 14 matching lines...) Expand all
82 system_info_writer.SetCSDVersion(std::string()); 79 system_info_writer.SetCSDVersion(std::string());
83 80
84 minidump_file_writer.AddStream(&system_info_writer); 81 minidump_file_writer.AddStream(&system_info_writer);
85 82
86 StringFileWriter file_writer; 83 StringFileWriter file_writer;
87 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 84 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
88 85
89 const MINIDUMP_SYSTEM_INFO* system_info; 86 const MINIDUMP_SYSTEM_INFO* system_info;
90 const MINIDUMP_STRING* csd_version; 87 const MINIDUMP_STRING* csd_version;
91 88
92 GetSystemInfoStream(file_writer.string(), 0, &system_info, &csd_version); 89 ASSERT_NO_FATAL_FAILURE(
93 if (Test::HasFatalFailure()) { 90 GetSystemInfoStream(file_writer.string(), 0, &system_info, &csd_version));
94 return;
95 }
96 91
97 EXPECT_EQ(kMinidumpCPUArchitectureUnknown, 92 EXPECT_EQ(kMinidumpCPUArchitectureUnknown,
98 system_info->ProcessorArchitecture); 93 system_info->ProcessorArchitecture);
99 EXPECT_EQ(0u, system_info->ProcessorLevel); 94 EXPECT_EQ(0u, system_info->ProcessorLevel);
100 EXPECT_EQ(0u, system_info->ProcessorRevision); 95 EXPECT_EQ(0u, system_info->ProcessorRevision);
101 EXPECT_EQ(0u, system_info->NumberOfProcessors); 96 EXPECT_EQ(0u, system_info->NumberOfProcessors);
102 EXPECT_EQ(0u, system_info->ProductType); 97 EXPECT_EQ(0u, system_info->ProductType);
103 EXPECT_EQ(0u, system_info->MajorVersion); 98 EXPECT_EQ(0u, system_info->MajorVersion);
104 EXPECT_EQ(0u, system_info->MinorVersion); 99 EXPECT_EQ(0u, system_info->MinorVersion);
105 EXPECT_EQ(0u, system_info->BuildNumber); 100 EXPECT_EQ(0u, system_info->BuildNumber);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 system_info_writer.SetCPUX86AMDExtendedFeatures(kAMDFeatures); 150 system_info_writer.SetCPUX86AMDExtendedFeatures(kAMDFeatures);
156 151
157 minidump_file_writer.AddStream(&system_info_writer); 152 minidump_file_writer.AddStream(&system_info_writer);
158 153
159 StringFileWriter file_writer; 154 StringFileWriter file_writer;
160 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 155 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
161 156
162 const MINIDUMP_SYSTEM_INFO* system_info; 157 const MINIDUMP_SYSTEM_INFO* system_info;
163 const MINIDUMP_STRING* csd_version; 158 const MINIDUMP_STRING* csd_version;
164 159
165 GetSystemInfoStream( 160 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
166 file_writer.string(), strlen(kCSDVersion), &system_info, &csd_version); 161 file_writer.string(), strlen(kCSDVersion), &system_info, &csd_version));
167 if (Test::HasFatalFailure()) {
168 return;
169 }
170 162
171 EXPECT_EQ(kCPUArchitecture, system_info->ProcessorArchitecture); 163 EXPECT_EQ(kCPUArchitecture, system_info->ProcessorArchitecture);
172 EXPECT_EQ(kCPULevel, system_info->ProcessorLevel); 164 EXPECT_EQ(kCPULevel, system_info->ProcessorLevel);
173 EXPECT_EQ(kCPURevision, system_info->ProcessorRevision); 165 EXPECT_EQ(kCPURevision, system_info->ProcessorRevision);
174 EXPECT_EQ(kCPUCount, system_info->NumberOfProcessors); 166 EXPECT_EQ(kCPUCount, system_info->NumberOfProcessors);
175 EXPECT_EQ(kOSType, system_info->ProductType); 167 EXPECT_EQ(kOSType, system_info->ProductType);
176 EXPECT_EQ(kOSVersionMajor, system_info->MajorVersion); 168 EXPECT_EQ(kOSVersionMajor, system_info->MajorVersion);
177 EXPECT_EQ(kOSVersionMinor, system_info->MinorVersion); 169 EXPECT_EQ(kOSVersionMinor, system_info->MinorVersion);
178 EXPECT_EQ(kOSVersionBuild, system_info->BuildNumber); 170 EXPECT_EQ(kOSVersionBuild, system_info->BuildNumber);
179 EXPECT_EQ(kOS, system_info->PlatformId); 171 EXPECT_EQ(kOS, system_info->PlatformId);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 system_info_writer.SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]); 210 system_info_writer.SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]);
219 211
220 minidump_file_writer.AddStream(&system_info_writer); 212 minidump_file_writer.AddStream(&system_info_writer);
221 213
222 StringFileWriter file_writer; 214 StringFileWriter file_writer;
223 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 215 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
224 216
225 const MINIDUMP_SYSTEM_INFO* system_info; 217 const MINIDUMP_SYSTEM_INFO* system_info;
226 const MINIDUMP_STRING* csd_version; 218 const MINIDUMP_STRING* csd_version;
227 219
228 GetSystemInfoStream( 220 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
229 file_writer.string(), strlen(kCSDVersion), &system_info, &csd_version); 221 file_writer.string(), strlen(kCSDVersion), &system_info, &csd_version));
230 if (Test::HasFatalFailure()) {
231 return;
232 }
233 222
234 EXPECT_EQ(kCPUArchitecture, system_info->ProcessorArchitecture); 223 EXPECT_EQ(kCPUArchitecture, system_info->ProcessorArchitecture);
235 EXPECT_EQ(kCPULevel, system_info->ProcessorLevel); 224 EXPECT_EQ(kCPULevel, system_info->ProcessorLevel);
236 EXPECT_EQ(kCPURevision, system_info->ProcessorRevision); 225 EXPECT_EQ(kCPURevision, system_info->ProcessorRevision);
237 EXPECT_EQ(kCPUCount, system_info->NumberOfProcessors); 226 EXPECT_EQ(kCPUCount, system_info->NumberOfProcessors);
238 EXPECT_EQ(kOSType, system_info->ProductType); 227 EXPECT_EQ(kOSType, system_info->ProductType);
239 EXPECT_EQ(kOSVersionMajor, system_info->MajorVersion); 228 EXPECT_EQ(kOSVersionMajor, system_info->MajorVersion);
240 EXPECT_EQ(kOSVersionMinor, system_info->MinorVersion); 229 EXPECT_EQ(kOSVersionMinor, system_info->MinorVersion);
241 EXPECT_EQ(kOSVersionBuild, system_info->BuildNumber); 230 EXPECT_EQ(kOSVersionBuild, system_info->BuildNumber);
242 EXPECT_EQ(kOS, system_info->PlatformId); 231 EXPECT_EQ(kOS, system_info->PlatformId);
(...skipping 20 matching lines...) Expand all
263 system_info_writer.SetCSDVersion(std::string()); 252 system_info_writer.SetCSDVersion(std::string());
264 253
265 minidump_file_writer.AddStream(&system_info_writer); 254 minidump_file_writer.AddStream(&system_info_writer);
266 255
267 StringFileWriter file_writer; 256 StringFileWriter file_writer;
268 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 257 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
269 258
270 const MINIDUMP_SYSTEM_INFO* system_info; 259 const MINIDUMP_SYSTEM_INFO* system_info;
271 const MINIDUMP_STRING* csd_version; 260 const MINIDUMP_STRING* csd_version;
272 261
273 GetSystemInfoStream(file_writer.string(), 0, &system_info, &csd_version); 262 ASSERT_NO_FATAL_FAILURE(
274 if (Test::HasFatalFailure()) { 263 GetSystemInfoStream(file_writer.string(), 0, &system_info, &csd_version));
275 return;
276 }
277 264
278 EXPECT_EQ(kCPUArchitecture, system_info->ProcessorArchitecture); 265 EXPECT_EQ(kCPUArchitecture, system_info->ProcessorArchitecture);
279 EXPECT_EQ(0u, system_info->ProcessorLevel); 266 EXPECT_EQ(0u, system_info->ProcessorLevel);
280 EXPECT_EQ(kCPUVendor[0], system_info->Cpu.X86CpuInfo.VendorId[0]); 267 EXPECT_EQ(kCPUVendor[0], system_info->Cpu.X86CpuInfo.VendorId[0]);
281 EXPECT_EQ(kCPUVendor[1], system_info->Cpu.X86CpuInfo.VendorId[1]); 268 EXPECT_EQ(kCPUVendor[1], system_info->Cpu.X86CpuInfo.VendorId[1]);
282 EXPECT_EQ(kCPUVendor[2], system_info->Cpu.X86CpuInfo.VendorId[2]); 269 EXPECT_EQ(kCPUVendor[2], system_info->Cpu.X86CpuInfo.VendorId[2]);
283 EXPECT_EQ(0u, system_info->Cpu.X86CpuInfo.VersionInformation); 270 EXPECT_EQ(0u, system_info->Cpu.X86CpuInfo.VersionInformation);
284 } 271 }
285 272
286 TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) { 273 TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) {
287 MinidumpFileWriter minidump_file_writer; 274 MinidumpFileWriter minidump_file_writer;
288 MinidumpSystemInfoWriter system_info_writer; 275 MinidumpSystemInfoWriter system_info_writer;
289 minidump_file_writer.AddStream(&system_info_writer); 276 minidump_file_writer.AddStream(&system_info_writer);
290 277
291 StringFileWriter file_writer; 278 StringFileWriter file_writer;
292 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), 279 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer),
293 "csd_version_"); 280 "csd_version_");
294 } 281 }
295 282
296 } // namespace 283 } // namespace
297 } // namespace test 284 } // namespace test
298 } // namespace crashpad 285 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_module_writer_test.cc ('k') | util/mac/mac_util_test.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698