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

Side by Side Diff: minidump/minidump_misc_info_writer_test.cc

Issue 936153002: Add FileReaderInterface. Move StringFileWriter to StringFile and (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Remove unused #include Created 5 years, 10 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
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 13 matching lines...) Expand all
24 #include "base/compiler_specific.h" 24 #include "base/compiler_specific.h"
25 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
26 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "gtest/gtest.h" 28 #include "gtest/gtest.h"
29 #include "minidump/minidump_file_writer.h" 29 #include "minidump/minidump_file_writer.h"
30 #include "minidump/test/minidump_file_writer_test_util.h" 30 #include "minidump/test/minidump_file_writer_test_util.h"
31 #include "minidump/test/minidump_writable_test_util.h" 31 #include "minidump/test/minidump_writable_test_util.h"
32 #include "snapshot/test/test_process_snapshot.h" 32 #include "snapshot/test/test_process_snapshot.h"
33 #include "snapshot/test/test_system_snapshot.h" 33 #include "snapshot/test/test_system_snapshot.h"
34 #include "util/file/string_file_writer.h" 34 #include "util/file/string_file.h"
35 #include "util/stdlib/strlcpy.h" 35 #include "util/stdlib/strlcpy.h"
36 36
37 namespace crashpad { 37 namespace crashpad {
38 namespace test { 38 namespace test {
39 namespace { 39 namespace {
40 40
41 template <typename T> 41 template <typename T>
42 void GetMiscInfoStream(const std::string& file_contents, const T** misc_info) { 42 void GetMiscInfoStream(const std::string& file_contents, const T** misc_info) {
43 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 43 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
44 const size_t kMiscInfoStreamOffset = 44 const size_t kMiscInfoStreamOffset =
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 arraysize(expected->DbgBldStr)); 163 arraysize(expected->DbgBldStr));
164 } 164 }
165 } 165 }
166 166
167 TEST(MinidumpMiscInfoWriter, Empty) { 167 TEST(MinidumpMiscInfoWriter, Empty) {
168 MinidumpFileWriter minidump_file_writer; 168 MinidumpFileWriter minidump_file_writer;
169 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 169 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
170 170
171 minidump_file_writer.AddStream(misc_info_writer.Pass()); 171 minidump_file_writer.AddStream(misc_info_writer.Pass());
172 172
173 StringFileWriter file_writer; 173 StringFile string_file;
174 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 174 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
175 175
176 const MINIDUMP_MISC_INFO* observed = nullptr; 176 const MINIDUMP_MISC_INFO* observed = nullptr;
177 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 177 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
178 178
179 MINIDUMP_MISC_INFO expected = {}; 179 MINIDUMP_MISC_INFO expected = {};
180 180
181 ExpectMiscInfoEqual(&expected, observed); 181 ExpectMiscInfoEqual(&expected, observed);
182 } 182 }
183 183
184 TEST(MinidumpMiscInfoWriter, ProcessId) { 184 TEST(MinidumpMiscInfoWriter, ProcessId) {
185 MinidumpFileWriter minidump_file_writer; 185 MinidumpFileWriter minidump_file_writer;
186 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 186 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
187 187
188 const uint32_t kProcessId = 12345; 188 const uint32_t kProcessId = 12345;
189 189
190 misc_info_writer->SetProcessID(kProcessId); 190 misc_info_writer->SetProcessID(kProcessId);
191 191
192 minidump_file_writer.AddStream(misc_info_writer.Pass()); 192 minidump_file_writer.AddStream(misc_info_writer.Pass());
193 193
194 StringFileWriter file_writer; 194 StringFile string_file;
195 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 195 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
196 196
197 const MINIDUMP_MISC_INFO* observed = nullptr; 197 const MINIDUMP_MISC_INFO* observed = nullptr;
198 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 198 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
199 199
200 MINIDUMP_MISC_INFO expected = {}; 200 MINIDUMP_MISC_INFO expected = {};
201 expected.Flags1 = MINIDUMP_MISC1_PROCESS_ID; 201 expected.Flags1 = MINIDUMP_MISC1_PROCESS_ID;
202 expected.ProcessId = kProcessId; 202 expected.ProcessId = kProcessId;
203 203
204 ExpectMiscInfoEqual(&expected, observed); 204 ExpectMiscInfoEqual(&expected, observed);
205 } 205 }
206 206
207 TEST(MinidumpMiscInfoWriter, ProcessTimes) { 207 TEST(MinidumpMiscInfoWriter, ProcessTimes) {
208 MinidumpFileWriter minidump_file_writer; 208 MinidumpFileWriter minidump_file_writer;
209 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 209 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
210 210
211 const time_t kProcessCreateTime = 0x15252f00; 211 const time_t kProcessCreateTime = 0x15252f00;
212 const uint32_t kProcessUserTime = 10; 212 const uint32_t kProcessUserTime = 10;
213 const uint32_t kProcessKernelTime = 5; 213 const uint32_t kProcessKernelTime = 5;
214 214
215 misc_info_writer->SetProcessTimes( 215 misc_info_writer->SetProcessTimes(
216 kProcessCreateTime, kProcessUserTime, kProcessKernelTime); 216 kProcessCreateTime, kProcessUserTime, kProcessKernelTime);
217 217
218 minidump_file_writer.AddStream(misc_info_writer.Pass()); 218 minidump_file_writer.AddStream(misc_info_writer.Pass());
219 219
220 StringFileWriter file_writer; 220 StringFile string_file;
221 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 221 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
222 222
223 const MINIDUMP_MISC_INFO* observed = nullptr; 223 const MINIDUMP_MISC_INFO* observed = nullptr;
224 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 224 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
225 225
226 MINIDUMP_MISC_INFO expected = {}; 226 MINIDUMP_MISC_INFO expected = {};
227 expected.Flags1 = MINIDUMP_MISC1_PROCESS_TIMES; 227 expected.Flags1 = MINIDUMP_MISC1_PROCESS_TIMES;
228 expected.ProcessCreateTime = kProcessCreateTime; 228 expected.ProcessCreateTime = kProcessCreateTime;
229 expected.ProcessUserTime = kProcessUserTime; 229 expected.ProcessUserTime = kProcessUserTime;
230 expected.ProcessKernelTime = kProcessKernelTime; 230 expected.ProcessKernelTime = kProcessKernelTime;
231 231
232 ExpectMiscInfoEqual(&expected, observed); 232 ExpectMiscInfoEqual(&expected, observed);
233 } 233 }
234 234
235 TEST(MinidumpMiscInfoWriter, ProcessorPowerInfo) { 235 TEST(MinidumpMiscInfoWriter, ProcessorPowerInfo) {
236 MinidumpFileWriter minidump_file_writer; 236 MinidumpFileWriter minidump_file_writer;
237 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 237 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
238 238
239 const uint32_t kProcessorMaxMhz = 2800; 239 const uint32_t kProcessorMaxMhz = 2800;
240 const uint32_t kProcessorCurrentMhz = 2300; 240 const uint32_t kProcessorCurrentMhz = 2300;
241 const uint32_t kProcessorMhzLimit = 3300; 241 const uint32_t kProcessorMhzLimit = 3300;
242 const uint32_t kProcessorMaxIdleState = 5; 242 const uint32_t kProcessorMaxIdleState = 5;
243 const uint32_t kProcessorCurrentIdleState = 1; 243 const uint32_t kProcessorCurrentIdleState = 1;
244 244
245 misc_info_writer->SetProcessorPowerInfo(kProcessorMaxMhz, 245 misc_info_writer->SetProcessorPowerInfo(kProcessorMaxMhz,
246 kProcessorCurrentMhz, 246 kProcessorCurrentMhz,
247 kProcessorMhzLimit, 247 kProcessorMhzLimit,
248 kProcessorMaxIdleState, 248 kProcessorMaxIdleState,
249 kProcessorCurrentIdleState); 249 kProcessorCurrentIdleState);
250 250
251 minidump_file_writer.AddStream(misc_info_writer.Pass()); 251 minidump_file_writer.AddStream(misc_info_writer.Pass());
252 252
253 StringFileWriter file_writer; 253 StringFile string_file;
254 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 254 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
255 255
256 const MINIDUMP_MISC_INFO_2* observed = nullptr; 256 const MINIDUMP_MISC_INFO_2* observed = nullptr;
257 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 257 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
258 258
259 MINIDUMP_MISC_INFO_2 expected = {}; 259 MINIDUMP_MISC_INFO_2 expected = {};
260 expected.Flags1 = MINIDUMP_MISC1_PROCESSOR_POWER_INFO; 260 expected.Flags1 = MINIDUMP_MISC1_PROCESSOR_POWER_INFO;
261 expected.ProcessorMaxMhz = kProcessorMaxMhz; 261 expected.ProcessorMaxMhz = kProcessorMaxMhz;
262 expected.ProcessorCurrentMhz = kProcessorCurrentMhz; 262 expected.ProcessorCurrentMhz = kProcessorCurrentMhz;
263 expected.ProcessorMhzLimit = kProcessorMhzLimit; 263 expected.ProcessorMhzLimit = kProcessorMhzLimit;
264 expected.ProcessorMaxIdleState = kProcessorMaxIdleState; 264 expected.ProcessorMaxIdleState = kProcessorMaxIdleState;
265 expected.ProcessorCurrentIdleState = kProcessorCurrentIdleState; 265 expected.ProcessorCurrentIdleState = kProcessorCurrentIdleState;
266 266
267 ExpectMiscInfoEqual(&expected, observed); 267 ExpectMiscInfoEqual(&expected, observed);
268 } 268 }
269 269
270 TEST(MinidumpMiscInfoWriter, ProcessIntegrityLevel) { 270 TEST(MinidumpMiscInfoWriter, ProcessIntegrityLevel) {
271 MinidumpFileWriter minidump_file_writer; 271 MinidumpFileWriter minidump_file_writer;
272 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 272 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
273 273
274 const uint32_t kProcessIntegrityLevel = 0x2000; 274 const uint32_t kProcessIntegrityLevel = 0x2000;
275 275
276 misc_info_writer->SetProcessIntegrityLevel(kProcessIntegrityLevel); 276 misc_info_writer->SetProcessIntegrityLevel(kProcessIntegrityLevel);
277 277
278 minidump_file_writer.AddStream(misc_info_writer.Pass()); 278 minidump_file_writer.AddStream(misc_info_writer.Pass());
279 279
280 StringFileWriter file_writer; 280 StringFile string_file;
281 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 281 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
282 282
283 const MINIDUMP_MISC_INFO_3* observed = nullptr; 283 const MINIDUMP_MISC_INFO_3* observed = nullptr;
284 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 284 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
285 285
286 MINIDUMP_MISC_INFO_3 expected = {}; 286 MINIDUMP_MISC_INFO_3 expected = {};
287 expected.Flags1 = MINIDUMP_MISC3_PROCESS_INTEGRITY; 287 expected.Flags1 = MINIDUMP_MISC3_PROCESS_INTEGRITY;
288 expected.ProcessIntegrityLevel = kProcessIntegrityLevel; 288 expected.ProcessIntegrityLevel = kProcessIntegrityLevel;
289 289
290 ExpectMiscInfoEqual(&expected, observed); 290 ExpectMiscInfoEqual(&expected, observed);
291 } 291 }
292 292
293 TEST(MinidumpMiscInfoWriter, ProcessExecuteFlags) { 293 TEST(MinidumpMiscInfoWriter, ProcessExecuteFlags) {
294 MinidumpFileWriter minidump_file_writer; 294 MinidumpFileWriter minidump_file_writer;
295 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 295 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
296 296
297 const uint32_t kProcessExecuteFlags = 0x13579bdf; 297 const uint32_t kProcessExecuteFlags = 0x13579bdf;
298 298
299 misc_info_writer->SetProcessExecuteFlags(kProcessExecuteFlags); 299 misc_info_writer->SetProcessExecuteFlags(kProcessExecuteFlags);
300 300
301 minidump_file_writer.AddStream(misc_info_writer.Pass()); 301 minidump_file_writer.AddStream(misc_info_writer.Pass());
302 302
303 StringFileWriter file_writer; 303 StringFile string_file;
304 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 304 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
305 305
306 const MINIDUMP_MISC_INFO_3* observed = nullptr; 306 const MINIDUMP_MISC_INFO_3* observed = nullptr;
307 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 307 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
308 308
309 MINIDUMP_MISC_INFO_3 expected = {}; 309 MINIDUMP_MISC_INFO_3 expected = {};
310 expected.Flags1 = MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS; 310 expected.Flags1 = MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS;
311 expected.ProcessExecuteFlags = kProcessExecuteFlags; 311 expected.ProcessExecuteFlags = kProcessExecuteFlags;
312 312
313 ExpectMiscInfoEqual(&expected, observed); 313 ExpectMiscInfoEqual(&expected, observed);
314 } 314 }
315 315
316 TEST(MinidumpMiscInfoWriter, ProtectedProcess) { 316 TEST(MinidumpMiscInfoWriter, ProtectedProcess) {
317 MinidumpFileWriter minidump_file_writer; 317 MinidumpFileWriter minidump_file_writer;
318 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 318 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
319 319
320 const uint32_t kProtectedProcess = 1; 320 const uint32_t kProtectedProcess = 1;
321 321
322 misc_info_writer->SetProtectedProcess(kProtectedProcess); 322 misc_info_writer->SetProtectedProcess(kProtectedProcess);
323 323
324 minidump_file_writer.AddStream(misc_info_writer.Pass()); 324 minidump_file_writer.AddStream(misc_info_writer.Pass());
325 325
326 StringFileWriter file_writer; 326 StringFile string_file;
327 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 327 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
328 328
329 const MINIDUMP_MISC_INFO_3* observed = nullptr; 329 const MINIDUMP_MISC_INFO_3* observed = nullptr;
330 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 330 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
331 331
332 MINIDUMP_MISC_INFO_3 expected = {}; 332 MINIDUMP_MISC_INFO_3 expected = {};
333 expected.Flags1 = MINIDUMP_MISC3_PROTECTED_PROCESS; 333 expected.Flags1 = MINIDUMP_MISC3_PROTECTED_PROCESS;
334 expected.ProtectedProcess = kProtectedProcess; 334 expected.ProtectedProcess = kProtectedProcess;
335 335
336 ExpectMiscInfoEqual(&expected, observed); 336 ExpectMiscInfoEqual(&expected, observed);
337 } 337 }
338 338
339 TEST(MinidumpMiscInfoWriter, TimeZone) { 339 TEST(MinidumpMiscInfoWriter, TimeZone) {
340 MinidumpFileWriter minidump_file_writer; 340 MinidumpFileWriter minidump_file_writer;
(...skipping 12 matching lines...) Expand all
353 kBias, 353 kBias,
354 kStandardName, 354 kStandardName,
355 kStandardDate, 355 kStandardDate,
356 kStandardBias, 356 kStandardBias,
357 kDaylightName, 357 kDaylightName,
358 kDaylightDate, 358 kDaylightDate,
359 kDaylightBias); 359 kDaylightBias);
360 360
361 minidump_file_writer.AddStream(misc_info_writer.Pass()); 361 minidump_file_writer.AddStream(misc_info_writer.Pass());
362 362
363 StringFileWriter file_writer; 363 StringFile string_file;
364 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 364 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
365 365
366 const MINIDUMP_MISC_INFO_3* observed = nullptr; 366 const MINIDUMP_MISC_INFO_3* observed = nullptr;
367 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 367 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
368 368
369 MINIDUMP_MISC_INFO_3 expected = {}; 369 MINIDUMP_MISC_INFO_3 expected = {};
370 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE; 370 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE;
371 expected.TimeZoneId = kTimeZoneId; 371 expected.TimeZoneId = kTimeZoneId;
372 expected.TimeZone.Bias = kBias; 372 expected.TimeZone.Bias = kBias;
373 base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName); 373 base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
374 c16lcpy(expected.TimeZone.StandardName, 374 c16lcpy(expected.TimeZone.StandardName,
375 standard_name_utf16.c_str(), 375 standard_name_utf16.c_str(),
376 arraysize(expected.TimeZone.StandardName)); 376 arraysize(expected.TimeZone.StandardName));
377 memcpy(&expected.TimeZone.StandardDate, 377 memcpy(&expected.TimeZone.StandardDate,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 kBias, 414 kBias,
415 standard_name, 415 standard_name,
416 kSystemTimeZero, 416 kSystemTimeZero,
417 kStandardBias, 417 kStandardBias,
418 daylight_name, 418 daylight_name,
419 kSystemTimeZero, 419 kSystemTimeZero,
420 kDaylightBias); 420 kDaylightBias);
421 421
422 minidump_file_writer.AddStream(misc_info_writer.Pass()); 422 minidump_file_writer.AddStream(misc_info_writer.Pass());
423 423
424 StringFileWriter file_writer; 424 StringFile string_file;
425 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 425 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
426 426
427 const MINIDUMP_MISC_INFO_3* observed = nullptr; 427 const MINIDUMP_MISC_INFO_3* observed = nullptr;
428 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 428 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
429 429
430 MINIDUMP_MISC_INFO_3 expected = {}; 430 MINIDUMP_MISC_INFO_3 expected = {};
431 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE; 431 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE;
432 expected.TimeZoneId = kTimeZoneId; 432 expected.TimeZoneId = kTimeZoneId;
433 expected.TimeZone.Bias = kBias; 433 expected.TimeZone.Bias = kBias;
434 base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name); 434 base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
435 c16lcpy(expected.TimeZone.StandardName, 435 c16lcpy(expected.TimeZone.StandardName,
436 standard_name_utf16.c_str(), 436 standard_name_utf16.c_str(),
437 arraysize(expected.TimeZone.StandardName)); 437 arraysize(expected.TimeZone.StandardName));
438 memcpy(&expected.TimeZone.StandardDate, 438 memcpy(&expected.TimeZone.StandardDate,
(...skipping 16 matching lines...) Expand all
455 MinidumpFileWriter minidump_file_writer; 455 MinidumpFileWriter minidump_file_writer;
456 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 456 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
457 457
458 const char kBuildString[] = "build string"; 458 const char kBuildString[] = "build string";
459 const char kDebugBuildString[] = "debug build string"; 459 const char kDebugBuildString[] = "debug build string";
460 460
461 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString); 461 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString);
462 462
463 minidump_file_writer.AddStream(misc_info_writer.Pass()); 463 minidump_file_writer.AddStream(misc_info_writer.Pass());
464 464
465 StringFileWriter file_writer; 465 StringFile string_file;
466 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 466 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
467 467
468 const MINIDUMP_MISC_INFO_4* observed = nullptr; 468 const MINIDUMP_MISC_INFO_4* observed = nullptr;
469 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 469 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
470 470
471 MINIDUMP_MISC_INFO_4 expected = {}; 471 MINIDUMP_MISC_INFO_4 expected = {};
472 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING; 472 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
473 base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString); 473 base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
474 c16lcpy(expected.BuildString, 474 c16lcpy(expected.BuildString,
475 build_string_utf16.c_str(), 475 build_string_utf16.c_str(),
476 arraysize(expected.BuildString)); 476 arraysize(expected.BuildString));
477 base::string16 debug_build_string_utf16 = 477 base::string16 debug_build_string_utf16 =
478 base::UTF8ToUTF16(kDebugBuildString); 478 base::UTF8ToUTF16(kDebugBuildString);
479 c16lcpy(expected.DbgBldStr, 479 c16lcpy(expected.DbgBldStr,
(...skipping 12 matching lines...) Expand all
492 492
493 MINIDUMP_MISC_INFO_4 tmp; 493 MINIDUMP_MISC_INFO_4 tmp;
494 ALLOW_UNUSED_LOCAL(tmp); 494 ALLOW_UNUSED_LOCAL(tmp);
495 std::string build_string(arraysize(tmp.BuildString) + 1, 'B'); 495 std::string build_string(arraysize(tmp.BuildString) + 1, 'B');
496 std::string debug_build_string(arraysize(tmp.DbgBldStr), 'D'); 496 std::string debug_build_string(arraysize(tmp.DbgBldStr), 'D');
497 497
498 misc_info_writer->SetBuildString(build_string, debug_build_string); 498 misc_info_writer->SetBuildString(build_string, debug_build_string);
499 499
500 minidump_file_writer.AddStream(misc_info_writer.Pass()); 500 minidump_file_writer.AddStream(misc_info_writer.Pass());
501 501
502 StringFileWriter file_writer; 502 StringFile string_file;
503 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 503 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
504 504
505 const MINIDUMP_MISC_INFO_4* observed = nullptr; 505 const MINIDUMP_MISC_INFO_4* observed = nullptr;
506 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 506 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
507 507
508 MINIDUMP_MISC_INFO_4 expected = {}; 508 MINIDUMP_MISC_INFO_4 expected = {};
509 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING; 509 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
510 base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string); 510 base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
511 c16lcpy(expected.BuildString, 511 c16lcpy(expected.BuildString,
512 build_string_utf16.c_str(), 512 build_string_utf16.c_str(),
513 arraysize(expected.BuildString)); 513 arraysize(expected.BuildString));
514 base::string16 debug_build_string_utf16 = 514 base::string16 debug_build_string_utf16 =
515 base::UTF8ToUTF16(debug_build_string); 515 base::UTF8ToUTF16(debug_build_string);
516 c16lcpy(expected.DbgBldStr, 516 c16lcpy(expected.DbgBldStr,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 kStandardName, 562 kStandardName,
563 kSystemTimeZero, 563 kSystemTimeZero,
564 kStandardBias, 564 kStandardBias,
565 kDaylightName, 565 kDaylightName,
566 kSystemTimeZero, 566 kSystemTimeZero,
567 kDaylightBias); 567 kDaylightBias);
568 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString); 568 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString);
569 569
570 minidump_file_writer.AddStream(misc_info_writer.Pass()); 570 minidump_file_writer.AddStream(misc_info_writer.Pass());
571 571
572 StringFileWriter file_writer; 572 StringFile string_file;
573 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 573 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
574 574
575 const MINIDUMP_MISC_INFO_4* observed = nullptr; 575 const MINIDUMP_MISC_INFO_4* observed = nullptr;
576 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 576 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
577 577
578 MINIDUMP_MISC_INFO_4 expected = {}; 578 MINIDUMP_MISC_INFO_4 expected = {};
579 expected.Flags1 = 579 expected.Flags1 =
580 MINIDUMP_MISC1_PROCESS_ID | MINIDUMP_MISC1_PROCESS_TIMES | 580 MINIDUMP_MISC1_PROCESS_ID | MINIDUMP_MISC1_PROCESS_TIMES |
581 MINIDUMP_MISC1_PROCESSOR_POWER_INFO | MINIDUMP_MISC3_PROCESS_INTEGRITY | 581 MINIDUMP_MISC1_PROCESSOR_POWER_INFO | MINIDUMP_MISC3_PROCESS_INTEGRITY |
582 MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS | MINIDUMP_MISC3_PROTECTED_PROCESS | 582 MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS | MINIDUMP_MISC3_PROTECTED_PROCESS |
583 MINIDUMP_MISC3_TIMEZONE | MINIDUMP_MISC4_BUILDSTRING; 583 MINIDUMP_MISC3_TIMEZONE | MINIDUMP_MISC4_BUILDSTRING;
584 expected.ProcessId = kProcessId; 584 expected.ProcessId = kProcessId;
585 expected.ProcessCreateTime = kProcessCreateTime; 585 expected.ProcessCreateTime = kProcessCreateTime;
586 expected.ProcessUserTime = kProcessUserTime; 586 expected.ProcessUserTime = kProcessUserTime;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 system_snapshot->SetMachineDescription(kMachineDescription); 702 system_snapshot->SetMachineDescription(kMachineDescription);
703 703
704 process_snapshot.SetSystem(system_snapshot.Pass()); 704 process_snapshot.SetSystem(system_snapshot.Pass());
705 705
706 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 706 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
707 misc_info_writer->InitializeFromSnapshot(&process_snapshot); 707 misc_info_writer->InitializeFromSnapshot(&process_snapshot);
708 708
709 MinidumpFileWriter minidump_file_writer; 709 MinidumpFileWriter minidump_file_writer;
710 minidump_file_writer.AddStream(misc_info_writer.Pass()); 710 minidump_file_writer.AddStream(misc_info_writer.Pass());
711 711
712 StringFileWriter file_writer; 712 StringFile string_file;
713 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 713 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
714 714
715 const MINIDUMP_MISC_INFO_4* misc_info = nullptr; 715 const MINIDUMP_MISC_INFO_4* misc_info = nullptr;
716 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &misc_info)); 716 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &misc_info));
717 717
718 ExpectMiscInfoEqual(&expect_misc_info, misc_info); 718 ExpectMiscInfoEqual(&expect_misc_info, misc_info);
719 } 719 }
720 720
721 } // namespace 721 } // namespace
722 } // namespace test 722 } // namespace test
723 } // namespace crashpad 723 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_memory_writer_test.cc ('k') | minidump/minidump_module_crashpad_info_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698