blob: d2eaa2c03bf6355bdb3c4a0520a187813b1cd9e1 [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
36 ImageHandlerMock imageMock;
37 std::vector<HandlerPack> blobs;
38 std::vector<DataHandlerPack> data = {
39 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
40 std::unique_ptr<blobs::GenericBlobInterface> handler;
41 VerificationMock* verifyMockPtr;
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070042};
43
Patrick Venture1361a122019-05-20 07:36:05 -070044class IpmiOnlyFirmwareTest : public ::testing::Test
45{
46 protected:
47 ImageHandlerMock imageMock;
48 std::vector<HandlerPack> blobs;
49 std::vector<DataHandlerPack> data = {
50 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
Patrick Venture1d5a31c2019-05-20 11:38:22 -070051 std::unique_ptr<blobs::GenericBlobInterface> handler;
Patrick Venture1361a122019-05-20 07:36:05 -070052
53 void SetUp() override
54 {
55 blobs = {
56 {hashBlobId, &imageMock},
57 {"asdf", &imageMock},
58 };
59 handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture27ac5822019-05-20 17:39:31 -070060 blobs, data, CreateVerifyMock(), CreateUpdateMock());
Patrick Venture1361a122019-05-20 07:36:05 -070061 }
62};
63
64class FakeLpcFirmwareTest : public ::testing::Test
65{
66 protected:
67 DataHandlerMock dataMock;
68 ImageHandlerMock imageMock;
69 std::vector<HandlerPack> blobs;
70 std::vector<DataHandlerPack> data;
Patrick Venture1d5a31c2019-05-20 11:38:22 -070071 std::unique_ptr<blobs::GenericBlobInterface> handler;
Patrick Venture1361a122019-05-20 07:36:05 -070072
73 void SetUp() override
74 {
75 blobs = {
76 {hashBlobId, &imageMock},
77 {"asdf", &imageMock},
78 };
79 data = {
80 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
81 {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
82 };
83 handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture27ac5822019-05-20 17:39:31 -070084 blobs, data, CreateVerifyMock(), CreateUpdateMock());
Patrick Venture1361a122019-05-20 07:36:05 -070085 }
86};
87
Patrick Venture1d5a31c2019-05-20 11:38:22 -070088} // namespace ipmi_flash