blob: 3cf46eda79993aeaf84b7dc74ce6f860fc0f441f [file] [log] [blame]
#include "flash-ipmi.hpp"
#include <cstdio>
#include <gtest/gtest.h>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
#define THIRTYTWO_MIB 33554432
TEST(FlashIpmiHashStartTest, OutofSequenceFails)
{
// Verify that the image must be started first. (can change).
std::string name = std::tmpnam(nullptr);
std::string name2 = std::tmpnam(nullptr);
sdbusplus::SdBusMock sdbus_mock;
auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
FlashUpdate updater(std::move(bus_mock), name, "", name2);
EXPECT_FALSE(updater.startHash(THIRTYTWO_MIB));
(void)std::remove(name.c_str());
(void)std::remove(name2.c_str());
}
TEST(FlashIpmiHashStartTest, VerifyHashFileCreated)
{
// Verify that it's happy.
std::string name = std::tmpnam(nullptr);
std::string name2 = std::tmpnam(nullptr);
sdbusplus::SdBusMock sdbus_mock;
auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
FlashUpdate updater(std::move(bus_mock), name, "", name2);
EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
(void)std::remove(name.c_str());
(void)std::remove(name2.c_str());
}