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

Side by Side Diff: minidump/minidump_misc_info_writer_test.cc

Issue 1483073004: Replace use of .Pass() with crashpad::move(). (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: pass: . Created 5 years 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 14 matching lines...) Expand all
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.h" 34 #include "util/file/string_file.h"
35 #include "util/stdlib/move.h"
35 #include "util/stdlib/strlcpy.h" 36 #include "util/stdlib/strlcpy.h"
36 37
37 namespace crashpad { 38 namespace crashpad {
38 namespace test { 39 namespace test {
39 namespace { 40 namespace {
40 41
41 template <typename T> 42 template <typename T>
42 void GetMiscInfoStream(const std::string& file_contents, const T** misc_info) { 43 void GetMiscInfoStream(const std::string& file_contents, const T** misc_info) {
43 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 44 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
44 const size_t kMiscInfoStreamOffset = 45 const size_t kMiscInfoStreamOffset =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ExpectNULPaddedString16Equal(expected->DbgBldStr, 162 ExpectNULPaddedString16Equal(expected->DbgBldStr,
162 observed->DbgBldStr, 163 observed->DbgBldStr,
163 arraysize(expected->DbgBldStr)); 164 arraysize(expected->DbgBldStr));
164 } 165 }
165 } 166 }
166 167
167 TEST(MinidumpMiscInfoWriter, Empty) { 168 TEST(MinidumpMiscInfoWriter, Empty) {
168 MinidumpFileWriter minidump_file_writer; 169 MinidumpFileWriter minidump_file_writer;
169 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 170 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
170 171
171 minidump_file_writer.AddStream(misc_info_writer.Pass()); 172 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
172 173
173 StringFile string_file; 174 StringFile string_file;
174 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 175 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
175 176
176 const MINIDUMP_MISC_INFO* observed = nullptr; 177 const MINIDUMP_MISC_INFO* observed = nullptr;
177 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 178 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
178 179
179 MINIDUMP_MISC_INFO expected = {}; 180 MINIDUMP_MISC_INFO expected = {};
180 181
181 ExpectMiscInfoEqual(&expected, observed); 182 ExpectMiscInfoEqual(&expected, observed);
182 } 183 }
183 184
184 TEST(MinidumpMiscInfoWriter, ProcessId) { 185 TEST(MinidumpMiscInfoWriter, ProcessId) {
185 MinidumpFileWriter minidump_file_writer; 186 MinidumpFileWriter minidump_file_writer;
186 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 187 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
187 188
188 const uint32_t kProcessId = 12345; 189 const uint32_t kProcessId = 12345;
189 190
190 misc_info_writer->SetProcessID(kProcessId); 191 misc_info_writer->SetProcessID(kProcessId);
191 192
192 minidump_file_writer.AddStream(misc_info_writer.Pass()); 193 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
193 194
194 StringFile string_file; 195 StringFile string_file;
195 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 196 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
196 197
197 const MINIDUMP_MISC_INFO* observed = nullptr; 198 const MINIDUMP_MISC_INFO* observed = nullptr;
198 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 199 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
199 200
200 MINIDUMP_MISC_INFO expected = {}; 201 MINIDUMP_MISC_INFO expected = {};
201 expected.Flags1 = MINIDUMP_MISC1_PROCESS_ID; 202 expected.Flags1 = MINIDUMP_MISC1_PROCESS_ID;
202 expected.ProcessId = kProcessId; 203 expected.ProcessId = kProcessId;
203 204
204 ExpectMiscInfoEqual(&expected, observed); 205 ExpectMiscInfoEqual(&expected, observed);
205 } 206 }
206 207
207 TEST(MinidumpMiscInfoWriter, ProcessTimes) { 208 TEST(MinidumpMiscInfoWriter, ProcessTimes) {
208 MinidumpFileWriter minidump_file_writer; 209 MinidumpFileWriter minidump_file_writer;
209 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 210 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
210 211
211 const time_t kProcessCreateTime = 0x15252f00; 212 const time_t kProcessCreateTime = 0x15252f00;
212 const uint32_t kProcessUserTime = 10; 213 const uint32_t kProcessUserTime = 10;
213 const uint32_t kProcessKernelTime = 5; 214 const uint32_t kProcessKernelTime = 5;
214 215
215 misc_info_writer->SetProcessTimes( 216 misc_info_writer->SetProcessTimes(
216 kProcessCreateTime, kProcessUserTime, kProcessKernelTime); 217 kProcessCreateTime, kProcessUserTime, kProcessKernelTime);
217 218
218 minidump_file_writer.AddStream(misc_info_writer.Pass()); 219 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
219 220
220 StringFile string_file; 221 StringFile string_file;
221 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 222 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
222 223
223 const MINIDUMP_MISC_INFO* observed = nullptr; 224 const MINIDUMP_MISC_INFO* observed = nullptr;
224 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 225 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
225 226
226 MINIDUMP_MISC_INFO expected = {}; 227 MINIDUMP_MISC_INFO expected = {};
227 expected.Flags1 = MINIDUMP_MISC1_PROCESS_TIMES; 228 expected.Flags1 = MINIDUMP_MISC1_PROCESS_TIMES;
228 expected.ProcessCreateTime = kProcessCreateTime; 229 expected.ProcessCreateTime = kProcessCreateTime;
(...skipping 12 matching lines...) Expand all
241 const uint32_t kProcessorMhzLimit = 3300; 242 const uint32_t kProcessorMhzLimit = 3300;
242 const uint32_t kProcessorMaxIdleState = 5; 243 const uint32_t kProcessorMaxIdleState = 5;
243 const uint32_t kProcessorCurrentIdleState = 1; 244 const uint32_t kProcessorCurrentIdleState = 1;
244 245
245 misc_info_writer->SetProcessorPowerInfo(kProcessorMaxMhz, 246 misc_info_writer->SetProcessorPowerInfo(kProcessorMaxMhz,
246 kProcessorCurrentMhz, 247 kProcessorCurrentMhz,
247 kProcessorMhzLimit, 248 kProcessorMhzLimit,
248 kProcessorMaxIdleState, 249 kProcessorMaxIdleState,
249 kProcessorCurrentIdleState); 250 kProcessorCurrentIdleState);
250 251
251 minidump_file_writer.AddStream(misc_info_writer.Pass()); 252 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
252 253
253 StringFile string_file; 254 StringFile string_file;
254 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 255 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
255 256
256 const MINIDUMP_MISC_INFO_2* observed = nullptr; 257 const MINIDUMP_MISC_INFO_2* observed = nullptr;
257 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 258 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
258 259
259 MINIDUMP_MISC_INFO_2 expected = {}; 260 MINIDUMP_MISC_INFO_2 expected = {};
260 expected.Flags1 = MINIDUMP_MISC1_PROCESSOR_POWER_INFO; 261 expected.Flags1 = MINIDUMP_MISC1_PROCESSOR_POWER_INFO;
261 expected.ProcessorMaxMhz = kProcessorMaxMhz; 262 expected.ProcessorMaxMhz = kProcessorMaxMhz;
262 expected.ProcessorCurrentMhz = kProcessorCurrentMhz; 263 expected.ProcessorCurrentMhz = kProcessorCurrentMhz;
263 expected.ProcessorMhzLimit = kProcessorMhzLimit; 264 expected.ProcessorMhzLimit = kProcessorMhzLimit;
264 expected.ProcessorMaxIdleState = kProcessorMaxIdleState; 265 expected.ProcessorMaxIdleState = kProcessorMaxIdleState;
265 expected.ProcessorCurrentIdleState = kProcessorCurrentIdleState; 266 expected.ProcessorCurrentIdleState = kProcessorCurrentIdleState;
266 267
267 ExpectMiscInfoEqual(&expected, observed); 268 ExpectMiscInfoEqual(&expected, observed);
268 } 269 }
269 270
270 TEST(MinidumpMiscInfoWriter, ProcessIntegrityLevel) { 271 TEST(MinidumpMiscInfoWriter, ProcessIntegrityLevel) {
271 MinidumpFileWriter minidump_file_writer; 272 MinidumpFileWriter minidump_file_writer;
272 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 273 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
273 274
274 const uint32_t kProcessIntegrityLevel = 0x2000; 275 const uint32_t kProcessIntegrityLevel = 0x2000;
275 276
276 misc_info_writer->SetProcessIntegrityLevel(kProcessIntegrityLevel); 277 misc_info_writer->SetProcessIntegrityLevel(kProcessIntegrityLevel);
277 278
278 minidump_file_writer.AddStream(misc_info_writer.Pass()); 279 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
279 280
280 StringFile string_file; 281 StringFile string_file;
281 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 282 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
282 283
283 const MINIDUMP_MISC_INFO_3* observed = nullptr; 284 const MINIDUMP_MISC_INFO_3* observed = nullptr;
284 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 285 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
285 286
286 MINIDUMP_MISC_INFO_3 expected = {}; 287 MINIDUMP_MISC_INFO_3 expected = {};
287 expected.Flags1 = MINIDUMP_MISC3_PROCESS_INTEGRITY; 288 expected.Flags1 = MINIDUMP_MISC3_PROCESS_INTEGRITY;
288 expected.ProcessIntegrityLevel = kProcessIntegrityLevel; 289 expected.ProcessIntegrityLevel = kProcessIntegrityLevel;
289 290
290 ExpectMiscInfoEqual(&expected, observed); 291 ExpectMiscInfoEqual(&expected, observed);
291 } 292 }
292 293
293 TEST(MinidumpMiscInfoWriter, ProcessExecuteFlags) { 294 TEST(MinidumpMiscInfoWriter, ProcessExecuteFlags) {
294 MinidumpFileWriter minidump_file_writer; 295 MinidumpFileWriter minidump_file_writer;
295 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 296 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
296 297
297 const uint32_t kProcessExecuteFlags = 0x13579bdf; 298 const uint32_t kProcessExecuteFlags = 0x13579bdf;
298 299
299 misc_info_writer->SetProcessExecuteFlags(kProcessExecuteFlags); 300 misc_info_writer->SetProcessExecuteFlags(kProcessExecuteFlags);
300 301
301 minidump_file_writer.AddStream(misc_info_writer.Pass()); 302 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
302 303
303 StringFile string_file; 304 StringFile string_file;
304 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 305 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
305 306
306 const MINIDUMP_MISC_INFO_3* observed = nullptr; 307 const MINIDUMP_MISC_INFO_3* observed = nullptr;
307 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 308 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
308 309
309 MINIDUMP_MISC_INFO_3 expected = {}; 310 MINIDUMP_MISC_INFO_3 expected = {};
310 expected.Flags1 = MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS; 311 expected.Flags1 = MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS;
311 expected.ProcessExecuteFlags = kProcessExecuteFlags; 312 expected.ProcessExecuteFlags = kProcessExecuteFlags;
312 313
313 ExpectMiscInfoEqual(&expected, observed); 314 ExpectMiscInfoEqual(&expected, observed);
314 } 315 }
315 316
316 TEST(MinidumpMiscInfoWriter, ProtectedProcess) { 317 TEST(MinidumpMiscInfoWriter, ProtectedProcess) {
317 MinidumpFileWriter minidump_file_writer; 318 MinidumpFileWriter minidump_file_writer;
318 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 319 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
319 320
320 const uint32_t kProtectedProcess = 1; 321 const uint32_t kProtectedProcess = 1;
321 322
322 misc_info_writer->SetProtectedProcess(kProtectedProcess); 323 misc_info_writer->SetProtectedProcess(kProtectedProcess);
323 324
324 minidump_file_writer.AddStream(misc_info_writer.Pass()); 325 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
325 326
326 StringFile string_file; 327 StringFile string_file;
327 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 328 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
328 329
329 const MINIDUMP_MISC_INFO_3* observed = nullptr; 330 const MINIDUMP_MISC_INFO_3* observed = nullptr;
330 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 331 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
331 332
332 MINIDUMP_MISC_INFO_3 expected = {}; 333 MINIDUMP_MISC_INFO_3 expected = {};
333 expected.Flags1 = MINIDUMP_MISC3_PROTECTED_PROCESS; 334 expected.Flags1 = MINIDUMP_MISC3_PROTECTED_PROCESS;
334 expected.ProtectedProcess = kProtectedProcess; 335 expected.ProtectedProcess = kProtectedProcess;
(...skipping 16 matching lines...) Expand all
351 352
352 misc_info_writer->SetTimeZone(kTimeZoneId, 353 misc_info_writer->SetTimeZone(kTimeZoneId,
353 kBias, 354 kBias,
354 kStandardName, 355 kStandardName,
355 kStandardDate, 356 kStandardDate,
356 kStandardBias, 357 kStandardBias,
357 kDaylightName, 358 kDaylightName,
358 kDaylightDate, 359 kDaylightDate,
359 kDaylightBias); 360 kDaylightBias);
360 361
361 minidump_file_writer.AddStream(misc_info_writer.Pass()); 362 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
362 363
363 StringFile string_file; 364 StringFile string_file;
364 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 365 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
365 366
366 const MINIDUMP_MISC_INFO_3* observed = nullptr; 367 const MINIDUMP_MISC_INFO_3* observed = nullptr;
367 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 368 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
368 369
369 MINIDUMP_MISC_INFO_3 expected = {}; 370 MINIDUMP_MISC_INFO_3 expected = {};
370 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE; 371 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE;
371 expected.TimeZoneId = kTimeZoneId; 372 expected.TimeZoneId = kTimeZoneId;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 413
413 misc_info_writer->SetTimeZone(kTimeZoneId, 414 misc_info_writer->SetTimeZone(kTimeZoneId,
414 kBias, 415 kBias,
415 standard_name, 416 standard_name,
416 kSystemTimeZero, 417 kSystemTimeZero,
417 kStandardBias, 418 kStandardBias,
418 daylight_name, 419 daylight_name,
419 kSystemTimeZero, 420 kSystemTimeZero,
420 kDaylightBias); 421 kDaylightBias);
421 422
422 minidump_file_writer.AddStream(misc_info_writer.Pass()); 423 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
423 424
424 StringFile string_file; 425 StringFile string_file;
425 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 426 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
426 427
427 const MINIDUMP_MISC_INFO_3* observed = nullptr; 428 const MINIDUMP_MISC_INFO_3* observed = nullptr;
428 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 429 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
429 430
430 MINIDUMP_MISC_INFO_3 expected = {}; 431 MINIDUMP_MISC_INFO_3 expected = {};
431 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE; 432 expected.Flags1 = MINIDUMP_MISC3_TIMEZONE;
432 expected.TimeZoneId = kTimeZoneId; 433 expected.TimeZoneId = kTimeZoneId;
(...skipping 20 matching lines...) Expand all
453 454
454 TEST(MinidumpMiscInfoWriter, BuildStrings) { 455 TEST(MinidumpMiscInfoWriter, BuildStrings) {
455 MinidumpFileWriter minidump_file_writer; 456 MinidumpFileWriter minidump_file_writer;
456 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 457 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
457 458
458 const char kBuildString[] = "build string"; 459 const char kBuildString[] = "build string";
459 const char kDebugBuildString[] = "debug build string"; 460 const char kDebugBuildString[] = "debug build string";
460 461
461 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString); 462 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString);
462 463
463 minidump_file_writer.AddStream(misc_info_writer.Pass()); 464 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
464 465
465 StringFile string_file; 466 StringFile string_file;
466 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 467 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
467 468
468 const MINIDUMP_MISC_INFO_4* observed = nullptr; 469 const MINIDUMP_MISC_INFO_4* observed = nullptr;
469 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 470 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
470 471
471 MINIDUMP_MISC_INFO_4 expected = {}; 472 MINIDUMP_MISC_INFO_4 expected = {};
472 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING; 473 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
473 base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString); 474 base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
(...skipping 16 matching lines...) Expand all
490 MinidumpFileWriter minidump_file_writer; 491 MinidumpFileWriter minidump_file_writer;
491 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 492 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
492 493
493 MINIDUMP_MISC_INFO_4 tmp; 494 MINIDUMP_MISC_INFO_4 tmp;
494 ALLOW_UNUSED_LOCAL(tmp); 495 ALLOW_UNUSED_LOCAL(tmp);
495 std::string build_string(arraysize(tmp.BuildString) + 1, 'B'); 496 std::string build_string(arraysize(tmp.BuildString) + 1, 'B');
496 std::string debug_build_string(arraysize(tmp.DbgBldStr), 'D'); 497 std::string debug_build_string(arraysize(tmp.DbgBldStr), 'D');
497 498
498 misc_info_writer->SetBuildString(build_string, debug_build_string); 499 misc_info_writer->SetBuildString(build_string, debug_build_string);
499 500
500 minidump_file_writer.AddStream(misc_info_writer.Pass()); 501 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
501 502
502 StringFile string_file; 503 StringFile string_file;
503 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 504 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
504 505
505 const MINIDUMP_MISC_INFO_4* observed = nullptr; 506 const MINIDUMP_MISC_INFO_4* observed = nullptr;
506 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 507 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
507 508
508 MINIDUMP_MISC_INFO_4 expected = {}; 509 MINIDUMP_MISC_INFO_4 expected = {};
509 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING; 510 expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
510 base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string); 511 base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 misc_info_writer->SetTimeZone(kTimeZoneId, 561 misc_info_writer->SetTimeZone(kTimeZoneId,
561 kBias, 562 kBias,
562 kStandardName, 563 kStandardName,
563 kSystemTimeZero, 564 kSystemTimeZero,
564 kStandardBias, 565 kStandardBias,
565 kDaylightName, 566 kDaylightName,
566 kSystemTimeZero, 567 kSystemTimeZero,
567 kDaylightBias); 568 kDaylightBias);
568 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString); 569 misc_info_writer->SetBuildString(kBuildString, kDebugBuildString);
569 570
570 minidump_file_writer.AddStream(misc_info_writer.Pass()); 571 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
571 572
572 StringFile string_file; 573 StringFile string_file;
573 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 574 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
574 575
575 const MINIDUMP_MISC_INFO_4* observed = nullptr; 576 const MINIDUMP_MISC_INFO_4* observed = nullptr;
576 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed)); 577 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &observed));
577 578
578 MINIDUMP_MISC_INFO_4 expected = {}; 579 MINIDUMP_MISC_INFO_4 expected = {};
579 expected.Flags1 = 580 expected.Flags1 =
580 MINIDUMP_MISC1_PROCESS_ID | MINIDUMP_MISC1_PROCESS_TIMES | 581 MINIDUMP_MISC1_PROCESS_ID | MINIDUMP_MISC1_PROCESS_TIMES |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 expect_misc_info.ProcessorMaxMhz * kHzPerMHz); 695 expect_misc_info.ProcessorMaxMhz * kHzPerMHz);
695 system_snapshot->SetTimeZone(SystemSnapshot::kObservingStandardTime, 696 system_snapshot->SetTimeZone(SystemSnapshot::kObservingStandardTime,
696 expect_misc_info.TimeZone.Bias * -60, 697 expect_misc_info.TimeZone.Bias * -60,
697 (expect_misc_info.TimeZone.Bias + 698 (expect_misc_info.TimeZone.Bias +
698 expect_misc_info.TimeZone.DaylightBias) * -60, 699 expect_misc_info.TimeZone.DaylightBias) * -60,
699 kStandardTimeName, 700 kStandardTimeName,
700 kDaylightTimeName); 701 kDaylightTimeName);
701 system_snapshot->SetOSVersionFull(kOSVersionFull); 702 system_snapshot->SetOSVersionFull(kOSVersionFull);
702 system_snapshot->SetMachineDescription(kMachineDescription); 703 system_snapshot->SetMachineDescription(kMachineDescription);
703 704
704 process_snapshot.SetSystem(system_snapshot.Pass()); 705 process_snapshot.SetSystem(crashpad::move(system_snapshot));
705 706
706 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 707 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
707 misc_info_writer->InitializeFromSnapshot(&process_snapshot); 708 misc_info_writer->InitializeFromSnapshot(&process_snapshot);
708 709
709 MinidumpFileWriter minidump_file_writer; 710 MinidumpFileWriter minidump_file_writer;
710 minidump_file_writer.AddStream(misc_info_writer.Pass()); 711 minidump_file_writer.AddStream(crashpad::move(misc_info_writer));
711 712
712 StringFile string_file; 713 StringFile string_file;
713 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 714 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
714 715
715 const MINIDUMP_MISC_INFO_4* misc_info = nullptr; 716 const MINIDUMP_MISC_INFO_4* misc_info = nullptr;
716 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &misc_info)); 717 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(string_file.string(), &misc_info));
717 718
718 ExpectMiscInfoEqual(&expect_misc_info, misc_info); 719 ExpectMiscInfoEqual(&expect_misc_info, misc_info);
719 } 720 }
720 721
721 } // namespace 722 } // namespace
722 } // namespace test 723 } // namespace test
723 } // namespace crashpad 724 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_memory_writer_test.cc ('k') | minidump/minidump_module_crashpad_info_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698