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

Side by Side Diff: minidump/minidump_system_info_writer_test.cc

Issue 1513573005: Provide std::move() in compat instead of using crashpad::move() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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
« no previous file with comments | « minidump/minidump_string_writer.cc ('k') | minidump/minidump_thread_writer.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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/minidump_system_info_writer.h" 15 #include "minidump/minidump_system_info_writer.h"
16 16
17 #include <windows.h> 17 #include <windows.h>
18 #include <dbghelp.h> 18 #include <dbghelp.h>
19 #include <string.h> 19 #include <string.h>
20 #include <sys/types.h> 20 #include <sys/types.h>
21 21
22 #include <algorithm> 22 #include <algorithm>
23 #include <string> 23 #include <string>
24 #include <utility>
24 25
25 #include "base/compiler_specific.h" 26 #include "base/compiler_specific.h"
26 #include "gtest/gtest.h" 27 #include "gtest/gtest.h"
27 #include "minidump/minidump_file_writer.h" 28 #include "minidump/minidump_file_writer.h"
28 #include "minidump/test/minidump_file_writer_test_util.h" 29 #include "minidump/test/minidump_file_writer_test_util.h"
29 #include "minidump/test/minidump_string_writer_test_util.h" 30 #include "minidump/test/minidump_string_writer_test_util.h"
30 #include "minidump/test/minidump_writable_test_util.h" 31 #include "minidump/test/minidump_writable_test_util.h"
31 #include "snapshot/test/test_system_snapshot.h" 32 #include "snapshot/test/test_system_snapshot.h"
32 #include "test/gtest_death_check.h" 33 #include "test/gtest_death_check.h"
33 #include "util/file/string_file.h" 34 #include "util/file/string_file.h"
34 #include "util/stdlib/move.h"
35 35
36 namespace crashpad { 36 namespace crashpad {
37 namespace test { 37 namespace test {
38 namespace { 38 namespace {
39 39
40 void GetSystemInfoStream(const std::string& file_contents, 40 void GetSystemInfoStream(const std::string& file_contents,
41 size_t csd_version_length, 41 size_t csd_version_length,
42 const MINIDUMP_SYSTEM_INFO** system_info, 42 const MINIDUMP_SYSTEM_INFO** system_info,
43 const MINIDUMP_STRING** csd_version) { 43 const MINIDUMP_STRING** csd_version) {
44 // The expected number of bytes for the CSD version’s MINIDUMP_STRING::Buffer. 44 // The expected number of bytes for the CSD version’s MINIDUMP_STRING::Buffer.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 MinidumpStringAtRVA(file_contents, (*system_info)->CSDVersionRva); 77 MinidumpStringAtRVA(file_contents, (*system_info)->CSDVersionRva);
78 EXPECT_EQ(kCSDVersionBytes, (*csd_version)->Length); 78 EXPECT_EQ(kCSDVersionBytes, (*csd_version)->Length);
79 } 79 }
80 80
81 TEST(MinidumpSystemInfoWriter, Empty) { 81 TEST(MinidumpSystemInfoWriter, Empty) {
82 MinidumpFileWriter minidump_file_writer; 82 MinidumpFileWriter minidump_file_writer;
83 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 83 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
84 84
85 system_info_writer->SetCSDVersion(std::string()); 85 system_info_writer->SetCSDVersion(std::string());
86 86
87 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 87 minidump_file_writer.AddStream(std::move(system_info_writer));
88 88
89 StringFile string_file; 89 StringFile string_file;
90 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 90 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
91 91
92 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 92 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
93 const MINIDUMP_STRING* csd_version = nullptr; 93 const MINIDUMP_STRING* csd_version = nullptr;
94 94
95 ASSERT_NO_FATAL_FAILURE( 95 ASSERT_NO_FATAL_FAILURE(
96 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version)); 96 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version));
97 97
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 system_info_writer->SetOS(kOS); 148 system_info_writer->SetOS(kOS);
149 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation); 149 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation);
150 system_info_writer->SetOSVersion( 150 system_info_writer->SetOSVersion(
151 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild); 151 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild);
152 system_info_writer->SetCSDVersion(kCSDVersion); 152 system_info_writer->SetCSDVersion(kCSDVersion);
153 system_info_writer->SetSuiteMask(kSuiteMask); 153 system_info_writer->SetSuiteMask(kSuiteMask);
154 system_info_writer->SetCPUX86VendorString(kCPUVendor); 154 system_info_writer->SetCPUX86VendorString(kCPUVendor);
155 system_info_writer->SetCPUX86VersionAndFeatures(kCPUVersion, kCPUFeatures); 155 system_info_writer->SetCPUX86VersionAndFeatures(kCPUVersion, kCPUFeatures);
156 system_info_writer->SetCPUX86AMDExtendedFeatures(kAMDFeatures); 156 system_info_writer->SetCPUX86AMDExtendedFeatures(kAMDFeatures);
157 157
158 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 158 minidump_file_writer.AddStream(std::move(system_info_writer));
159 159
160 StringFile string_file; 160 StringFile string_file;
161 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 161 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
162 162
163 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 163 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
164 const MINIDUMP_STRING* csd_version = nullptr; 164 const MINIDUMP_STRING* csd_version = nullptr;
165 165
166 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream( 166 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
167 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version)); 167 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version));
168 168
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 system_info_writer->SetCPUArchitecture(kCPUArchitecture); 208 system_info_writer->SetCPUArchitecture(kCPUArchitecture);
209 system_info_writer->SetCPULevelAndRevision(kCPULevel, kCPURevision); 209 system_info_writer->SetCPULevelAndRevision(kCPULevel, kCPURevision);
210 system_info_writer->SetCPUCount(kCPUCount); 210 system_info_writer->SetCPUCount(kCPUCount);
211 system_info_writer->SetOS(kOS); 211 system_info_writer->SetOS(kOS);
212 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation); 212 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation);
213 system_info_writer->SetOSVersion( 213 system_info_writer->SetOSVersion(
214 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild); 214 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild);
215 system_info_writer->SetCSDVersion(kCSDVersion); 215 system_info_writer->SetCSDVersion(kCSDVersion);
216 system_info_writer->SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]); 216 system_info_writer->SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]);
217 217
218 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 218 minidump_file_writer.AddStream(std::move(system_info_writer));
219 219
220 StringFile string_file; 220 StringFile string_file;
221 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 221 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
222 222
223 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 223 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
224 const MINIDUMP_STRING* csd_version; 224 const MINIDUMP_STRING* csd_version;
225 225
226 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream( 226 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
227 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version)); 227 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version));
228 228
(...skipping 21 matching lines...) Expand all
250 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 250 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
251 251
252 const MinidumpCPUArchitecture kCPUArchitecture = kMinidumpCPUArchitectureX86; 252 const MinidumpCPUArchitecture kCPUArchitecture = kMinidumpCPUArchitectureX86;
253 const uint32_t kCPUVendor[] = {'uneG', 'Ieni', 'letn'}; 253 const uint32_t kCPUVendor[] = {'uneG', 'Ieni', 'letn'};
254 254
255 system_info_writer->SetCPUArchitecture(kCPUArchitecture); 255 system_info_writer->SetCPUArchitecture(kCPUArchitecture);
256 system_info_writer->SetCPUX86Vendor( 256 system_info_writer->SetCPUX86Vendor(
257 kCPUVendor[0], kCPUVendor[1], kCPUVendor[2]); 257 kCPUVendor[0], kCPUVendor[1], kCPUVendor[2]);
258 system_info_writer->SetCSDVersion(std::string()); 258 system_info_writer->SetCSDVersion(std::string());
259 259
260 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 260 minidump_file_writer.AddStream(std::move(system_info_writer));
261 261
262 StringFile string_file; 262 StringFile string_file;
263 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 263 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
264 264
265 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 265 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
266 const MINIDUMP_STRING* csd_version; 266 const MINIDUMP_STRING* csd_version;
267 267
268 ASSERT_NO_FATAL_FAILURE( 268 ASSERT_NO_FATAL_FAILURE(
269 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version)); 269 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version));
270 270
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 system_snapshot.SetOSServer(true); 330 system_snapshot.SetOSServer(true);
331 system_snapshot.SetOSVersion(expect_system_info.MajorVersion, 331 system_snapshot.SetOSVersion(expect_system_info.MajorVersion,
332 expect_system_info.MinorVersion, 332 expect_system_info.MinorVersion,
333 expect_system_info.BuildNumber, 333 expect_system_info.BuildNumber,
334 kOSVersionBuild); 334 kOSVersionBuild);
335 335
336 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 336 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
337 system_info_writer->InitializeFromSnapshot(&system_snapshot); 337 system_info_writer->InitializeFromSnapshot(&system_snapshot);
338 338
339 MinidumpFileWriter minidump_file_writer; 339 MinidumpFileWriter minidump_file_writer;
340 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 340 minidump_file_writer.AddStream(std::move(system_info_writer));
341 341
342 StringFile string_file; 342 StringFile string_file;
343 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 343 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
344 344
345 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 345 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
346 const MINIDUMP_STRING* csd_version = nullptr; 346 const MINIDUMP_STRING* csd_version = nullptr;
347 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(), 347 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(),
348 strlen(kOSVersionBuild), 348 strlen(kOSVersionBuild),
349 &system_info, 349 &system_info,
350 &csd_version)); 350 &csd_version));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 system_snapshot.SetOSVersion(expect_system_info.MajorVersion, 425 system_snapshot.SetOSVersion(expect_system_info.MajorVersion,
426 expect_system_info.MinorVersion, 426 expect_system_info.MinorVersion,
427 expect_system_info.BuildNumber, 427 expect_system_info.BuildNumber,
428 kOSVersionBuild); 428 kOSVersionBuild);
429 system_snapshot.SetNXEnabled(true); 429 system_snapshot.SetNXEnabled(true);
430 430
431 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 431 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
432 system_info_writer->InitializeFromSnapshot(&system_snapshot); 432 system_info_writer->InitializeFromSnapshot(&system_snapshot);
433 433
434 MinidumpFileWriter minidump_file_writer; 434 MinidumpFileWriter minidump_file_writer;
435 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 435 minidump_file_writer.AddStream(std::move(system_info_writer));
436 436
437 StringFile string_file; 437 StringFile string_file;
438 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 438 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
439 439
440 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 440 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
441 const MINIDUMP_STRING* csd_version = nullptr; 441 const MINIDUMP_STRING* csd_version = nullptr;
442 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(), 442 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(),
443 strlen(kOSVersionBuild), 443 strlen(kOSVersionBuild),
444 &system_info, 444 &system_info,
445 &csd_version)); 445 &csd_version));
(...skipping 17 matching lines...) Expand all
463 system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1]); 463 system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1]);
464 464
465 for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) { 465 for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) {
466 EXPECT_EQ(kOSVersionBuild[index], csd_version->Buffer[index]) << index; 466 EXPECT_EQ(kOSVersionBuild[index], csd_version->Buffer[index]) << index;
467 } 467 }
468 } 468 }
469 469
470 TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) { 470 TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) {
471 MinidumpFileWriter minidump_file_writer; 471 MinidumpFileWriter minidump_file_writer;
472 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 472 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
473 minidump_file_writer.AddStream(crashpad::move(system_info_writer)); 473 minidump_file_writer.AddStream(std::move(system_info_writer));
474 474
475 StringFile string_file; 475 StringFile string_file;
476 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), 476 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),
477 "csd_version_"); 477 "csd_version_");
478 } 478 }
479 479
480 } // namespace 480 } // namespace
481 } // namespace test 481 } // namespace test
482 } // namespace crashpad 482 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_string_writer.cc ('k') | minidump/minidump_thread_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698