#include "create_action_map.hpp" #include "firmware_handler.hpp" #include "flags.hpp" #include "image_mock.hpp" #include "util.hpp" #include #include #include #include namespace ipmi_flash { namespace { class FirmwareOpenFailTest : public ::testing::TestWithParam {}; TEST_P(FirmwareOpenFailTest, WithFlags) { std::vector data; data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr); data.emplace_back(FirmwareFlags::UpdateFlags::p2a, nullptr); data.emplace_back(FirmwareFlags::UpdateFlags::lpc, nullptr); std::vector blobs; blobs.emplace_back(hashBlobId, std::make_unique()); blobs.emplace_back("asdf", std::make_unique()); auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( std::move(blobs), std::move(data), CreateActionMap("asdf")); EXPECT_FALSE(handler->open(0, GetParam(), "asdf")); } const std::vector OpenFailParams{ /* These first 4 fail because they don't have the "write" flag */ 0b000 << 8, 0b110 << 8, 0b101 << 8, 0b011 << 8, /* Next 1 doesn't specify any transport */ blobs::OpenFlags::write | 0b000 << 8, /* Next 3 specify 2 reserved transport bits at the same time. This isn't * allowed because older code expects these first 3 bits to be mutually * exclusive. */ blobs::OpenFlags::write | 0b110 << 8, blobs::OpenFlags::write | 0b101 << 8, blobs::OpenFlags::write | 0b011 << 8, }; INSTANTIATE_TEST_CASE_P(WithFlags, FirmwareOpenFailTest, ::testing::ValuesIn(OpenFailParams)); } // namespace } // namespace ipmi_flash