2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-08-07 14:58:26 -04:00
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#include "minidump/minidump_system_info_writer.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2014-11-05 18:10:38 -05:00
|
|
|
|
#include <algorithm>
|
2014-08-07 14:58:26 -04:00
|
|
|
|
#include <string>
|
2015-12-09 17:36:32 -05:00
|
|
|
|
#include <utility>
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include "minidump/minidump_file_writer.h"
|
2014-10-20 12:11:14 -04:00
|
|
|
|
#include "minidump/test/minidump_file_writer_test_util.h"
|
2014-10-21 14:15:07 -04:00
|
|
|
|
#include "minidump/test/minidump_string_writer_test_util.h"
|
2014-10-22 18:35:18 -04:00
|
|
|
|
#include "minidump/test/minidump_writable_test_util.h"
|
2014-11-05 18:10:38 -05:00
|
|
|
|
#include "snapshot/test/test_system_snapshot.h"
|
mac: Tests that crash intentionally shouldn’t go to ReportCrash
Crashpad has many tests that crash intentionally. Some of these are
gtest death tests, and others arrange for intentional crashes to test
Crashpad’s own crash-catching logic. On macOS, all of the gtest death
tests and some of the other intentional crashes were being logged by
ReportCrash, the system’s crash reporter. Since these reports
corresponded to intentional crashes, they were never useful, and served
only to clutter ~/Library/Logs/DiagnosticReports.
Since Crashpad is adept at handling exceptions on its own, this
introduces the “exception swallowing server”,
crashpad_exception_swallower, which is a Mach exception server that
implements a no-op exception handler routine for all exceptions
received. The exception swallowing server is established as the task
handler for EXC_CRASH and EXC_CORPSE_NOTIFY exceptions during gtest
death tests invoked by {ASSERT,EXPECT}_DEATH_{CHECK,CRASH}, and for all
child processes invoked by the Multiprocess test infrastructure. The
exception swallowing server is not in effect at other times, so
unexpected crashes in test code can still be handled by ReportCrash or
another crash reporter.
With this change in place, no new reports are generated in the
user-level ~/Library/Logs/DiagnosticReports or the system’s
/Library/Logs/DiagnosticReports during a run of Crashpad’s full test
suite on macOS.
Bug: crashpad:33
Change-Id: I13891853a7e25accc30da21fa7ea8bd7d1f3bd2f
Reviewed-on: https://chromium-review.googlesource.com/777859
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-20 13:32:26 -05:00
|
|
|
|
#include "test/gtest_death.h"
|
2015-02-18 14:15:38 -05:00
|
|
|
|
#include "util/file/string_file.h"
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-07 17:28:50 -04:00
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace test {
|
2014-08-07 14:58:26 -04:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
void GetSystemInfoStream(const std::string& file_contents,
|
|
|
|
|
size_t csd_version_length,
|
|
|
|
|
const MINIDUMP_SYSTEM_INFO** system_info,
|
|
|
|
|
const MINIDUMP_STRING** csd_version) {
|
|
|
|
|
// The expected number of bytes for the CSD version’s MINIDUMP_STRING::Buffer.
|
2022-01-14 17:51:32 -05:00
|
|
|
|
[[maybe_unused]] MINIDUMP_STRING* tmp;
|
2018-01-10 14:16:31 -08:00
|
|
|
|
const size_t kCSDVersionBytes = csd_version_length * sizeof(tmp->Buffer[0]);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
const size_t kCSDVersionBytesWithNUL =
|
2018-01-10 14:16:31 -08:00
|
|
|
|
kCSDVersionBytes + sizeof(tmp->Buffer[0]);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kSystemInfoStreamOffset =
|
2014-08-07 14:58:26 -04:00
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kCSDVersionOffset =
|
2014-08-07 14:58:26 -04:00
|
|
|
|
kSystemInfoStreamOffset + sizeof(MINIDUMP_SYSTEM_INFO);
|
|
|
|
|
const size_t kFileSize =
|
|
|
|
|
kCSDVersionOffset + sizeof(MINIDUMP_STRING) + kCSDVersionBytesWithNUL;
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
ASSERT_EQ(file_contents.size(), kFileSize);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
const MINIDUMP_HEADER* header =
|
2014-10-21 14:15:07 -04:00
|
|
|
|
MinidumpHeaderAtStart(file_contents, &directory);
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
2014-10-21 14:15:07 -04:00
|
|
|
|
ASSERT_TRUE(directory);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
ASSERT_EQ(directory[0].StreamType, kMinidumpStreamTypeSystemInfo);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kSystemInfoStreamOffset);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-22 18:35:18 -04:00
|
|
|
|
*system_info = MinidumpWritableAtLocationDescriptor<MINIDUMP_SYSTEM_INFO>(
|
|
|
|
|
file_contents, directory[0].Location);
|
|
|
|
|
ASSERT_TRUE(system_info);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ((*system_info)->CSDVersionRva, kCSDVersionOffset);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
|
*csd_version =
|
|
|
|
|
MinidumpStringAtRVA(file_contents, (*system_info)->CSDVersionRva);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ((*csd_version)->Length, kCSDVersionBytes);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpSystemInfoWriter, Empty) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCSDVersion(std::string());
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-05 09:39:54 -08:00
|
|
|
|
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
|
|
|
|
|
const MINIDUMP_STRING* csd_version = nullptr;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(system_info->ProcessorArchitecture,
|
|
|
|
|
kMinidumpCPUArchitectureUnknown);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorLevel, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorRevision, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->NumberOfProcessors, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->ProductType, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->MajorVersion, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->MinorVersion, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->BuildNumber, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->PlatformId, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->SuiteMask, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[0], 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[1], 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[2], 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VersionInformation, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.FeatureInformation, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.AMDExtendedCpuFeatures, 0u);
|
2020-12-09 22:21:38 +00:00
|
|
|
|
|
|
|
|
|
CPU_INFORMATION other_cpu_info;
|
|
|
|
|
memcpy(&other_cpu_info, &system_info->Cpu, sizeof(other_cpu_info));
|
|
|
|
|
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[0], 0u);
|
|
|
|
|
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[1], 0u);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
|
|
|
|
|
EXPECT_EQ(csd_version->Buffer[0], '\0');
|
2014-08-07 14:58:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpSystemInfoWriter, X86_Win) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr MinidumpCPUArchitecture kCPUArchitecture =
|
|
|
|
|
kMinidumpCPUArchitectureX86;
|
|
|
|
|
constexpr uint16_t kCPULevel = 0x0010;
|
|
|
|
|
constexpr uint16_t kCPURevision = 0x0602;
|
|
|
|
|
constexpr uint8_t kCPUCount = 1;
|
|
|
|
|
constexpr MinidumpOS kOS = kMinidumpOSWin32NT;
|
|
|
|
|
constexpr MinidumpOSType kOSType = kMinidumpOSTypeWorkstation;
|
|
|
|
|
constexpr uint32_t kOSVersionMajor = 6;
|
|
|
|
|
constexpr uint32_t kOSVersionMinor = 1;
|
|
|
|
|
constexpr uint32_t kOSVersionBuild = 7601;
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kCSDVersion[] = "Service Pack 1";
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint16_t kSuiteMask = VER_SUITE_SINGLEUSERTS;
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kCPUVendor[] = "AuthenticAMD";
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint32_t kCPUVersion = 0x00100f62;
|
|
|
|
|
constexpr uint32_t kCPUFeatures = 0x078bfbff;
|
|
|
|
|
constexpr uint32_t kAMDFeatures = 0xefd3fbff;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
|
|
|
|
uint32_t cpu_vendor_registers[3];
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
ASSERT_EQ(strlen(kCPUVendor), sizeof(cpu_vendor_registers));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
memcpy(cpu_vendor_registers, kCPUVendor, sizeof(cpu_vendor_registers));
|
|
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCPUArchitecture(kCPUArchitecture);
|
|
|
|
|
system_info_writer->SetCPULevelAndRevision(kCPULevel, kCPURevision);
|
|
|
|
|
system_info_writer->SetCPUCount(kCPUCount);
|
|
|
|
|
system_info_writer->SetOS(kOS);
|
|
|
|
|
system_info_writer->SetOSType(kMinidumpOSTypeWorkstation);
|
|
|
|
|
system_info_writer->SetOSVersion(
|
2014-08-07 14:58:26 -04:00
|
|
|
|
kOSVersionMajor, kOSVersionMinor, kOSVersionBuild);
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCSDVersion(kCSDVersion);
|
|
|
|
|
system_info_writer->SetSuiteMask(kSuiteMask);
|
|
|
|
|
system_info_writer->SetCPUX86VendorString(kCPUVendor);
|
|
|
|
|
system_info_writer->SetCPUX86VersionAndFeatures(kCPUVersion, kCPUFeatures);
|
|
|
|
|
system_info_writer->SetCPUX86AMDExtendedFeatures(kAMDFeatures);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-05 09:39:54 -08:00
|
|
|
|
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
|
|
|
|
|
const MINIDUMP_STRING* csd_version = nullptr;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), strlen(kCSDVersion), &system_info, &csd_version));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(system_info->ProcessorArchitecture, kCPUArchitecture);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorLevel, kCPULevel);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorRevision, kCPURevision);
|
|
|
|
|
EXPECT_EQ(system_info->NumberOfProcessors, kCPUCount);
|
|
|
|
|
EXPECT_EQ(system_info->ProductType, kOSType);
|
|
|
|
|
EXPECT_EQ(system_info->MajorVersion, kOSVersionMajor);
|
|
|
|
|
EXPECT_EQ(system_info->MinorVersion, kOSVersionMinor);
|
|
|
|
|
EXPECT_EQ(system_info->BuildNumber, kOSVersionBuild);
|
|
|
|
|
EXPECT_EQ(system_info->PlatformId, kOS);
|
|
|
|
|
EXPECT_EQ(system_info->SuiteMask, kSuiteMask);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[0], cpu_vendor_registers[0]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[1], cpu_vendor_registers[1]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[2], cpu_vendor_registers[2]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VersionInformation, kCPUVersion);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.FeatureInformation, kCPUFeatures);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.AMDExtendedCpuFeatures, kAMDFeatures);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < strlen(kCSDVersion); ++index) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(csd_version->Buffer[index], kCSDVersion[index]) << index;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-05 18:10:38 -05:00
|
|
|
|
TEST(MinidumpSystemInfoWriter, AMD64_Mac) {
|
2014-08-07 14:58:26 -04:00
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr MinidumpCPUArchitecture kCPUArchitecture =
|
2014-08-07 14:58:26 -04:00
|
|
|
|
kMinidumpCPUArchitectureAMD64;
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint16_t kCPULevel = 0x0006;
|
|
|
|
|
constexpr uint16_t kCPURevision = 0x3a09;
|
|
|
|
|
constexpr uint8_t kCPUCount = 8;
|
|
|
|
|
constexpr MinidumpOS kOS = kMinidumpOSMacOSX;
|
|
|
|
|
constexpr MinidumpOSType kOSType = kMinidumpOSTypeWorkstation;
|
|
|
|
|
constexpr uint32_t kOSVersionMajor = 10;
|
|
|
|
|
constexpr uint32_t kOSVersionMinor = 9;
|
|
|
|
|
constexpr uint32_t kOSVersionBuild = 4;
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kCSDVersion[] = "13E28";
|
|
|
|
|
static constexpr uint64_t kCPUFeatures[2] = {0x10427f4c, 0x00000000};
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCPUArchitecture(kCPUArchitecture);
|
|
|
|
|
system_info_writer->SetCPULevelAndRevision(kCPULevel, kCPURevision);
|
|
|
|
|
system_info_writer->SetCPUCount(kCPUCount);
|
|
|
|
|
system_info_writer->SetOS(kOS);
|
|
|
|
|
system_info_writer->SetOSType(kMinidumpOSTypeWorkstation);
|
|
|
|
|
system_info_writer->SetOSVersion(
|
2014-08-07 14:58:26 -04:00
|
|
|
|
kOSVersionMajor, kOSVersionMinor, kOSVersionBuild);
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCSDVersion(kCSDVersion);
|
|
|
|
|
system_info_writer->SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-05 09:39:54 -08:00
|
|
|
|
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
const MINIDUMP_STRING* csd_version;
|
|
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), strlen(kCSDVersion), &system_info, &csd_version));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(system_info->ProcessorArchitecture, kCPUArchitecture);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorLevel, kCPULevel);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorRevision, kCPURevision);
|
|
|
|
|
EXPECT_EQ(system_info->NumberOfProcessors, kCPUCount);
|
|
|
|
|
EXPECT_EQ(system_info->ProductType, kOSType);
|
|
|
|
|
EXPECT_EQ(system_info->MajorVersion, kOSVersionMajor);
|
|
|
|
|
EXPECT_EQ(system_info->MinorVersion, kOSVersionMinor);
|
|
|
|
|
EXPECT_EQ(system_info->BuildNumber, kOSVersionBuild);
|
|
|
|
|
EXPECT_EQ(system_info->PlatformId, kOS);
|
|
|
|
|
EXPECT_EQ(system_info->SuiteMask, 0u);
|
2020-12-09 22:21:38 +00:00
|
|
|
|
|
|
|
|
|
CPU_INFORMATION other_cpu_info;
|
|
|
|
|
memcpy(&other_cpu_info, &system_info->Cpu, sizeof(other_cpu_info));
|
|
|
|
|
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[0], kCPUFeatures[0]);
|
|
|
|
|
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[1], kCPUFeatures[1]);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpSystemInfoWriter, X86_CPUVendorFromRegisters) {
|
|
|
|
|
// MinidumpSystemInfoWriter.X86_Win already tested SetCPUX86VendorString().
|
|
|
|
|
// This test exercises SetCPUX86Vendor() to set the vendor from register
|
|
|
|
|
// values.
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr MinidumpCPUArchitecture kCPUArchitecture =
|
|
|
|
|
kMinidumpCPUArchitectureX86;
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr uint32_t kCPUVendor[] = {'uneG', 'Ieni', 'letn'};
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCPUArchitecture(kCPUArchitecture);
|
|
|
|
|
system_info_writer->SetCPUX86Vendor(
|
2014-08-07 14:58:26 -04:00
|
|
|
|
kCPUVendor[0], kCPUVendor[1], kCPUVendor[2]);
|
2014-10-27 15:01:39 -04:00
|
|
|
|
system_info_writer->SetCSDVersion(std::string());
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-05 09:39:54 -08:00
|
|
|
|
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
|
2014-08-07 14:58:26 -04:00
|
|
|
|
const MINIDUMP_STRING* csd_version;
|
|
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
GetSystemInfoStream(string_file.string(), 0, &system_info, &csd_version));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(system_info->ProcessorArchitecture, kCPUArchitecture);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorLevel, 0u);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[0], kCPUVendor[0]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[1], kCPUVendor[1]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[2], kCPUVendor[2]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VersionInformation, 0u);
|
2014-08-07 14:58:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-05 18:10:38 -05:00
|
|
|
|
TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
|
|
|
|
|
MINIDUMP_SYSTEM_INFO expect_system_info = {};
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint16_t kCPUFamily = 6;
|
|
|
|
|
constexpr uint8_t kCPUModel = 70;
|
|
|
|
|
constexpr uint8_t kCPUStepping = 1;
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
|
|
|
|
const uint8_t kCPUBasicFamily =
|
2015-02-05 09:39:54 -08:00
|
|
|
|
static_cast<uint8_t>(std::min(kCPUFamily, static_cast<uint16_t>(15)));
|
2014-11-05 18:10:38 -05:00
|
|
|
|
const uint8_t kCPUExtendedFamily = kCPUFamily - kCPUBasicFamily;
|
|
|
|
|
|
|
|
|
|
// These checks ensure that even if the constants above change, they represent
|
|
|
|
|
// something that can legitimately be encoded in the form used by cpuid 1 eax.
|
|
|
|
|
EXPECT_LE(kCPUFamily, 270);
|
|
|
|
|
EXPECT_LE(kCPUStepping, 15);
|
|
|
|
|
EXPECT_TRUE(kCPUBasicFamily == 6 || kCPUBasicFamily == 15 || kCPUModel <= 15);
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint8_t kCPUBasicModel = kCPUModel & 0xf;
|
|
|
|
|
constexpr uint8_t kCPUExtendedModel = kCPUModel >> 4;
|
2014-11-05 18:10:38 -05:00
|
|
|
|
const uint32_t kCPUSignature =
|
|
|
|
|
(kCPUExtendedFamily << 20) | (kCPUExtendedModel << 16) |
|
|
|
|
|
(kCPUBasicFamily << 8) | (kCPUBasicModel << 4) | kCPUStepping;
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint64_t kCPUX86Features = 0x7ffafbffbfebfbff;
|
2014-11-05 18:10:38 -05:00
|
|
|
|
expect_system_info.ProcessorArchitecture = kMinidumpCPUArchitectureX86;
|
|
|
|
|
expect_system_info.ProcessorLevel = kCPUFamily;
|
|
|
|
|
expect_system_info.ProcessorRevision = (kCPUModel << 8) | kCPUStepping;
|
|
|
|
|
expect_system_info.NumberOfProcessors = 8;
|
|
|
|
|
expect_system_info.ProductType = kMinidumpOSTypeServer;
|
|
|
|
|
expect_system_info.MajorVersion = 10;
|
|
|
|
|
expect_system_info.MinorVersion = 9;
|
|
|
|
|
expect_system_info.BuildNumber = 5;
|
|
|
|
|
expect_system_info.PlatformId = kMinidumpOSMacOSX;
|
|
|
|
|
expect_system_info.SuiteMask = 0;
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VendorId[0] = 'uneG';
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VendorId[1] = 'Ieni';
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VendorId[2] = 'letn';
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VersionInformation = kCPUSignature;
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.FeatureInformation =
|
|
|
|
|
kCPUX86Features & 0xffffffff;
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kCPUVendor[] = "GenuineIntel";
|
|
|
|
|
static constexpr char kOSVersionBuild[] = "13F34";
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
|
|
|
|
TestSystemSnapshot system_snapshot;
|
|
|
|
|
system_snapshot.SetCPUArchitecture(kCPUArchitectureX86);
|
|
|
|
|
system_snapshot.SetCPURevision(
|
|
|
|
|
(kCPUFamily << 16) | (kCPUModel << 8) | kCPUStepping);
|
|
|
|
|
system_snapshot.SetCPUCount(expect_system_info.NumberOfProcessors);
|
|
|
|
|
system_snapshot.SetCPUVendor(kCPUVendor);
|
|
|
|
|
system_snapshot.SetCPUX86Signature(kCPUSignature);
|
|
|
|
|
system_snapshot.SetCPUX86Features(kCPUX86Features);
|
|
|
|
|
system_snapshot.SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX);
|
|
|
|
|
system_snapshot.SetOSServer(true);
|
|
|
|
|
system_snapshot.SetOSVersion(expect_system_info.MajorVersion,
|
|
|
|
|
expect_system_info.MinorVersion,
|
|
|
|
|
expect_system_info.BuildNumber,
|
|
|
|
|
kOSVersionBuild);
|
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2014-11-05 18:10:38 -05:00
|
|
|
|
system_info_writer->InitializeFromSnapshot(&system_snapshot);
|
|
|
|
|
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
2015-02-05 09:39:54 -08:00
|
|
|
|
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
|
|
|
|
|
const MINIDUMP_STRING* csd_version = nullptr;
|
2015-02-18 14:15:38 -05:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(),
|
2014-11-05 18:10:38 -05:00
|
|
|
|
strlen(kOSVersionBuild),
|
|
|
|
|
&system_info,
|
|
|
|
|
&csd_version));
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(system_info->ProcessorArchitecture,
|
|
|
|
|
expect_system_info.ProcessorArchitecture);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorLevel, expect_system_info.ProcessorLevel);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorRevision,
|
|
|
|
|
expect_system_info.ProcessorRevision);
|
|
|
|
|
EXPECT_EQ(system_info->NumberOfProcessors,
|
|
|
|
|
expect_system_info.NumberOfProcessors);
|
|
|
|
|
EXPECT_EQ(system_info->ProductType, expect_system_info.ProductType);
|
|
|
|
|
EXPECT_EQ(system_info->MajorVersion, expect_system_info.MajorVersion);
|
|
|
|
|
EXPECT_EQ(system_info->MinorVersion, expect_system_info.MinorVersion);
|
|
|
|
|
EXPECT_EQ(system_info->BuildNumber, expect_system_info.BuildNumber);
|
|
|
|
|
EXPECT_EQ(system_info->PlatformId, expect_system_info.PlatformId);
|
|
|
|
|
EXPECT_EQ(system_info->SuiteMask, expect_system_info.SuiteMask);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[0],
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VendorId[0]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[1],
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VendorId[1]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VendorId[2],
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VendorId[2]);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VersionInformation,
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.VersionInformation);
|
|
|
|
|
EXPECT_EQ(system_info->Cpu.X86CpuInfo.FeatureInformation,
|
|
|
|
|
expect_system_info.Cpu.X86CpuInfo.FeatureInformation);
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(csd_version->Buffer[index], kOSVersionBuild[index]) << index;
|
2014-11-05 18:10:38 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_AMD64) {
|
|
|
|
|
MINIDUMP_SYSTEM_INFO expect_system_info = {};
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint8_t kCPUFamily = 6;
|
|
|
|
|
constexpr uint8_t kCPUModel = 70;
|
|
|
|
|
constexpr uint8_t kCPUStepping = 1;
|
2014-11-05 18:10:38 -05:00
|
|
|
|
expect_system_info.ProcessorArchitecture = kMinidumpCPUArchitectureAMD64;
|
|
|
|
|
expect_system_info.ProcessorLevel = kCPUFamily;
|
|
|
|
|
expect_system_info.ProcessorRevision = (kCPUModel << 8) | kCPUStepping;
|
|
|
|
|
expect_system_info.NumberOfProcessors = 8;
|
|
|
|
|
expect_system_info.ProductType = kMinidumpOSTypeServer;
|
|
|
|
|
expect_system_info.MajorVersion = 10;
|
|
|
|
|
expect_system_info.MinorVersion = 9;
|
|
|
|
|
expect_system_info.BuildNumber = 5;
|
|
|
|
|
expect_system_info.PlatformId = kMinidumpOSMacOSX;
|
|
|
|
|
expect_system_info.SuiteMask = 0;
|
|
|
|
|
expect_system_info.Cpu.OtherCpuInfo.ProcessorFeatures[0] =
|
|
|
|
|
(1 << PF_COMPARE_EXCHANGE_DOUBLE) |
|
|
|
|
|
(1 << PF_MMX_INSTRUCTIONS_AVAILABLE) |
|
|
|
|
|
(1 << PF_XMMI_INSTRUCTIONS_AVAILABLE) |
|
|
|
|
|
(1 << PF_RDTSC_INSTRUCTION_AVAILABLE) |
|
|
|
|
|
(1 << PF_PAE_ENABLED) |
|
|
|
|
|
(1 << PF_XMMI64_INSTRUCTIONS_AVAILABLE) |
|
|
|
|
|
(1 << PF_SSE_DAZ_MODE_AVAILABLE) |
|
|
|
|
|
(1 << PF_NX_ENABLED) |
|
|
|
|
|
(1 << PF_SSE3_INSTRUCTIONS_AVAILABLE) |
|
|
|
|
|
(1 << PF_COMPARE_EXCHANGE128) |
|
|
|
|
|
(1 << PF_XSAVE_ENABLED) |
|
|
|
|
|
(1 << PF_RDWRFSGSBASE_AVAILABLE) |
|
2016-11-09 15:55:55 -05:00
|
|
|
|
(1 << PF_RDRAND_INSTRUCTION_AVAILABLE) |
|
|
|
|
|
(UINT64_C(1) << PF_RDTSCP_INSTRUCTION_AVAILABLE);
|
2014-11-05 18:10:38 -05:00
|
|
|
|
expect_system_info.Cpu.OtherCpuInfo.ProcessorFeatures[1] = 0;
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kOSVersionBuild[] = "13F34";
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
|
|
|
|
TestSystemSnapshot system_snapshot;
|
|
|
|
|
system_snapshot.SetCPUArchitecture(kCPUArchitectureX86_64);
|
|
|
|
|
system_snapshot.SetCPURevision(
|
|
|
|
|
(kCPUFamily << 16) | (kCPUModel << 8) | kCPUStepping);
|
|
|
|
|
system_snapshot.SetCPUCount(expect_system_info.NumberOfProcessors);
|
|
|
|
|
system_snapshot.SetCPUX86Features(0x7ffafbffbfebfbff);
|
|
|
|
|
system_snapshot.SetCPUX86ExtendedFeatures(0x000000212c100900);
|
|
|
|
|
system_snapshot.SetCPUX86Leaf7Features(0x00002fbb);
|
|
|
|
|
system_snapshot.SetCPUX86SupportsDAZ(true);
|
|
|
|
|
system_snapshot.SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX);
|
|
|
|
|
system_snapshot.SetOSServer(true);
|
|
|
|
|
system_snapshot.SetOSVersion(expect_system_info.MajorVersion,
|
|
|
|
|
expect_system_info.MinorVersion,
|
|
|
|
|
expect_system_info.BuildNumber,
|
|
|
|
|
kOSVersionBuild);
|
|
|
|
|
system_snapshot.SetNXEnabled(true);
|
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2014-11-05 18:10:38 -05:00
|
|
|
|
system_info_writer->InitializeFromSnapshot(&system_snapshot);
|
|
|
|
|
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
2015-02-05 09:39:54 -08:00
|
|
|
|
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
|
|
|
|
|
const MINIDUMP_STRING* csd_version = nullptr;
|
2015-02-18 14:15:38 -05:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(string_file.string(),
|
2014-11-05 18:10:38 -05:00
|
|
|
|
strlen(kOSVersionBuild),
|
|
|
|
|
&system_info,
|
|
|
|
|
&csd_version));
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(system_info->ProcessorArchitecture,
|
|
|
|
|
expect_system_info.ProcessorArchitecture);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorLevel, expect_system_info.ProcessorLevel);
|
|
|
|
|
EXPECT_EQ(system_info->ProcessorRevision,
|
|
|
|
|
expect_system_info.ProcessorRevision);
|
|
|
|
|
EXPECT_EQ(system_info->NumberOfProcessors,
|
|
|
|
|
expect_system_info.NumberOfProcessors);
|
|
|
|
|
EXPECT_EQ(system_info->ProductType, expect_system_info.ProductType);
|
|
|
|
|
EXPECT_EQ(system_info->MajorVersion, expect_system_info.MajorVersion);
|
|
|
|
|
EXPECT_EQ(system_info->MinorVersion, expect_system_info.MinorVersion);
|
|
|
|
|
EXPECT_EQ(system_info->BuildNumber, expect_system_info.BuildNumber);
|
|
|
|
|
EXPECT_EQ(system_info->PlatformId, expect_system_info.PlatformId);
|
|
|
|
|
EXPECT_EQ(system_info->SuiteMask, expect_system_info.SuiteMask);
|
2020-12-09 22:21:38 +00:00
|
|
|
|
|
|
|
|
|
CPU_INFORMATION other_cpu_info;
|
|
|
|
|
memcpy(&other_cpu_info, &system_info->Cpu, sizeof(other_cpu_info));
|
|
|
|
|
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[0],
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
expect_system_info.Cpu.OtherCpuInfo.ProcessorFeatures[0]);
|
2020-12-09 22:21:38 +00:00
|
|
|
|
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[1],
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
expect_system_info.Cpu.OtherCpuInfo.ProcessorFeatures[1]);
|
2014-11-05 18:10:38 -05:00
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(csd_version->Buffer[index], kOSVersionBuild[index]) << index;
|
2014-11-05 18:10:38 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 14:58:26 -04:00
|
|
|
|
TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_info_writer = std::make_unique<MinidumpSystemInfoWriter>();
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
|
2014-08-07 14:58:26 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
2015-03-09 18:02:14 -04:00
|
|
|
|
ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),
|
|
|
|
|
"csd_version_");
|
2014-08-07 14:58:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
2014-10-07 17:28:50 -04:00
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace crashpad
|