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

Side by Side Diff: minidump/minidump_misc_info_writer_test.cc

Issue 899163004: win: Fixes for minidump_misc_info_writer_test.cc (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_test-10
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_EQ(expected->ProcessId, observed->ProcessId); 92 EXPECT_EQ(expected->ProcessId, observed->ProcessId);
93 EXPECT_EQ(expected->ProcessCreateTime, observed->ProcessCreateTime); 93 EXPECT_EQ(expected->ProcessCreateTime, observed->ProcessCreateTime);
94 EXPECT_EQ(expected->ProcessUserTime, observed->ProcessUserTime); 94 EXPECT_EQ(expected->ProcessUserTime, observed->ProcessUserTime);
95 EXPECT_EQ(expected->ProcessKernelTime, observed->ProcessKernelTime); 95 EXPECT_EQ(expected->ProcessKernelTime, observed->ProcessKernelTime);
96 } 96 }
97 97
98 template <> 98 template <>
99 void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_2>( 99 void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_2>(
100 const MINIDUMP_MISC_INFO_2* expected, 100 const MINIDUMP_MISC_INFO_2* expected,
101 const MINIDUMP_MISC_INFO_2* observed) { 101 const MINIDUMP_MISC_INFO_2* observed) {
102 ExpectMiscInfoEqual<MINIDUMP_MISC_INFO>(expected, observed); 102 ExpectMiscInfoEqual<MINIDUMP_MISC_INFO>(
103 reinterpret_cast<const MINIDUMP_MISC_INFO*>(expected),
104 reinterpret_cast<const MINIDUMP_MISC_INFO*>(observed));
103 EXPECT_EQ(expected->ProcessorMaxMhz, observed->ProcessorMaxMhz); 105 EXPECT_EQ(expected->ProcessorMaxMhz, observed->ProcessorMaxMhz);
104 EXPECT_EQ(expected->ProcessorCurrentMhz, observed->ProcessorCurrentMhz); 106 EXPECT_EQ(expected->ProcessorCurrentMhz, observed->ProcessorCurrentMhz);
105 EXPECT_EQ(expected->ProcessorMhzLimit, observed->ProcessorMhzLimit); 107 EXPECT_EQ(expected->ProcessorMhzLimit, observed->ProcessorMhzLimit);
106 EXPECT_EQ(expected->ProcessorMaxIdleState, observed->ProcessorMaxIdleState); 108 EXPECT_EQ(expected->ProcessorMaxIdleState, observed->ProcessorMaxIdleState);
107 EXPECT_EQ(expected->ProcessorCurrentIdleState, 109 EXPECT_EQ(expected->ProcessorCurrentIdleState,
108 observed->ProcessorCurrentIdleState); 110 observed->ProcessorCurrentIdleState);
109 } 111 }
110 112
111 template <> 113 template <>
112 void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>( 114 void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(
113 const MINIDUMP_MISC_INFO_3* expected, 115 const MINIDUMP_MISC_INFO_3* expected,
114 const MINIDUMP_MISC_INFO_3* observed) { 116 const MINIDUMP_MISC_INFO_3* observed) {
115 ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_2>(expected, observed); 117 ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_2>(
118 reinterpret_cast<const MINIDUMP_MISC_INFO_2*>(expected),
119 reinterpret_cast<const MINIDUMP_MISC_INFO_2*>(observed));
116 EXPECT_EQ(expected->ProcessIntegrityLevel, observed->ProcessIntegrityLevel); 120 EXPECT_EQ(expected->ProcessIntegrityLevel, observed->ProcessIntegrityLevel);
117 EXPECT_EQ(expected->ProcessExecuteFlags, observed->ProcessExecuteFlags); 121 EXPECT_EQ(expected->ProcessExecuteFlags, observed->ProcessExecuteFlags);
118 EXPECT_EQ(expected->ProtectedProcess, observed->ProtectedProcess); 122 EXPECT_EQ(expected->ProtectedProcess, observed->ProtectedProcess);
119 EXPECT_EQ(expected->TimeZoneId, observed->TimeZoneId); 123 EXPECT_EQ(expected->TimeZoneId, observed->TimeZoneId);
120 EXPECT_EQ(expected->TimeZone.Bias, observed->TimeZone.Bias); 124 EXPECT_EQ(expected->TimeZone.Bias, observed->TimeZone.Bias);
121 { 125 {
122 SCOPED_TRACE("Standard"); 126 SCOPED_TRACE("Standard");
123 ExpectNULPaddedString16Equal(expected->TimeZone.StandardName, 127 ExpectNULPaddedString16Equal(expected->TimeZone.StandardName,
124 observed->TimeZone.StandardName, 128 observed->TimeZone.StandardName,
125 arraysize(expected->TimeZone.StandardName)); 129 arraysize(expected->TimeZone.StandardName));
126 ExpectSystemTimeEqual(&expected->TimeZone.StandardDate, 130 ExpectSystemTimeEqual(&expected->TimeZone.StandardDate,
127 &observed->TimeZone.StandardDate); 131 &observed->TimeZone.StandardDate);
128 EXPECT_EQ(expected->TimeZone.StandardBias, observed->TimeZone.StandardBias); 132 EXPECT_EQ(expected->TimeZone.StandardBias, observed->TimeZone.StandardBias);
129 } 133 }
130 { 134 {
131 SCOPED_TRACE("Daylight"); 135 SCOPED_TRACE("Daylight");
132 ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName, 136 ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName,
133 observed->TimeZone.DaylightName, 137 observed->TimeZone.DaylightName,
134 arraysize(expected->TimeZone.DaylightName)); 138 arraysize(expected->TimeZone.DaylightName));
135 ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate, 139 ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate,
136 &observed->TimeZone.DaylightDate); 140 &observed->TimeZone.DaylightDate);
137 EXPECT_EQ(expected->TimeZone.DaylightBias, observed->TimeZone.DaylightBias); 141 EXPECT_EQ(expected->TimeZone.DaylightBias, observed->TimeZone.DaylightBias);
138 } 142 }
139 } 143 }
140 144
141 template <> 145 template <>
142 void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_4>( 146 void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_4>(
143 const MINIDUMP_MISC_INFO_4* expected, 147 const MINIDUMP_MISC_INFO_4* expected,
144 const MINIDUMP_MISC_INFO_4* observed) { 148 const MINIDUMP_MISC_INFO_4* observed) {
145 ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(expected, observed); 149 ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(
150 reinterpret_cast<const MINIDUMP_MISC_INFO_3*>(expected),
151 reinterpret_cast<const MINIDUMP_MISC_INFO_3*>(observed));
146 { 152 {
147 SCOPED_TRACE("BuildString"); 153 SCOPED_TRACE("BuildString");
148 ExpectNULPaddedString16Equal(expected->BuildString, 154 ExpectNULPaddedString16Equal(expected->BuildString,
149 observed->BuildString, 155 observed->BuildString,
150 arraysize(expected->BuildString)); 156 arraysize(expected->BuildString));
151 } 157 }
152 { 158 {
153 SCOPED_TRACE("DbgBldStr"); 159 SCOPED_TRACE("DbgBldStr");
154 ExpectNULPaddedString16Equal(expected->DbgBldStr, 160 ExpectNULPaddedString16Equal(expected->DbgBldStr,
155 observed->DbgBldStr, 161 observed->DbgBldStr,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 391
386 TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) { 392 TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
387 // This test makes sure that the time zone name strings are truncated properly 393 // This test makes sure that the time zone name strings are truncated properly
388 // to the widths of their fields. 394 // to the widths of their fields.
389 395
390 MinidumpFileWriter minidump_file_writer; 396 MinidumpFileWriter minidump_file_writer;
391 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 397 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
392 398
393 const uint32_t kTimeZoneId = 2; 399 const uint32_t kTimeZoneId = 2;
394 const int32_t kBias = 300; 400 const int32_t kBias = 300;
395 std::string standard_name( 401 MINIDUMP_MISC_INFO_N tmp; (void)tmp;
Mark Mentovai 2015/02/05 14:31:35 Add ALLOW_UNUSED_LOCAL to mini_chromium and use it
scottmg 2015/02/05 17:04:28 Done.
396 arraysize(decltype(MINIDUMP_MISC_INFO_N::TimeZone)::StandardName) + 1, 402 std::string standard_name(arraysize(tmp.TimeZone.StandardName) + 1, 's');
397 's');
398 const int32_t kStandardBias = 0; 403 const int32_t kStandardBias = 0;
399 std::string daylight_name( 404 std::string daylight_name(arraysize(tmp.TimeZone.DaylightName), 'd');
400 arraysize(decltype(MINIDUMP_MISC_INFO_N::TimeZone)::DaylightName), 'd');
401 const int32_t kDaylightBias = -60; 405 const int32_t kDaylightBias = -60;
402 406
403 // Test using kSystemTimeZero, because not all platforms will be able to 407 // Test using kSystemTimeZero, because not all platforms will be able to
404 // provide daylight saving time transition times. 408 // provide daylight saving time transition times.
405 const SYSTEMTIME kSystemTimeZero = {}; 409 const SYSTEMTIME kSystemTimeZero = {};
406 410
407 misc_info_writer->SetTimeZone(kTimeZoneId, 411 misc_info_writer->SetTimeZone(kTimeZoneId,
408 kBias, 412 kBias,
409 standard_name, 413 standard_name,
410 kSystemTimeZero, 414 kSystemTimeZero,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 ExpectMiscInfoEqual(&expected, observed); 481 ExpectMiscInfoEqual(&expected, observed);
478 } 482 }
479 483
480 TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) { 484 TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) {
481 // This test makes sure that the build strings are truncated properly to the 485 // This test makes sure that the build strings are truncated properly to the
482 // widths of their fields. 486 // widths of their fields.
483 487
484 MinidumpFileWriter minidump_file_writer; 488 MinidumpFileWriter minidump_file_writer;
485 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter()); 489 auto misc_info_writer = make_scoped_ptr(new MinidumpMiscInfoWriter());
486 490
487 std::string build_string(arraysize(MINIDUMP_MISC_INFO_N::BuildString) + 1, 491 MINIDUMP_MISC_INFO_4 tmp; (void)tmp;
Mark Mentovai 2015/02/05 14:31:35 Here too.
scottmg 2015/02/05 17:04:28 Done.
488 'B'); 492 std::string build_string(arraysize(tmp.BuildString) + 1, 'B');
Mark Mentovai 2015/02/05 14:31:35 Nice, the local variable makes these lines less ug
489 std::string debug_build_string(arraysize(MINIDUMP_MISC_INFO_N::DbgBldStr), 493 std::string debug_build_string(arraysize(tmp.DbgBldStr), 'D');
490 'D');
491 494
492 misc_info_writer->SetBuildString(build_string, debug_build_string); 495 misc_info_writer->SetBuildString(build_string, debug_build_string);
493 496
494 minidump_file_writer.AddStream(misc_info_writer.Pass()); 497 minidump_file_writer.AddStream(misc_info_writer.Pass());
495 498
496 StringFileWriter file_writer; 499 StringFileWriter file_writer;
497 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 500 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
498 501
499 const MINIDUMP_MISC_INFO_4* observed; 502 const MINIDUMP_MISC_INFO_4* observed;
500 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed)); 503 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &observed));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 arraysize(expect_misc_info.TimeZone.DaylightName)); 666 arraysize(expect_misc_info.TimeZone.DaylightName));
664 expect_misc_info.TimeZone.DaylightBias = -60; 667 expect_misc_info.TimeZone.DaylightBias = -60;
665 c16lcpy(expect_misc_info.BuildString, 668 c16lcpy(expect_misc_info.BuildString,
666 build_string_utf16.c_str(), 669 build_string_utf16.c_str(),
667 arraysize(expect_misc_info.BuildString)); 670 arraysize(expect_misc_info.BuildString));
668 c16lcpy(expect_misc_info.DbgBldStr, 671 c16lcpy(expect_misc_info.DbgBldStr,
669 debug_build_string_utf16.c_str(), 672 debug_build_string_utf16.c_str(),
670 arraysize(expect_misc_info.DbgBldStr)); 673 arraysize(expect_misc_info.DbgBldStr));
671 674
672 const timeval kStartTime = 675 const timeval kStartTime =
673 { implicit_cast<time_t>(expect_misc_info.ProcessCreateTime), 0 }; 676 { static_cast<time_t>(expect_misc_info.ProcessCreateTime), 0 };
674 const timeval kUserCPUTime = 677 const timeval kUserCPUTime =
675 { implicit_cast<time_t>(expect_misc_info.ProcessUserTime), 0 }; 678 { static_cast<time_t>(expect_misc_info.ProcessUserTime), 0 };
676 const timeval kSystemCPUTime = 679 const timeval kSystemCPUTime =
677 { implicit_cast<time_t>(expect_misc_info.ProcessKernelTime), 0 }; 680 { static_cast<time_t>(expect_misc_info.ProcessKernelTime), 0 };
678 681
679 TestProcessSnapshot process_snapshot; 682 TestProcessSnapshot process_snapshot;
680 process_snapshot.SetProcessID(expect_misc_info.ProcessId); 683 process_snapshot.SetProcessID(expect_misc_info.ProcessId);
681 process_snapshot.SetProcessStartTime(kStartTime); 684 process_snapshot.SetProcessStartTime(kStartTime);
682 process_snapshot.SetProcessCPUTimes(kUserCPUTime, kSystemCPUTime); 685 process_snapshot.SetProcessCPUTimes(kUserCPUTime, kSystemCPUTime);
683 686
684 auto system_snapshot = make_scoped_ptr(new TestSystemSnapshot()); 687 auto system_snapshot = make_scoped_ptr(new TestSystemSnapshot());
685 const uint64_t kHzPerMHz = 1E6; 688 const uint64_t kHzPerMHz = static_cast<uint64_t>(1E6);
686 system_snapshot->SetCPUFrequency( 689 system_snapshot->SetCPUFrequency(
687 expect_misc_info.ProcessorCurrentMhz * kHzPerMHz, 690 expect_misc_info.ProcessorCurrentMhz * kHzPerMHz,
688 expect_misc_info.ProcessorMaxMhz * kHzPerMHz); 691 expect_misc_info.ProcessorMaxMhz * kHzPerMHz);
689 system_snapshot->SetTimeZone(SystemSnapshot::kObservingStandardTime, 692 system_snapshot->SetTimeZone(SystemSnapshot::kObservingStandardTime,
690 expect_misc_info.TimeZone.Bias * -60, 693 expect_misc_info.TimeZone.Bias * -60,
691 (expect_misc_info.TimeZone.Bias + 694 (expect_misc_info.TimeZone.Bias +
692 expect_misc_info.TimeZone.DaylightBias) * -60, 695 expect_misc_info.TimeZone.DaylightBias) * -60,
693 kStandardTimeName, 696 kStandardTimeName,
694 kDaylightTimeName); 697 kDaylightTimeName);
695 system_snapshot->SetOSVersionFull(kOSVersionFull); 698 system_snapshot->SetOSVersionFull(kOSVersionFull);
(...skipping 12 matching lines...) Expand all
708 711
709 const MINIDUMP_MISC_INFO_4* misc_info; 712 const MINIDUMP_MISC_INFO_4* misc_info;
710 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &misc_info)); 713 ASSERT_NO_FATAL_FAILURE(GetMiscInfoStream(file_writer.string(), &misc_info));
711 714
712 ExpectMiscInfoEqual(&expect_misc_info, misc_info); 715 ExpectMiscInfoEqual(&expect_misc_info, misc_info);
713 } 716 }
714 717
715 } // namespace 718 } // namespace
716 } // namespace test 719 } // namespace test
717 } // namespace crashpad 720 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698