blob: 65aa6ef3a8ade2d19de3f87258276869ce05f979 [file] [log] [blame]
Patrick Ventured333a872018-12-03 16:24:26 -08001#include "data_mock.hpp"
2#include "firmware_handler.hpp"
Patrick Venture1cc88952019-01-04 10:56:32 -08003#include "image_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07004#include "util.hpp"
Patrick Ventured333a872018-12-03 16:24:26 -08005
6#include <phosphor-logging/test/sdjournal_mock.hpp>
7#include <sdbusplus/test/sdbus_mock.hpp>
8
9#include <gtest/gtest.h>
10
11using namespace phosphor::logging;
12
13namespace blobs
14{
15using ::testing::Return;
16using ::testing::StrEq;
17using ::testing::StrictMock;
18
Patrick Venture301e5252019-01-10 09:38:12 -080019TEST(FirmwareHandlerBlobTest, VerifyFirmwareCounts)
Patrick Ventured333a872018-12-03 16:24:26 -080020{
21 /* Verify the firmware count must be greater than zero. */
22
23 DataHandlerMock dataMock;
Patrick Venture1cc88952019-01-04 10:56:32 -080024 ImageHandlerMock imageMock;
25 // StrictMock<SdJournalMock> journalMock;
26 // SwapJouralHandler(&journalMock);
Patrick Ventured333a872018-12-03 16:24:26 -080027
Patrick Venture1cc88952019-01-04 10:56:32 -080028 std::vector<HandlerPack> blobs = {
Patrick Venture7dad86f2019-05-17 08:52:20 -070029 {hashBlobId, &imageMock},
Patrick Venture1cc88952019-01-04 10:56:32 -080030 };
Patrick Ventured333a872018-12-03 16:24:26 -080031
32 std::vector<DataHandlerPack> data = {
33 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
34 {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
35 };
36
37 sdbusplus::SdBusMock sdbus_mock;
38 auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
39
Patrick Venture1cc88952019-01-04 10:56:32 -080040 // TODO: Once we can test across log<> paths again, re-enable this test
41 // as a failure test instead of a success one. EXPECT_CALL(journalMock,
42 // journal_send_call(StrEq("PRIORITY=%d")))
43 // .WillOnce(Return(0));
Patrick Ventured333a872018-12-03 16:24:26 -080044
45 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
46 std::move(bus_mock), blobs, data);
47
Patrick Venture1cc88952019-01-04 10:56:32 -080048 // EXPECT_EQ(handler, nullptr);
49 EXPECT_FALSE(handler == nullptr);
Patrick Ventured333a872018-12-03 16:24:26 -080050}
51
52} // namespace blobs