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