OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef CRASHPAD_SNAPSHOT_TEST_TEST_SYSTEM_SNAPSHOT_H_ |
| 16 #define CRASHPAD_SNAPSHOT_TEST_TEST_SYSTEM_SNAPSHOT_H_ |
| 17 |
| 18 #include <stdint.h> |
| 19 |
| 20 #include <string> |
| 21 |
| 22 #include "base/basictypes.h" |
| 23 #include "snapshot/system_snapshot.h" |
| 24 |
| 25 namespace crashpad { |
| 26 namespace test { |
| 27 |
| 28 //! \brief A test SystemSnapshot that can carry arbitrary data for testing |
| 29 //! purposes. |
| 30 class TestSystemSnapshot final : public SystemSnapshot { |
| 31 public: |
| 32 TestSystemSnapshot(); |
| 33 ~TestSystemSnapshot() override; |
| 34 |
| 35 void SetCPUArchitecture(CPUArchitecture cpu_architecture) { |
| 36 cpu_architecture_ = cpu_architecture; |
| 37 } |
| 38 void SetCPURevision(uint32_t cpu_revision) { cpu_revision_ = cpu_revision; } |
| 39 void SetCPUCount(uint8_t cpu_count) { cpu_count_ = cpu_count; } |
| 40 void SetCPUVendor(const std::string& cpu_vendor) { cpu_vendor_ = cpu_vendor; } |
| 41 void SetCPUFrequency(uint64_t current_hz, uint64_t max_hz) { |
| 42 cpu_frequency_current_hz_ = current_hz; |
| 43 cpu_frequency_max_hz_ = max_hz; |
| 44 } |
| 45 void SetCPUX86Signature(uint32_t cpu_x86_signature) { |
| 46 cpu_x86_signature_ = cpu_x86_signature; |
| 47 } |
| 48 void SetCPUX86Features(uint64_t cpu_x86_features) { |
| 49 cpu_x86_features_ = cpu_x86_features; |
| 50 } |
| 51 void SetCPUX86ExtendedFeatures(uint64_t cpu_x86_extended_features) { |
| 52 cpu_x86_extended_features_ = cpu_x86_extended_features; |
| 53 } |
| 54 void SetCPUX86Leaf7Features(uint32_t cpu_x86_leaf_7_features) { |
| 55 cpu_x86_leaf_7_features_ = cpu_x86_leaf_7_features; |
| 56 } |
| 57 void SetCPUX86SupportsDAZ(bool cpu_x86_supports_daz) { |
| 58 cpu_x86_supports_daz_ = cpu_x86_supports_daz; |
| 59 } |
| 60 void SetOperatingSystem(OperatingSystem operating_system) { |
| 61 operating_system_ = operating_system; |
| 62 } |
| 63 void SetOSServer(bool os_server) { os_server_ = os_server; } |
| 64 void SetOSVersion( |
| 65 int major, int minor, int bugfix, const std::string& build) { |
| 66 os_version_major_ = major; |
| 67 os_version_minor_ = minor; |
| 68 os_version_bugfix_ = bugfix; |
| 69 os_version_build_ = build; |
| 70 } |
| 71 void SetOSVersionFull(const std::string& os_version_full) { |
| 72 os_version_full_ = os_version_full; |
| 73 } |
| 74 void SetNXEnabled(bool nx_enabled) { nx_enabled_ = nx_enabled; } |
| 75 void SetMachineDescription(const std::string& machine_description) { |
| 76 machine_description_ = machine_description; |
| 77 } |
| 78 void SetTimeZone(DaylightSavingTimeStatus dst_status, |
| 79 int standard_offset_seconds, |
| 80 int daylight_offset_seconds, |
| 81 const std::string& standard_name, |
| 82 const std::string& daylight_name) { |
| 83 time_zone_dst_status_ = dst_status; |
| 84 time_zone_standard_offset_seconds_ = standard_offset_seconds; |
| 85 time_zone_daylight_offset_seconds_ = daylight_offset_seconds; |
| 86 time_zone_standard_name_ = standard_name; |
| 87 time_zone_daylight_name_ = daylight_name; |
| 88 } |
| 89 |
| 90 // SystemSnapshot: |
| 91 |
| 92 CPUArchitecture GetCPUArchitecture() const override; |
| 93 uint32_t CPURevision() const override; |
| 94 uint8_t CPUCount() const override; |
| 95 std::string CPUVendor() const override; |
| 96 void CPUFrequency(uint64_t* current_hz, uint64_t* max_hz) const override; |
| 97 uint32_t CPUX86Signature() const override; |
| 98 uint64_t CPUX86Features() const override; |
| 99 uint64_t CPUX86ExtendedFeatures() const override; |
| 100 uint32_t CPUX86Leaf7Features() const override; |
| 101 bool CPUX86SupportsDAZ() const override; |
| 102 OperatingSystem GetOperatingSystem() const override; |
| 103 bool OSServer() const override; |
| 104 void OSVersion( |
| 105 int* major, int* minor, int* bugfix, std::string* build) const override; |
| 106 std::string OSVersionFull() const override; |
| 107 bool NXEnabled() const override; |
| 108 std::string MachineDescription() const override; |
| 109 void TimeZone(DaylightSavingTimeStatus* dst_status, |
| 110 int* standard_offset_seconds, |
| 111 int* daylight_offset_seconds, |
| 112 std::string* standard_name, |
| 113 std::string* daylight_name) const override; |
| 114 |
| 115 private: |
| 116 CPUArchitecture cpu_architecture_; |
| 117 uint32_t cpu_revision_; |
| 118 uint8_t cpu_count_; |
| 119 std::string cpu_vendor_; |
| 120 uint64_t cpu_frequency_current_hz_; |
| 121 uint64_t cpu_frequency_max_hz_; |
| 122 uint32_t cpu_x86_signature_; |
| 123 uint64_t cpu_x86_features_; |
| 124 uint64_t cpu_x86_extended_features_; |
| 125 uint32_t cpu_x86_leaf_7_features_; |
| 126 bool cpu_x86_supports_daz_; |
| 127 OperatingSystem operating_system_; |
| 128 bool os_server_; |
| 129 int os_version_major_; |
| 130 int os_version_minor_; |
| 131 int os_version_bugfix_; |
| 132 std::string os_version_build_; |
| 133 std::string os_version_full_; |
| 134 bool nx_enabled_; |
| 135 std::string machine_description_; |
| 136 DaylightSavingTimeStatus time_zone_dst_status_; |
| 137 int time_zone_standard_offset_seconds_; |
| 138 int time_zone_daylight_offset_seconds_; |
| 139 std::string time_zone_standard_name_; |
| 140 std::string time_zone_daylight_name_; |
| 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(TestSystemSnapshot); |
| 143 }; |
| 144 |
| 145 } // namespace test |
| 146 } // namespace crashpad |
| 147 |
| 148 #endif // CRASHPAD_SNAPSHOT_TEST_TEST_SYSTEM_SNAPSHOT_H_ |
OLD | NEW |