blob: 2427b820c7f78083b1781f24dbc0b5b23df0f979 [file] [log] [blame]
Patrick Venture1361a122019-05-20 07:36:05 -07001#pragma once
2
Patrick Venture27ac5822019-05-20 17:39:31 -07003#include "bmc_update_mock.hpp"
Patrick Venture1361a122019-05-20 07:36:05 -07004#include "data_mock.hpp"
5#include "firmware_handler.hpp"
6#include "image_mock.hpp"
7#include "verification_mock.hpp"
8
9#include <memory>
10#include <vector>
11
12#include <gmock/gmock.h>
13#include <gtest/gtest.h>
14
Patrick Venture1d5a31c2019-05-20 11:38:22 -070015namespace ipmi_flash
Patrick Venture1361a122019-05-20 07:36:05 -070016{
17
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070018class IpmiOnlyFirmwareStaticTest : public ::testing::Test
19{
20 protected:
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070021 void SetUp() override
22 {
23 blobs = {
24 {hashBlobId, &imageMock},
25 {staticLayoutBlobId, &imageMock},
26 };
Patrick Venture19044e12019-05-23 19:30:28 -070027
28 std::unique_ptr<VerificationInterface> verifyMock =
29 std::make_unique<VerificationMock>();
30 verifyMockPtr = reinterpret_cast<VerificationMock*>(verifyMock.get());
31
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070032 handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture19044e12019-05-23 19:30:28 -070033 blobs, data, std::move(verifyMock), CreateUpdateMock());
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070034 }
Patrick Venture19044e12019-05-23 19:30:28 -070035
Patrick Venture6fdd02e2019-05-28 13:02:04 -070036 void expectedState(FirmwareBlobHandler::UpdateState state)
37 {
38 auto realHandler = dynamic_cast<FirmwareBlobHandler*>(handler.get());
39 EXPECT_EQ(state, realHandler->getCurrentState());
40 }
41
Patrick Venture19044e12019-05-23 19:30:28 -070042 ImageHandlerMock imageMock;
43 std::vector<HandlerPack> blobs;
44 std::vector<DataHandlerPack> data = {
45 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
46 std::unique_ptr<blobs::GenericBlobInterface> handler;
47 VerificationMock* verifyMockPtr;
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070048};
49
Patrick Venture1361a122019-05-20 07:36:05 -070050class IpmiOnlyFirmwareTest : public ::testing::Test
51{
52 protected:
53 ImageHandlerMock imageMock;
54 std::vector<HandlerPack> blobs;
55 std::vector<DataHandlerPack> data = {
56 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
Patrick Venture1d5a31c2019-05-20 11:38:22 -070057 std::unique_ptr<blobs::GenericBlobInterface> handler;
Patrick Venture1361a122019-05-20 07:36:05 -070058
59 void SetUp() override
60 {
61 blobs = {
62 {hashBlobId, &imageMock},
63 {"asdf", &imageMock},
64 };
65 handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture27ac5822019-05-20 17:39:31 -070066 blobs, data, CreateVerifyMock(), CreateUpdateMock());
Patrick Venture1361a122019-05-20 07:36:05 -070067 }
68};
69
70class FakeLpcFirmwareTest : public ::testing::Test
71{
72 protected:
73 DataHandlerMock dataMock;
74 ImageHandlerMock imageMock;
75 std::vector<HandlerPack> blobs;
76 std::vector<DataHandlerPack> data;
Patrick Venture1d5a31c2019-05-20 11:38:22 -070077 std::unique_ptr<blobs::GenericBlobInterface> handler;
Patrick Venture1361a122019-05-20 07:36:05 -070078
79 void SetUp() override
80 {
81 blobs = {
82 {hashBlobId, &imageMock},
83 {"asdf", &imageMock},
84 };
85 data = {
86 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
87 {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
88 };
89 handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture27ac5822019-05-20 17:39:31 -070090 blobs, data, CreateVerifyMock(), CreateUpdateMock());
Patrick Venture1361a122019-05-20 07:36:05 -070091 }
92};
93
Patrick Venture1d5a31c2019-05-20 11:38:22 -070094} // namespace ipmi_flash