| #pragma once |
| |
| #include "cper_encoder.hpp" |
| |
| #include "gmock/gmock.h" |
| |
| namespace uefi::cper |
| { |
| |
| // Record Header |
| inline constexpr uint8_t kMockRecordSeverity = |
| static_cast<uint8_t>(ErrorSeverity::kFatal); |
| inline constexpr uint32_t kMockValidationBits = 0x5; |
| |
| inline constexpr guid_t kMockPlatformId{ |
| 0xF70B188B, |
| 0x8431, |
| 0x4AC0, |
| {0x85, 0x3B, 0x73, 0x44, 0x58, 0x82, 0x3E, 0xC5}}; |
| inline constexpr guid_t kMockPartitionId{ |
| 0xCAFDBB26, |
| 0x7ED7, |
| 0x4D4E, |
| {0x82, 0xBA, 0x68, 0xB0, 0x91, 0x20, 0xD5, 0x0B}}; |
| inline constexpr guid_t kMockCreatorId{ |
| 0x294C5454, |
| 0x6809, |
| 0x4C55, |
| {0xAD, 0x04, 0x82, 0x6B, 0xAD, 0xD8, 0x0A, 0x50}}; |
| |
| inline constexpr guid_t kMockNotificationType = notification_type::kPEI; |
| inline constexpr uint64_t kMockRecordId = 0xDEADBEEF; |
| inline constexpr uint32_t kMockHeaderFlags = record_flags::kRecovered; |
| inline constexpr uint64_t kMockPersistenceInformation = 0; |
| |
| // Section Descriptor |
| inline constexpr uint16_t kMockSectionRevision = 0x0002; |
| inline constexpr uint32_t kMockSectionValidationBits = 0x3; |
| inline constexpr uint32_t kMockSectionFlag = 0x1; |
| |
| inline constexpr guid_t kMockSectionType{ |
| 0xF0E2FCA7, |
| 0xAD2D, |
| 0x4B17, |
| {0x95, 0x0C, 0x76, 0x88, 0x7E, 0x6A, 0x30, 0xF3}}; |
| inline constexpr guid_t kMockFruId{ |
| 0x1103ED84, |
| 0x62DD, |
| 0x4028, |
| {0xAE, 0x9D, 0x20, 0xCE, 0xF6, 0xE7, 0xB5, 0xA9}}; |
| |
| inline constexpr uint8_t kMockSectionSeverity = |
| static_cast<uint8_t>(ErrorSeverity::kFatal); |
| constexpr std::array<uint8_t, 20> kMockFruText = {'m', 'o', 'c', 'k'}; |
| |
| template <ByteLike BodyType> |
| class MockCperEncoder : public CperEncoder<BodyType> |
| { |
| public: |
| const uint64_t timestamp; |
| |
| MockCperEncoder() : |
| timestamp(createCperTimestamp(std::chrono::system_clock::now())) |
| {} |
| |
| MOCK_METHOD((void), mockCreateRecordHeader, ()); |
| MOCK_METHOD((void), mockCreateSectionDescriptor, ()); |
| |
| RecordHeader createRecordHeader(const uint32_t recordLength, |
| const uint16_t sectionCount) override |
| { |
| mockCreateRecordHeader(); |
| return RecordHeader(sectionCount, kMockRecordSeverity, |
| kMockValidationBits, recordLength, timestamp, |
| kMockPlatformId, kMockPartitionId, kMockCreatorId, |
| kMockNotificationType, kMockRecordId, |
| kMockHeaderFlags, kMockPersistenceInformation); |
| } |
| |
| SectionDescriptor createSectionDescriptor(const uint32_t sectionLength, |
| const uint32_t sectionOffset, |
| const uint32_t sectionFlags, |
| const guid_t sectionType) override |
| { |
| mockCreateSectionDescriptor(); |
| return SectionDescriptor( |
| sectionOffset, sectionLength, kMockSectionRevision, |
| kMockSectionValidationBits, sectionFlags, sectionType, kMockFruId, |
| kMockSectionSeverity, kMockFruText); |
| } |
| }; |
| |
| }; // namespace uefi::cper |