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

Side by Side Diff: minidump/minidump_system_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
« 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,
(...skipping 13 matching lines...) Expand all
24 24
25 #include "base/compiler_specific.h" 25 #include "base/compiler_specific.h"
26 #include "gtest/gtest.h" 26 #include "gtest/gtest.h"
27 #include "minidump/minidump_file_writer.h" 27 #include "minidump/minidump_file_writer.h"
28 #include "minidump/test/minidump_file_writer_test_util.h" 28 #include "minidump/test/minidump_file_writer_test_util.h"
29 #include "minidump/test/minidump_string_writer_test_util.h" 29 #include "minidump/test/minidump_string_writer_test_util.h"
30 #include "minidump/test/minidump_writable_test_util.h" 30 #include "minidump/test/minidump_writable_test_util.h"
31 #include "snapshot/test/test_system_snapshot.h" 31 #include "snapshot/test/test_system_snapshot.h"
32 #include "test/gtest_death_check.h" 32 #include "test/gtest_death_check.h"
33 #include "util/file/string_file.h" 33 #include "util/file/string_file.h"
34 #include "util/stdlib/move.h"
34 35
35 namespace crashpad { 36 namespace crashpad {
36 namespace test { 37 namespace test {
37 namespace { 38 namespace {
38 39
39 void GetSystemInfoStream(const std::string& file_contents, 40 void GetSystemInfoStream(const std::string& file_contents,
40 size_t csd_version_length, 41 size_t csd_version_length,
41 const MINIDUMP_SYSTEM_INFO** system_info, 42 const MINIDUMP_SYSTEM_INFO** system_info,
42 const MINIDUMP_STRING** csd_version) { 43 const MINIDUMP_STRING** csd_version) {
43 // 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
76 MinidumpStringAtRVA(file_contents, (*system_info)->CSDVersionRva); 77 MinidumpStringAtRVA(file_contents, (*system_info)->CSDVersionRva);
77 EXPECT_EQ(kCSDVersionBytes, (*csd_version)->Length); 78 EXPECT_EQ(kCSDVersionBytes, (*csd_version)->Length);
78 } 79 }
79 80
80 TEST(MinidumpSystemInfoWriter, Empty) { 81 TEST(MinidumpSystemInfoWriter, Empty) {
81 MinidumpFileWriter minidump_file_writer; 82 MinidumpFileWriter minidump_file_writer;
82 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 83 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
83 84
84 system_info_writer->SetCSDVersion(std::string()); 85 system_info_writer->SetCSDVersion(std::string());
85 86
86 minidump_file_writer.AddStream(system_info_writer.Pass()); 87 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
87 88
88 StringFile string_file; 89 StringFile string_file;
89 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 90 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
90 91
91 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 92 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
92 const MINIDUMP_STRING* csd_version = nullptr; 93 const MINIDUMP_STRING* csd_version = nullptr;
93 94
94 ASSERT_NO_FATAL_FAILURE( 95 ASSERT_NO_FATAL_FAILURE(
95 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version)); 96 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version));
96 97
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 system_info_writer->SetOS(kOS); 148 system_info_writer->SetOS(kOS);
148 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation); 149 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation);
149 system_info_writer->SetOSVersion( 150 system_info_writer->SetOSVersion(
150 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild); 151 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild);
151 system_info_writer->SetCSDVersion(kCSDVersion); 152 system_info_writer->SetCSDVersion(kCSDVersion);
152 system_info_writer->SetSuiteMask(kSuiteMask); 153 system_info_writer->SetSuiteMask(kSuiteMask);
153 system_info_writer->SetCPUX86VendorString(kCPUVendor); 154 system_info_writer->SetCPUX86VendorString(kCPUVendor);
154 system_info_writer->SetCPUX86VersionAndFeatures(kCPUVersion, kCPUFeatures); 155 system_info_writer->SetCPUX86VersionAndFeatures(kCPUVersion, kCPUFeatures);
155 system_info_writer->SetCPUX86AMDExtendedFeatures(kAMDFeatures); 156 system_info_writer->SetCPUX86AMDExtendedFeatures(kAMDFeatures);
156 157
157 minidump_file_writer.AddStream(system_info_writer.Pass()); 158 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
158 159
159 StringFile string_file; 160 StringFile string_file;
160 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 161 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
161 162
162 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 163 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
163 const MINIDUMP_STRING* csd_version = nullptr; 164 const MINIDUMP_STRING* csd_version = nullptr;
164 165
165 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream( 166 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
166 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version)); 167 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version));
167 168
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 system_info_writer->SetCPUArchitecture(kCPUArchitecture); 208 system_info_writer->SetCPUArchitecture(kCPUArchitecture);
208 system_info_writer->SetCPULevelAndRevision(kCPULevel, kCPURevision); 209 system_info_writer->SetCPULevelAndRevision(kCPULevel, kCPURevision);
209 system_info_writer->SetCPUCount(kCPUCount); 210 system_info_writer->SetCPUCount(kCPUCount);
210 system_info_writer->SetOS(kOS); 211 system_info_writer->SetOS(kOS);
211 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation); 212 system_info_writer->SetOSType(kMinidumpOSTypeWorkstation);
212 system_info_writer->SetOSVersion( 213 system_info_writer->SetOSVersion(
213 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild); 214 kOSVersionMajor, kOSVersionMinor, kOSVersionBuild);
214 system_info_writer->SetCSDVersion(kCSDVersion); 215 system_info_writer->SetCSDVersion(kCSDVersion);
215 system_info_writer->SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]); 216 system_info_writer->SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]);
216 217
217 minidump_file_writer.AddStream(system_info_writer.Pass()); 218 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
218 219
219 StringFile string_file; 220 StringFile string_file;
220 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 221 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
221 222
222 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 223 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
223 const MINIDUMP_STRING* csd_version; 224 const MINIDUMP_STRING* csd_version;
224 225
225 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream( 226 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
226 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version)); 227 string_file.string(), strlen(kCSDVersion), &system_info, &csd_version));
227 228
(...skipping 21 matching lines...) Expand all
249 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 250 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
250 251
251 const MinidumpCPUArchitecture kCPUArchitecture = kMinidumpCPUArchitectureX86; 252 const MinidumpCPUArchitecture kCPUArchitecture = kMinidumpCPUArchitectureX86;
252 const uint32_t kCPUVendor[] = {'uneG', 'Ieni', 'letn'}; 253 const uint32_t kCPUVendor[] = {'uneG', 'Ieni', 'letn'};
253 254
254 system_info_writer->SetCPUArchitecture(kCPUArchitecture); 255 system_info_writer->SetCPUArchitecture(kCPUArchitecture);
255 system_info_writer->SetCPUX86Vendor( 256 system_info_writer->SetCPUX86Vendor(
256 kCPUVendor[0], kCPUVendor[1], kCPUVendor[2]); 257 kCPUVendor[0], kCPUVendor[1], kCPUVendor[2]);
257 system_info_writer->SetCSDVersion(std::string()); 258 system_info_writer->SetCSDVersion(std::string());
258 259
259 minidump_file_writer.AddStream(system_info_writer.Pass()); 260 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
260 261
261 StringFile string_file; 262 StringFile string_file;
262 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 263 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
263 264
264 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 265 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
265 const MINIDUMP_STRING* csd_version; 266 const MINIDUMP_STRING* csd_version;
266 267
267 ASSERT_NO_FATAL_FAILURE( 268 ASSERT_NO_FATAL_FAILURE(
268 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version)); 269 GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version));
269 270
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 system_snapshot.SetOSServer(true); 330 system_snapshot.SetOSServer(true);
330 system_snapshot.SetOSVersion(expect_system_info.MajorVersion, 331 system_snapshot.SetOSVersion(expect_system_info.MajorVersion,
331 expect_system_info.MinorVersion, 332 expect_system_info.MinorVersion,
332 expect_system_info.BuildNumber, 333 expect_system_info.BuildNumber,
333 kOSVersionBuild); 334 kOSVersionBuild);
334 335
335 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 336 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
336 system_info_writer->InitializeFromSnapshot(&system_snapshot); 337 system_info_writer->InitializeFromSnapshot(&system_snapshot);
337 338
338 MinidumpFileWriter minidump_file_writer; 339 MinidumpFileWriter minidump_file_writer;
339 minidump_file_writer.AddStream(system_info_writer.Pass()); 340 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
340 341
341 StringFile string_file; 342 StringFile string_file;
342 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 343 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
343 344
344 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 345 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
345 const MINIDUMP_STRING* csd_version = nullptr; 346 const MINIDUMP_STRING* csd_version = nullptr;
346 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(), 347 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(),
347 strlen(kOSVersionBuild), 348 strlen(kOSVersionBuild),
348 &system_info, 349 &system_info,
349 &csd_version)); 350 &csd_version));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 system_snapshot.SetOSVersion(expect_system_info.MajorVersion, 425 system_snapshot.SetOSVersion(expect_system_info.MajorVersion,
425 expect_system_info.MinorVersion, 426 expect_system_info.MinorVersion,
426 expect_system_info.BuildNumber, 427 expect_system_info.BuildNumber,
427 kOSVersionBuild); 428 kOSVersionBuild);
428 system_snapshot.SetNXEnabled(true); 429 system_snapshot.SetNXEnabled(true);
429 430
430 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 431 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
431 system_info_writer->InitializeFromSnapshot(&system_snapshot); 432 system_info_writer->InitializeFromSnapshot(&system_snapshot);
432 433
433 MinidumpFileWriter minidump_file_writer; 434 MinidumpFileWriter minidump_file_writer;
434 minidump_file_writer.AddStream(system_info_writer.Pass()); 435 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
435 436
436 StringFile string_file; 437 StringFile string_file;
437 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 438 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
438 439
439 const MINIDUMP_SYSTEM_INFO* system_info = nullptr; 440 const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
440 const MINIDUMP_STRING* csd_version = nullptr; 441 const MINIDUMP_STRING* csd_version = nullptr;
441 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(), 442 ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(),
442 strlen(kOSVersionBuild), 443 strlen(kOSVersionBuild),
443 &system_info, 444 &system_info,
444 &csd_version)); 445 &csd_version));
(...skipping 17 matching lines...) Expand all
462 system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1]); 463 system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1]);
463 464
464 for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) { 465 for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) {
465 EXPECT_EQ(kOSVersionBuild[index], csd_version->Buffer[index]) << index; 466 EXPECT_EQ(kOSVersionBuild[index], csd_version->Buffer[index]) << index;
466 } 467 }
467 } 468 }
468 469
469 TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) { 470 TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) {
470 MinidumpFileWriter minidump_file_writer; 471 MinidumpFileWriter minidump_file_writer;
471 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter()); 472 auto system_info_writer = make_scoped_ptr(new MinidumpSystemInfoWriter());
472 minidump_file_writer.AddStream(system_info_writer.Pass()); 473 minidump_file_writer.AddStream(crashpad::move(system_info_writer));
473 474
474 StringFile string_file; 475 StringFile string_file;
475 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), 476 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),
476 "csd_version_"); 477 "csd_version_");
477 } 478 }
478 479
479 } // namespace 480 } // namespace
480 } // namespace test 481 } // namespace test
481 } // 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