blob: 84769cb2d5e97a44e5b468eb57bc14cfffecca5c [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 Ventured333a872018-12-03 16:24:26 -08004
5#include <phosphor-logging/test/sdjournal_mock.hpp>
6#include <sdbusplus/test/sdbus_mock.hpp>
7
8#include <gtest/gtest.h>
9
10using namespace phosphor::logging;
11
12namespace blobs
13{
14using ::testing::Return;
15using ::testing::StrEq;
16using ::testing::StrictMock;
17
Patrick Venture301e5252019-01-10 09:38:12 -080018TEST(FirmwareHandlerBlobTest, VerifyFirmwareCounts)
Patrick Ventured333a872018-12-03 16:24:26 -080019{
20 /* Verify the firmware count must be greater than zero. */
21
22 DataHandlerMock dataMock;
Patrick Venture1cc88952019-01-04 10:56:32 -080023 ImageHandlerMock imageMock;
24 // StrictMock<SdJournalMock> journalMock;
25 // SwapJouralHandler(&journalMock);
Patrick Ventured333a872018-12-03 16:24:26 -080026
Patrick Venture1cc88952019-01-04 10:56:32 -080027 std::vector<HandlerPack> blobs = {
28 {FirmwareBlobHandler::hashBlobID, &imageMock},
29 };
Patrick Ventured333a872018-12-03 16:24:26 -080030
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 Venture1cc88952019-01-04 10:56:32 -080039 // 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 Ventured333a872018-12-03 16:24:26 -080043
44 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
45 std::move(bus_mock), blobs, data);
46
Patrick Venture1cc88952019-01-04 10:56:32 -080047 // EXPECT_EQ(handler, nullptr);
48 EXPECT_FALSE(handler == nullptr);
Patrick Ventured333a872018-12-03 16:24:26 -080049}
50
51} // namespace blobs