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 | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 4 | |
| 5 | #include <phosphor-logging/test/sdjournal_mock.hpp> |
| 6 | #include <sdbusplus/test/sdbus_mock.hpp> |
| 7 | |
| 8 | #include <gtest/gtest.h> |
| 9 | |
| 10 | using namespace phosphor::logging; |
| 11 | |
| 12 | namespace blobs |
| 13 | { |
| 14 | using ::testing::Return; |
| 15 | using ::testing::StrEq; |
| 16 | using ::testing::StrictMock; |
| 17 | |
Patrick Venture | 301e525 | 2019-01-10 09:38:12 -0800 | [diff] [blame^] | 18 | TEST(FirmwareHandlerBlobTest, VerifyFirmwareCounts) |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 19 | { |
| 20 | /* Verify the firmware count must be greater than zero. */ |
| 21 | |
| 22 | DataHandlerMock dataMock; |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 23 | ImageHandlerMock imageMock; |
| 24 | // StrictMock<SdJournalMock> journalMock; |
| 25 | // SwapJouralHandler(&journalMock); |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 26 | |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 27 | std::vector<HandlerPack> blobs = { |
| 28 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
| 29 | }; |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 30 | |
| 31 | std::vector<DataHandlerPack> data = { |
| 32 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
| 33 | {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock}, |
| 34 | }; |
| 35 | |
| 36 | sdbusplus::SdBusMock sdbus_mock; |
| 37 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 38 | |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 39 | // TODO: Once we can test across log<> paths again, re-enable this test |
| 40 | // as a failure test instead of a success one. EXPECT_CALL(journalMock, |
| 41 | // journal_send_call(StrEq("PRIORITY=%d"))) |
| 42 | // .WillOnce(Return(0)); |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 43 | |
| 44 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 45 | std::move(bus_mock), blobs, data); |
| 46 | |
Patrick Venture | 1cc8895 | 2019-01-04 10:56:32 -0800 | [diff] [blame] | 47 | // EXPECT_EQ(handler, nullptr); |
| 48 | EXPECT_FALSE(handler == nullptr); |
Patrick Venture | d333a87 | 2018-12-03 16:24:26 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | } // namespace blobs |