#include "buffer.hpp"
#include "data_interface_mock.hpp"

#include <boost/endian/arithmetic.hpp>
#include <boost/endian/conversion.hpp>

#include <algorithm>
#include <array>
#include <cstdint>
#include <memory>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

namespace bios_bmc_smm_error_logger
{
namespace
{

using ::testing::_;
using ::testing::ElementsAreArray;
using ::testing::InSequence;
using ::testing::Return;

class BufferTest : public ::testing::Test
{
  protected:
    BufferTest() :
        dataInterfaceMock(std::make_unique<DataInterfaceMock>()),
        dataInterfaceMockPtr(dataInterfaceMock.get())
    {
        bufferImpl = std::make_unique<BufferImpl>(std::move(dataInterfaceMock));
        testInitializationHeader.bmcInterfaceVersion = testBmcInterfaceVersion;
        testInitializationHeader.queueSize = testQueueSize;
        testInitializationHeader.ueRegionSize = testUeRegionSize;
        std::transform(testMagicNumber.begin(), testMagicNumber.end(),
                       testInitializationHeader.magicNumber.begin(),
                       [](uint32_t number) -> little_uint32_t {
                           return boost::endian::native_to_little(number);
                       });
    }
    ~BufferTest() override = default;

    // CircularBufferHeader size is 0x30, ensure the test region is bigger
    static constexpr size_t testRegionSize = 0x200;
    static constexpr uint32_t testBmcInterfaceVersion = 123;
    static constexpr uint32_t testQueueSize = 0x200;
    static constexpr uint16_t testUeRegionSize = 0x50;
    static constexpr std::array<uint32_t, 4> testMagicNumber = {
        0x12345678, 0x22345678, 0x32345678, 0x42345678};
    static constexpr size_t bufferHeaderSize =
        sizeof(struct CircularBufferHeader);

    struct CircularBufferHeader testInitializationHeader
    {};

    std::unique_ptr<DataInterfaceMock> dataInterfaceMock;
    DataInterfaceMock* dataInterfaceMockPtr;
    std::unique_ptr<BufferImpl> bufferImpl;
};

TEST_F(BufferTest, BufferInitializeEraseFail)
{
    InSequence s;
    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    EXPECT_THROW(
        try {
            // Test too big of a proposed buffer compared to the memori size
            uint16_t bigQueueSize = 0x201;
            uint16_t bigUeRegionSize = 0x50;
            bufferImpl->initialize(testBmcInterfaceVersion, bigQueueSize,
                                   bigUeRegionSize, testMagicNumber);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[initialize] Proposed queue size '513' is bigger than the BMC's allocated MMIO region of '512'");
            throw;
        },
        std::runtime_error);
    EXPECT_NE(bufferImpl->getCachedBufferHeader(), testInitializationHeader);

    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    const std::vector<uint8_t> emptyArray(testQueueSize, 0);
    // Return a smaller write than the intended testRegionSize to test the error
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, ElementsAreArray(emptyArray)))
        .WillOnce(Return(testQueueSize - 1));
    EXPECT_THROW(
        try {
            bufferImpl->initialize(testBmcInterfaceVersion, testQueueSize,
                                   testUeRegionSize, testMagicNumber);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(), "[initialize] Only erased '511'");
            throw;
        },
        std::runtime_error);
    EXPECT_NE(bufferImpl->getCachedBufferHeader(), testInitializationHeader);

    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, ElementsAreArray(emptyArray)))
        .WillOnce(Return(testQueueSize));
    // Return a smaller write than the intended initializationHeader to test the
    // error
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, _)).WillOnce(Return(0));
    EXPECT_THROW(
        try {
            bufferImpl->initialize(testBmcInterfaceVersion, testQueueSize,
                                   testUeRegionSize, testMagicNumber);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(),
                         "[initialize] Only wrote '0' bytes of the header");
            throw;
        },
        std::runtime_error);
    EXPECT_NE(bufferImpl->getCachedBufferHeader(), testInitializationHeader);
}

TEST_F(BufferTest, BufferInitializePass)
{
    InSequence s;
    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    const std::vector<uint8_t> emptyArray(testQueueSize, 0);
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, ElementsAreArray(emptyArray)))
        .WillOnce(Return(testQueueSize));

    uint8_t* testInitializationHeaderPtr =
        reinterpret_cast<uint8_t*>(&testInitializationHeader);
    EXPECT_CALL(*dataInterfaceMockPtr,
                write(0, ElementsAreArray(testInitializationHeaderPtr,
                                          bufferHeaderSize)))
        .WillOnce(Return(bufferHeaderSize));
    EXPECT_NO_THROW(
        bufferImpl->initialize(testBmcInterfaceVersion, testQueueSize,
                               testUeRegionSize, testMagicNumber));
    EXPECT_EQ(bufferImpl->getCachedBufferHeader(), testInitializationHeader);
}

TEST_F(BufferTest, BufferHeaderReadFail)
{
    std::vector<std::uint8_t> testBytesRead{};
    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(testBytesRead));
    EXPECT_THROW(
        try {
            bufferImpl->readBufferHeader();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(),
                         "Buffer header read only read '0', expected '48'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferTest, BufferHeaderReadPass)
{
    uint8_t* testInitializationHeaderPtr =
        reinterpret_cast<uint8_t*>(&testInitializationHeader);
    std::vector<uint8_t> testInitializationHeaderVector(
        testInitializationHeaderPtr,
        testInitializationHeaderPtr + bufferHeaderSize);

    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(testInitializationHeaderVector));
    EXPECT_NO_THROW(bufferImpl->readBufferHeader());
    EXPECT_EQ(bufferImpl->getCachedBufferHeader(), testInitializationHeader);
}

TEST_F(BufferTest, BufferUpdateReadPtrFail)
{
    // Return write size that is not 2 which is sizeof(little_uint16_t)
    constexpr size_t wrongWriteSize = 1;
    EXPECT_CALL(*dataInterfaceMockPtr, write(_, _))
        .WillOnce(Return(wrongWriteSize));
    EXPECT_THROW(
        try {
            bufferImpl->updateReadPtr(0);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[updateReadPtr] Wrote '1' bytes, instead of expected '3'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferTest, BufferUpdateReadPtrPass)
{
    constexpr size_t expectedWriteSize = 3;
    constexpr uint8_t expectedBmcReadPtrOffset = 0x21;
    // Check that we truncate the highest 24bits
    const uint32_t testNewReadPtr = 0x99881234;
    const std::vector<uint8_t> expectedReadPtr{0x34, 0x12, 0x88};

    EXPECT_CALL(*dataInterfaceMockPtr, write(expectedBmcReadPtrOffset,
                                             ElementsAreArray(expectedReadPtr)))
        .WillOnce(Return(expectedWriteSize));
    EXPECT_NO_THROW(bufferImpl->updateReadPtr(testNewReadPtr));

    auto cachedHeader = bufferImpl->getCachedBufferHeader();
    EXPECT_EQ(boost::endian::little_to_native(cachedHeader.bmcReadPtr),
              0x881234);
}

TEST_F(BufferTest, BufferUpdateBmcFlagsFail)
{
    // Return write size that is not 4 which is sizeof(little_uint32_t)
    constexpr size_t wrongWriteSize = 1;
    EXPECT_CALL(*dataInterfaceMockPtr, write(_, _))
        .WillOnce(Return(wrongWriteSize));
    EXPECT_THROW(
        try {
            bufferImpl->updateBmcFlags(static_cast<uint32_t>(BmcFlags::ready));
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[updateBmcFlags] Wrote '1' bytes, instead of expected '4'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferTest, BufferUpdateBmcFlagsPass)
{
    constexpr size_t expectedWriteSize = 4;
    constexpr uint8_t expectedBmcReadPtrOffset = 0x1d;
    const std::vector<uint8_t> expectedNewBmcFlagsVector{0x04, 0x0, 0x0, 0x00};

    EXPECT_CALL(*dataInterfaceMockPtr,
                write(expectedBmcReadPtrOffset,
                      ElementsAreArray(expectedNewBmcFlagsVector)))
        .WillOnce(Return(expectedWriteSize));
    EXPECT_NO_THROW(
        bufferImpl->updateBmcFlags(static_cast<uint32_t>(BmcFlags::ready)));

    auto cachedHeader = bufferImpl->getCachedBufferHeader();
    EXPECT_EQ(boost::endian::little_to_native(cachedHeader.bmcFlags),
              static_cast<uint32_t>(BmcFlags::ready));
}

TEST_F(BufferTest, GetMaxOffsetQueueSizeFail)
{
    InSequence s;
    static constexpr size_t wrongQueueSize = testQueueSize - 1;
    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    const std::vector<uint8_t> emptyArray(wrongQueueSize, 0);
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, ElementsAreArray(emptyArray)))
        .WillOnce(Return(wrongQueueSize));

    EXPECT_CALL(*dataInterfaceMockPtr, write(0, _))
        .WillOnce(Return(bufferHeaderSize));
    EXPECT_NO_THROW(
        bufferImpl->initialize(testBmcInterfaceVersion, wrongQueueSize,
                               testUeRegionSize, testMagicNumber));
    EXPECT_THROW(
        try {
            bufferImpl->getMaxOffset();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(),
                         "[getMaxOffset] runtime queueSize '511' did not match "
                         "compile-time queueSize '512'. This indicates that the"
                         " buffer was corrupted");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferTest, GetMaxOffsetUeRegionSizeFail)
{
    InSequence s;
    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    const std::vector<uint8_t> emptyArray(testQueueSize, 0);
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, ElementsAreArray(emptyArray)))
        .WillOnce(Return(testQueueSize));

    EXPECT_CALL(*dataInterfaceMockPtr, write(0, _))
        .WillOnce(Return(bufferHeaderSize));
    EXPECT_NO_THROW(
        bufferImpl->initialize(testBmcInterfaceVersion, testQueueSize,
                               testUeRegionSize + 1, testMagicNumber));
    EXPECT_THROW(
        try {
            bufferImpl->getMaxOffset();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[getMaxOffset] runtime ueRegionSize '81' did not match "
                "compile-time ueRegionSize '80'. This indicates that the"
                " buffer was corrupted");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferTest, GetOffsetUeRegionSizeFail)
{
    InSequence s;
    EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
        .WillOnce(Return(testRegionSize));
    const std::vector<uint8_t> emptyArray(testQueueSize, 0);
    EXPECT_CALL(*dataInterfaceMockPtr, write(0, ElementsAreArray(emptyArray)))
        .WillOnce(Return(testQueueSize));

    EXPECT_CALL(*dataInterfaceMockPtr, write(0, _))
        .WillOnce(Return(bufferHeaderSize));
    EXPECT_NO_THROW(
        bufferImpl->initialize(testBmcInterfaceVersion, testQueueSize,
                               testUeRegionSize - 1, testMagicNumber));
    EXPECT_THROW(
        try {
            bufferImpl->getQueueOffset();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[getQueueOffset] runtime ueRegionSize '79' did not match "
                "compile-time ueRegionSize '80'. This indicates that the"
                " buffer was corrupted");
            throw;
        },
        std::runtime_error);
}

class BufferWraparoundReadTest : public BufferTest
{
  protected:
    BufferWraparoundReadTest()
    {
        initializeFuncMock();
    }
    void initializeFuncMock()
    {
        // Initialize the memory and the cachedBufferHeader
        InSequence s;
        EXPECT_CALL(*dataInterfaceMockPtr, getMemoryRegionSize())
            .WillOnce(Return(testRegionSize));
        const std::vector<uint8_t> emptyArray(testQueueSize, 0);
        EXPECT_CALL(*dataInterfaceMockPtr,
                    write(0, ElementsAreArray(emptyArray)))
            .WillOnce(Return(testQueueSize));

        EXPECT_CALL(*dataInterfaceMockPtr, write(0, _))
            .WillOnce(Return(bufferHeaderSize));
        EXPECT_NO_THROW(
            bufferImpl->initialize(testBmcInterfaceVersion, testQueueSize,
                                   testUeRegionSize, testMagicNumber));
    }
    static constexpr size_t expectedWriteSize = 3;
    static constexpr uint8_t expectedBmcReadPtrOffset = 0x21;
    static constexpr size_t expectedqueueOffset = 0x30 + testUeRegionSize;

    static constexpr size_t testMaxOffset =
        testQueueSize - testUeRegionSize - sizeof(struct CircularBufferHeader);
    uint8_t* testInitializationHeaderPtr =
        reinterpret_cast<uint8_t*>(&testInitializationHeader);
};

TEST_F(BufferWraparoundReadTest, GetMaxOffsetPassTest)
{
    EXPECT_EQ(bufferImpl->getMaxOffset(), testMaxOffset);
}

TEST_F(BufferWraparoundReadTest, GetQueueOffsetPassTest)
{
    EXPECT_EQ(bufferImpl->getQueueOffset(),
              bufferHeaderSize + testUeRegionSize);
}

TEST_F(BufferWraparoundReadTest, ParamsTooBigFail)
{
    InSequence s;
    size_t tooBigOffset = testMaxOffset + 1;
    EXPECT_THROW(
        try {
            bufferImpl->wraparoundRead(tooBigOffset, /* length */ 1);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[wraparoundRead] relativeOffset '385' was bigger than maxOffset '384'");
            throw;
        },
        std::runtime_error);

    size_t tooBigLength = testMaxOffset + 1;
    EXPECT_THROW(
        try {
            bufferImpl->wraparoundRead(/* relativeOffset */ 0, tooBigLength);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(), "[wraparoundRead] length '385' was bigger "
                                   "than maxOffset '384'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferWraparoundReadTest, NoWrapAroundReadFails)
{
    InSequence s;
    size_t testLength = 0x10;
    size_t testOffset = 0x20;

    // Fail the first read
    std::vector<std::uint8_t> shortTestBytesRead(testLength - 1);
    EXPECT_CALL(*dataInterfaceMockPtr,
                read(testOffset + expectedqueueOffset, testLength))
        .WillOnce(Return(shortTestBytesRead));

    EXPECT_THROW(
        try {
            bufferImpl->wraparoundRead(testOffset, testLength);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(),
                         "[wraparoundRead] Read '15' which was not the "
                         "requested length of '16'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferWraparoundReadTest, NoWrapAroundReadPass)
{
    InSequence s;
    size_t testLength = 0x10;
    size_t testOffset = 0x20;

    // Successfully read all the requested length without a wrap around
    std::vector<std::uint8_t> testBytesRead(testLength);
    EXPECT_CALL(*dataInterfaceMockPtr,
                read(testOffset + expectedqueueOffset, testLength))
        .WillOnce(Return(testBytesRead));

    // Call to updateReadPtr is triggered
    const std::vector<uint8_t> expectedReadPtr{
        static_cast<uint8_t>(testOffset + testLength), 0x0, 0x0};
    EXPECT_CALL(*dataInterfaceMockPtr, write(expectedBmcReadPtrOffset,
                                             ElementsAreArray(expectedReadPtr)))
        .WillOnce(Return(expectedWriteSize));

    EXPECT_THAT(bufferImpl->wraparoundRead(testOffset, testLength),
                ElementsAreArray(testBytesRead));
    struct CircularBufferHeader cachedBufferHeader =
        bufferImpl->getCachedBufferHeader();
    // The bmcReadPtr should have been updated
    EXPECT_EQ(boost::endian::little_to_native(cachedBufferHeader.bmcReadPtr),
              testOffset + testLength);
}

TEST_F(BufferWraparoundReadTest, WrapAroundReadFails)
{
    InSequence s;
    size_t testBytesLeft = 3;
    size_t testLength = 0x10;
    size_t testOffset = testMaxOffset - (testLength - testBytesLeft);

    // Read until the end of the queue
    std::vector<std::uint8_t> testBytesReadShort(testLength - testBytesLeft);
    EXPECT_CALL(*dataInterfaceMockPtr, read(testOffset + expectedqueueOffset,
                                            testLength - testBytesLeft))
        .WillOnce(Return(testBytesReadShort));

    // Read 1 byte short after wraparound
    std::vector<std::uint8_t> testBytesLeftReadShort(testBytesLeft - 1);
    EXPECT_CALL(*dataInterfaceMockPtr, read(expectedqueueOffset, testBytesLeft))
        .WillOnce(Return(testBytesLeftReadShort));

    EXPECT_THROW(
        try {
            bufferImpl->wraparoundRead(testOffset, testLength);
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[wraparoundRead] Buffer wrapped around but read '2' which was "
                "not the requested lenght of '3'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferWraparoundReadTest, WrapAroundReadPasses)
{
    InSequence s;
    size_t testBytesLeft = 3;
    size_t testLength = 0x10;
    size_t testOffset = testMaxOffset - (testLength - testBytesLeft);

    // Read to the end of the queue
    std::vector<std::uint8_t> testBytesReadFirst{16, 15, 14, 13, 12, 11, 10,
                                                 9,  8,  7,  6,  5,  4};
    EXPECT_CALL(*dataInterfaceMockPtr, read(testOffset + expectedqueueOffset,
                                            testLength - testBytesLeft))
        .WillOnce(Return(testBytesReadFirst));

    std::vector<std::uint8_t> testBytesReadSecond{3, 2, 1};
    EXPECT_CALL(*dataInterfaceMockPtr, read(expectedqueueOffset, testBytesLeft))
        .WillOnce(Return(testBytesReadSecond));

    // Call to updateReadPtr is triggered
    const std::vector<uint8_t> expectedReadPtr{
        static_cast<uint8_t>(testBytesLeft), 0x0, 0x0};
    EXPECT_CALL(*dataInterfaceMockPtr, write(expectedBmcReadPtrOffset,
                                             ElementsAreArray(expectedReadPtr)))
        .WillOnce(Return(expectedWriteSize));

    std::vector<std::uint8_t> expectedBytes = {16, 15, 14, 13, 12, 11, 10, 9,
                                               8,  7,  6,  5,  4,  3,  2,  1};
    EXPECT_THAT(bufferImpl->wraparoundRead(testOffset, testLength),
                ElementsAreArray(expectedBytes));
    struct CircularBufferHeader cachedBufferHeader =
        bufferImpl->getCachedBufferHeader();
    // The bmcReadPtr should have been updated to reflect the wraparound
    EXPECT_EQ(boost::endian::little_to_native(cachedBufferHeader.bmcReadPtr),
              testBytesLeft);
}

TEST_F(BufferWraparoundReadTest, WrapAroundCornerCasePass)
{
    InSequence s;
    size_t testBytesLeft = 0;
    size_t testLength = 4;
    size_t testOffset = testMaxOffset - (testLength - testBytesLeft);

    // Read to the very end of the queue
    std::vector<std::uint8_t> testBytes{4, 3, 2, 1};
    EXPECT_CALL(*dataInterfaceMockPtr,
                read(testOffset + expectedqueueOffset, testLength))
        .WillOnce(Return(testBytes));

    // Call to updateReadPtr is triggered, since we read to the very end of the
    // buffer, update the readPtr up around to 0
    const std::vector<uint8_t> expectedReadPtr{0x0, 0x0, 0x0};
    EXPECT_CALL(*dataInterfaceMockPtr, write(expectedBmcReadPtrOffset,
                                             ElementsAreArray(expectedReadPtr)))
        .WillOnce(Return(expectedWriteSize));

    EXPECT_THAT(bufferImpl->wraparoundRead(testOffset, testLength),
                ElementsAreArray(testBytes));
    struct CircularBufferHeader cachedBufferHeader =
        bufferImpl->getCachedBufferHeader();
    // The bmcReadPtr should have been updated to reflect the wraparound
    EXPECT_EQ(boost::endian::little_to_native(cachedBufferHeader.bmcReadPtr),
              0);
}

class BufferEntryTest : public BufferWraparoundReadTest
{
  protected:
    BufferEntryTest()
    {
        testEntryHeader.sequenceId = testSequenceId;
        testEntryHeader.entrySize = testEntrySize;
        testEntryHeader.checksum = testChecksum;
        testEntryHeader.rdeCommandType = testRdeCommandType;
    }
    ~BufferEntryTest() override = default;

    void wraparoundReadMock(const uint32_t relativeOffset,
                            std::span<std::uint8_t> expetedBytesOutput)
    {
        InSequence s;
        const uint32_t queueSizeToQueueEnd = testMaxOffset - relativeOffset;

        // This will wrap, split the read mocks in 2
        if (expetedBytesOutput.size() > queueSizeToQueueEnd)
        {
            EXPECT_CALL(*dataInterfaceMockPtr, read(_, _))
                .WillOnce(Return(std::vector<std::uint8_t>(
                    expetedBytesOutput.begin(),
                    expetedBytesOutput.begin() + queueSizeToQueueEnd)));
            EXPECT_CALL(*dataInterfaceMockPtr, read(_, _))
                .WillOnce(Return(std::vector<std::uint8_t>(
                    expetedBytesOutput.begin() + queueSizeToQueueEnd,
                    expetedBytesOutput.end())));
        }
        else
        {
            EXPECT_CALL(*dataInterfaceMockPtr, read(_, _))
                .WillOnce(Return(std::vector<std::uint8_t>(
                    expetedBytesOutput.begin(), expetedBytesOutput.end())));
        }

        EXPECT_CALL(*dataInterfaceMockPtr, write(_, _))
            .WillOnce(Return(expectedWriteSize));
    }

    static constexpr size_t entryHeaderSize = sizeof(struct QueueEntryHeader);
    static constexpr uint16_t testSequenceId = 0;
    static constexpr uint16_t testEntrySize = 0x20;
    static constexpr uint8_t testRdeCommandType = 0x01;
    // Calculated checksum for the header
    static constexpr uint8_t testChecksum =
        (testSequenceId ^ testEntrySize ^ testRdeCommandType);
    size_t testOffset = 0x0;

    struct QueueEntryHeader testEntryHeader
    {};
};

TEST_F(BufferEntryTest, ReadEntryHeaderPass)
{
    uint8_t* testEntryHeaderPtr = reinterpret_cast<uint8_t*>(&testEntryHeader);
    std::vector<uint8_t> testEntryHeaderVector(
        testEntryHeaderPtr, testEntryHeaderPtr + entryHeaderSize);
    wraparoundReadMock(testOffset, testEntryHeaderVector);
    EXPECT_EQ(bufferImpl->readEntryHeader(), testEntryHeader);
    // Check the bmcReadPtr
    struct CircularBufferHeader cachedBufferHeader =
        bufferImpl->getCachedBufferHeader();
    EXPECT_EQ(boost::endian::little_to_native(cachedBufferHeader.bmcReadPtr),
              testOffset + testEntryHeaderVector.size());
}

TEST_F(BufferEntryTest, ReadEntryChecksumFail)
{
    InSequence s;
    std::vector<uint8_t> testEntryVector(testEntrySize);
    // Offset the checksum by 1
    testEntryHeader.checksum += 1;
    uint8_t* testEntryHeaderPtr = reinterpret_cast<uint8_t*>(&testEntryHeader);
    std::vector<uint8_t> testEntryHeaderVector(
        testEntryHeaderPtr, testEntryHeaderPtr + entryHeaderSize);
    wraparoundReadMock(testOffset, testEntryHeaderVector);
    wraparoundReadMock(testOffset + entryHeaderSize, testEntryVector);
    EXPECT_THROW(
        try { bufferImpl->readEntry(); } catch (const std::runtime_error& e) {
            // Calculation: testChecksum (0x21) XOR (0x22) = 3
            EXPECT_STREQ(e.what(),
                         "[readEntry] Checksum was '3', expected '0'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferEntryTest, ReadEntryPassWraparound)
{
    InSequence s;
    // We expect this will bump checksum up by "testEntrySize" = 0xff ^ 0xff ...
    // (20 times) = 0 therefore leave the checksum as is
    std::vector<uint8_t> testEntryVector(testEntrySize, 0xff);
    uint8_t* testEntryHeaderPtr = reinterpret_cast<uint8_t*>(&testEntryHeader);
    std::vector<uint8_t> testEntryHeaderVector(
        testEntryHeaderPtr, testEntryHeaderPtr + entryHeaderSize);
    // Set testOffset so that we can test the wraparound here at the header and
    // update the readPtr
    testOffset = testMaxOffset - 1;
    EXPECT_CALL(*dataInterfaceMockPtr, write(expectedBmcReadPtrOffset, _))
        .WillOnce(Return(expectedWriteSize));
    EXPECT_NO_THROW(bufferImpl->updateReadPtr(testOffset));

    wraparoundReadMock(testOffset, testEntryHeaderVector);
    wraparoundReadMock(testOffset + entryHeaderSize, testEntryVector);

    EntryPair testedEntryPair;
    EXPECT_NO_THROW(testedEntryPair = bufferImpl->readEntry());
    EXPECT_EQ(testedEntryPair.first, testEntryHeader);
    EXPECT_THAT(testedEntryPair.second, ElementsAreArray(testEntryVector));
    struct CircularBufferHeader cachedBufferHeader =
        bufferImpl->getCachedBufferHeader();
    // The bmcReadPtr should have been updated to reflect the wraparound
    EXPECT_EQ(boost::endian::little_to_native(cachedBufferHeader.bmcReadPtr),
              entryHeaderSize + testEntrySize - 1);

    // Set testOffset so that we can test the wraparound here as well on our
    // second read for the entry (by 1 byte)
    testOffset = testMaxOffset - entryHeaderSize - 1;
    EXPECT_CALL(*dataInterfaceMockPtr, write(expectedBmcReadPtrOffset, _))
        .WillOnce(Return(expectedWriteSize));
    EXPECT_NO_THROW(bufferImpl->updateReadPtr(testOffset));

    wraparoundReadMock(testOffset, testEntryHeaderVector);
    wraparoundReadMock(testOffset + entryHeaderSize, testEntryVector);

    EXPECT_NO_THROW(testedEntryPair = bufferImpl->readEntry());
    EXPECT_EQ(testedEntryPair.first, testEntryHeader);
    EXPECT_THAT(testedEntryPair.second, ElementsAreArray(testEntryVector));
    cachedBufferHeader = bufferImpl->getCachedBufferHeader();
    // The bmcReadPtr should have been updated to reflect the wraparound
    EXPECT_EQ(boost::endian::little_to_native(cachedBufferHeader.bmcReadPtr),
              testEntrySize - 1);
}

class BufferReadErrorLogsTest : public BufferEntryTest
{
  protected:
    BufferReadErrorLogsTest() = default;

    uint8_t* testEntryHeaderPtr = reinterpret_cast<uint8_t*>(&testEntryHeader);
    size_t entryAndHeaderSize = entryHeaderSize + testEntrySize;
};

TEST_F(BufferReadErrorLogsTest, PtrsTooBigFail)
{
    InSequence s;
    // Set the biosWritePtr too big
    testInitializationHeader.biosWritePtr =
        boost::endian::native_to_little((testMaxOffset + 1));
    initializeFuncMock();

    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(std::vector<uint8_t>(
            testInitializationHeaderPtr,
            testInitializationHeaderPtr + bufferHeaderSize)));
    EXPECT_THROW(
        try {
            bufferImpl->readErrorLogs();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(),
                         "[readErrorLogs] currentBiosWritePtr was '385' "
                         "which was bigger than maxOffset '384'");
            throw;
        },
        std::runtime_error);

    // Reset the biosWritePtr and set the bmcReadPtr too big
    testInitializationHeader.biosWritePtr = 0;
    initializeFuncMock();
    testInitializationHeader.bmcReadPtr =
        boost::endian::native_to_little((testMaxOffset + 1));
    initializeFuncMock();

    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(std::vector<uint8_t>(
            testInitializationHeaderPtr,
            testInitializationHeaderPtr + bufferHeaderSize)));
    EXPECT_THROW(
        try {
            bufferImpl->readErrorLogs();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(e.what(), "[readErrorLogs] currentReadPtr was '385' "
                                   "which was bigger than maxOffset '384'");
            throw;
        },
        std::runtime_error);
}

TEST_F(BufferReadErrorLogsTest, IdenticalPtrsPass)
{
    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(std::vector<uint8_t>(
            testInitializationHeaderPtr,
            testInitializationHeaderPtr + bufferHeaderSize)));
    EXPECT_NO_THROW(bufferImpl->readErrorLogs());
}

TEST_F(BufferReadErrorLogsTest, NoWraparoundPass)
{
    InSequence s;
    // Set the biosWritePtr to 1 entryHeader + entry size
    testInitializationHeader.biosWritePtr =
        boost::endian::native_to_little((entryAndHeaderSize));
    initializeFuncMock();
    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(std::vector<uint8_t>(
            testInitializationHeaderPtr,
            testInitializationHeaderPtr + bufferHeaderSize)));
    std::vector<uint8_t> testEntryHeaderVector(
        testEntryHeaderPtr, testEntryHeaderPtr + entryHeaderSize);
    std::vector<uint8_t> testEntryVector(testEntrySize);
    wraparoundReadMock(/*relativeOffset=*/0, testEntryHeaderVector);
    wraparoundReadMock(/*relativeOffset=*/0 + entryHeaderSize, testEntryVector);

    std::vector<EntryPair> entryPairs;
    EXPECT_NO_THROW(entryPairs = bufferImpl->readErrorLogs());

    // Check that we only read one entryPair and that the content is correct
    EXPECT_EQ(entryPairs.size(), 1U);
    EXPECT_EQ(entryPairs[0].first, testEntryHeader);
    EXPECT_THAT(entryPairs[0].second, ElementsAreArray(testEntryVector));
}

TEST_F(BufferReadErrorLogsTest, WraparoundMultiplEntryPass)
{
    InSequence s;
    // Set the bmcReadPtr to 1 entryHeader + entry size from the "end" exactly
    uint32_t entryAndHeaderSizeAwayFromEnd = testMaxOffset - entryAndHeaderSize;
    testInitializationHeader.bmcReadPtr =
        boost::endian::native_to_little(entryAndHeaderSizeAwayFromEnd);
    // Set the biosWritePtr to 1 entryHeader + entry size from the "beginning"
    testInitializationHeader.biosWritePtr = entryAndHeaderSize;
    initializeFuncMock();
    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(std::vector<uint8_t>(
            testInitializationHeaderPtr,
            testInitializationHeaderPtr + bufferHeaderSize)));

    std::vector<uint8_t> testEntryHeaderVector(
        testEntryHeaderPtr, testEntryHeaderPtr + entryHeaderSize);
    std::vector<uint8_t> testEntryVector(testEntrySize);
    wraparoundReadMock(/*relativeOffset=*/entryAndHeaderSizeAwayFromEnd,
                       testEntryHeaderVector);
    wraparoundReadMock(/*relativeOffset=*/entryAndHeaderSizeAwayFromEnd +
                           entryHeaderSize,
                       testEntryVector);
    wraparoundReadMock(/*relativeOffset=*/0 + entryAndHeaderSize,
                       testEntryHeaderVector);
    wraparoundReadMock(/*relativeOffset=*/0 + entryAndHeaderSize +
                           entryHeaderSize,
                       testEntryVector);

    std::vector<EntryPair> entryPairs;
    EXPECT_NO_THROW(entryPairs = bufferImpl->readErrorLogs());

    // Check that we only read one entryPair and that the content is correct
    EXPECT_EQ(entryPairs.size(), 2);
    EXPECT_EQ(entryPairs[0].first, testEntryHeader);
    EXPECT_EQ(entryPairs[1].first, testEntryHeader);
    EXPECT_THAT(entryPairs[0].second, ElementsAreArray(testEntryVector));
    EXPECT_THAT(entryPairs[1].second, ElementsAreArray(testEntryVector));
}

TEST_F(BufferReadErrorLogsTest, WraparoundMismatchingPtrsFail)
{
    InSequence s;
    testInitializationHeader.bmcReadPtr = boost::endian::native_to_little(0);
    // Make the biosWritePtr intentially 1 smaller than expected
    testInitializationHeader.biosWritePtr =
        boost::endian::native_to_little(entryAndHeaderSize - 1);
    initializeFuncMock();
    EXPECT_CALL(*dataInterfaceMockPtr, read(0, bufferHeaderSize))
        .WillOnce(Return(std::vector<uint8_t>(
            testInitializationHeaderPtr,
            testInitializationHeaderPtr + bufferHeaderSize)));

    std::vector<uint8_t> testEntryHeaderVector(
        testEntryHeaderPtr, testEntryHeaderPtr + entryHeaderSize);
    std::vector<uint8_t> testEntryVector(testEntrySize);
    wraparoundReadMock(/*relativeOffset=*/0, testEntryHeaderVector);
    wraparoundReadMock(/*relativeOffset=*/0 + entryHeaderSize, testEntryVector);

    EXPECT_THROW(
        try {
            bufferImpl->readErrorLogs();
        } catch (const std::runtime_error& e) {
            EXPECT_STREQ(
                e.what(),
                "[readErrorLogs] biosWritePtr '37' and bmcReaddPtr '38' "
                "are not identical after reading through all the logs");
            throw;
        },
        std::runtime_error);
}

} // namespace
} // namespace bios_bmc_smm_error_logger
