Index: snapshot/win/system_snapshot_win_test.cc |
diff --git a/snapshot/mac/system_snapshot_mac_test.cc b/snapshot/win/system_snapshot_win_test.cc |
similarity index 60% |
copy from snapshot/mac/system_snapshot_mac_test.cc |
copy to snapshot/win/system_snapshot_win_test.cc |
index b69ccac20d2001f34a2226d70b917d0ec51ccf76..7552ca5642b677f53ee440b38520ec272e358ceb 100644 |
--- a/snapshot/mac/system_snapshot_mac_test.cc |
+++ b/snapshot/win/system_snapshot_win_test.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2014 The Crashpad Authors. All rights reserved. |
+// Copyright 2015 The Crashpad Authors. All rights reserved. |
// |
// Licensed under the Apache License, Version 2.0 (the "License"); |
// you may not use this file except in compliance with the License. |
@@ -12,7 +12,7 @@ |
// See the License for the specific language governing permissions and |
// limitations under the License. |
-#include "snapshot/mac/system_snapshot_mac.h" |
+#include "snapshot/win/system_snapshot_win.h" |
#include <sys/time.h> |
#include <time.h> |
@@ -21,113 +21,93 @@ |
#include "build/build_config.h" |
#include "gtest/gtest.h" |
-#include "snapshot/mac/process_reader.h" |
-#include "util/mac/mac_util.h" |
-#include "util/test/errors.h" |
+#include "snapshot/win/process_reader_win.h" |
namespace crashpad { |
namespace test { |
namespace { |
-// SystemSnapshotMac objects would be cumbersome to construct in each test that |
-// requires one, because of the repetitive and mechanical work necessary to set |
-// up a ProcessReader and timeval, along with the checks to verify that these |
-// operations succeed. This test fixture class handles the initialization work |
-// so that individual tests don’t have to. |
-class SystemSnapshotMacTest : public testing::Test { |
+class SystemSnapshotWinTest : public testing::Test { |
public: |
- SystemSnapshotMacTest() |
+ SystemSnapshotWinTest() |
: Test(), |
process_reader_(), |
- snapshot_time_(), |
system_snapshot_() { |
} |
- const internal::SystemSnapshotMac& system_snapshot() const { |
+ const internal::SystemSnapshotWin& system_snapshot() const { |
return system_snapshot_; |
} |
// testing::Test: |
void SetUp() override { |
- ASSERT_TRUE(process_reader_.Initialize(mach_task_self())); |
- ASSERT_EQ(0, gettimeofday(&snapshot_time_, nullptr)) |
- << ErrnoMessage("gettimeofday"); |
- system_snapshot_.Initialize(&process_reader_, &snapshot_time_); |
+ ASSERT_TRUE(process_reader_.Initialize(GetCurrentProcess())); |
+ system_snapshot_.Initialize(&process_reader_); |
} |
private: |
- ProcessReader process_reader_; |
- timeval snapshot_time_; |
- internal::SystemSnapshotMac system_snapshot_; |
+ ProcessReaderWin process_reader_; |
+ internal::SystemSnapshotWin system_snapshot_; |
- DISALLOW_COPY_AND_ASSIGN(SystemSnapshotMacTest); |
+ DISALLOW_COPY_AND_ASSIGN(SystemSnapshotWinTest); |
}; |
-TEST_F(SystemSnapshotMacTest, GetCPUArchitecture) { |
+TEST_F(SystemSnapshotWinTest, GetCPUArchitecture) { |
CPUArchitecture cpu_architecture = system_snapshot().GetCPUArchitecture(); |
#if defined(ARCH_CPU_X86) |
EXPECT_EQ(kCPUArchitectureX86, cpu_architecture); |
#elif defined(ARCH_CPU_X86_64) |
EXPECT_EQ(kCPUArchitectureX86_64, cpu_architecture); |
-#else |
-#error port to your architecture |
#endif |
} |
-TEST_F(SystemSnapshotMacTest, CPUCount) { |
+TEST_F(SystemSnapshotWinTest, CPUCount) { |
EXPECT_GE(system_snapshot().CPUCount(), 1); |
} |
-TEST_F(SystemSnapshotMacTest, CPUVendor) { |
+TEST_F(SystemSnapshotWinTest, CPUVendor) { |
std::string cpu_vendor = system_snapshot().CPUVendor(); |
-#if defined(ARCH_CPU_X86_FAMILY) |
- // Apple has only shipped Intel x86-family CPUs, but here’s a small nod to the |
- // “Hackintosh” crowd. |
- if (cpu_vendor != "GenuineIntel" && cpu_vendor != "AuthenticAMD") { |
- FAIL() << "cpu_vendor " << cpu_vendor; |
- } |
-#else |
-#error port to your architecture |
-#endif |
+ // There are a variety of other values, but we don't expect to run our tests |
+ // on them. |
+ EXPECT_TRUE(cpu_vendor == "GenuineIntel" || cpu_vendor == "AuthenticAMD"); |
} |
-#if defined(ARCH_CPU_X86_FAMILY) |
- |
-TEST_F(SystemSnapshotMacTest, CPUX86SupportsDAZ) { |
- // All x86-family CPUs that Apple is known to have shipped should support DAZ. |
+TEST_F(SystemSnapshotWinTest, CPUX86SupportsDAZ) { |
+ // Most SSE2+ machines support Denormals-Are-Zero. This may fail if run on |
+ // older machines. |
EXPECT_TRUE(system_snapshot().CPUX86SupportsDAZ()); |
} |
-#endif |
- |
-TEST_F(SystemSnapshotMacTest, GetOperatingSystem) { |
- EXPECT_EQ(SystemSnapshot::kOperatingSystemMacOSX, |
+TEST_F(SystemSnapshotWinTest, GetOperatingSystem) { |
+ EXPECT_EQ(SystemSnapshot::kOperatingSystemWindows, |
system_snapshot().GetOperatingSystem()); |
} |
-TEST_F(SystemSnapshotMacTest, OSVersion) { |
+TEST_F(SystemSnapshotWinTest, OSVersion) { |
int major; |
int minor; |
int bugfix; |
std::string build; |
system_snapshot().OSVersion(&major, &minor, &bugfix, &build); |
- EXPECT_EQ(10, major); |
- EXPECT_EQ(MacOSXMinorVersion(), minor); |
- EXPECT_FALSE(build.empty()); |
+ EXPECT_GE(major, 5); |
+ if (major == 5) |
+ EXPECT_GE(minor, 1); |
+ if (major == 6) |
+ EXPECT_TRUE(minor >= 0 && minor <= 3); |
} |
-TEST_F(SystemSnapshotMacTest, OSVersionFull) { |
+TEST_F(SystemSnapshotWinTest, OSVersionFull) { |
EXPECT_FALSE(system_snapshot().OSVersionFull().empty()); |
} |
-TEST_F(SystemSnapshotMacTest, MachineDescription) { |
- EXPECT_FALSE(system_snapshot().MachineDescription().empty()); |
+TEST_F(SystemSnapshotWinTest, MachineDescription) { |
+ EXPECT_TRUE(system_snapshot().MachineDescription().empty()); |
} |
-TEST_F(SystemSnapshotMacTest, TimeZone) { |
+TEST_F(SystemSnapshotWinTest, TimeZone) { |
SystemSnapshot::DaylightSavingTimeStatus dst_status; |
int standard_offset_seconds; |
int daylight_offset_seconds; |