Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 1 | #include "data_mock.hpp" |
| 2 | #include "firmware_handler.hpp" |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 3 | #include "image_mock.hpp" |
Patrick Venture | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame^] | 4 | #include "util.hpp" |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 5 | |
| 6 | #include <phosphor-logging/test/sdjournal_mock.hpp> |
| 7 | #include <sdbusplus/test/sdbus_mock.hpp> |
| 8 | |
| 9 | #include <gtest/gtest.h> |
| 10 | |
| 11 | using namespace phosphor::logging; |
| 12 | |
| 13 | namespace blobs |
| 14 | { |
| 15 | using ::testing::Return; |
| 16 | using ::testing::StrEq; |
| 17 | using ::testing::StrictMock; |
| 18 | |
Patrick Venture | 301e525 | 2019-01-10 09:38:12 -0800 | [diff] [blame] | 19 | TEST(FirmwareHandlerBlobTest, VerifyFirmwareCounts) |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 20 | { |
| 21 | /* Verify the firmware count must be greater than zero. */ |
| 22 | |
| 23 | DataHandlerMock dataMock; |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 24 | ImageHandlerMock imageMock; |
| 25 | // StrictMock<SdJournalMock> journalMock; |
| 26 | // SwapJouralHandler(&journalMock); |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 27 | |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 28 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame^] | 29 | {hashBlobId, &imageMock}, |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 30 | }; |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 31 | |
| 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 Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 40 | // 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 Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 44 | |
| 45 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 46 | std::move(bus_mock), blobs, data); |
| 47 | |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 48 | // EXPECT_EQ(handler, nullptr); |
| 49 | EXPECT_FALSE(handler == nullptr); |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | } // namespace blobs |