blob: 1313c5a61d64726c29923594f6dcd136b8245a98 [file] [log] [blame]
Patrick Venture46637c82018-11-06 15:20:24 -08001#include "firmware_handler.hpp"
Patrick Venture84778b82019-06-26 20:11:09 -07002#include "flags.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08003#include "image_mock.hpp"
Patrick Venture1d66fe62019-06-03 14:57:27 -07004#include "triggerable_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07005#include "util.hpp"
Patrick Venture46637c82018-11-06 15:20:24 -08006
Patrick Ventured4e20de2019-07-18 12:48:05 -07007#include <memory>
Patrick Venturea78e39f2018-11-06 18:37:06 -08008#include <vector>
Patrick Venture46637c82018-11-06 15:20:24 -08009
10#include <gtest/gtest.h>
11
Patrick Venture1d5a31c2019-05-20 11:38:22 -070012namespace ipmi_flash
Patrick Venture46637c82018-11-06 15:20:24 -080013{
Patrick Ventured4e20de2019-07-18 12:48:05 -070014namespace
15{
16
Benjamin Fair12901982019-11-12 13:55:46 -080017/* This test ensures the stat() method preserves compatibility with older host
18 * tools by reporting that all transports are supported. */
19TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsAllTransports)
Patrick Venture46637c82018-11-06 15:20:24 -080020{
21 /* Test that the metadata information returned matches expectations for this
22 * case.
23 *
24 * canHandle has already been called at this point, so we don't need to test
25 * the input for this function.
26 */
27
Patrick Ventured4e20de2019-07-18 12:48:05 -070028 std::vector<HandlerPack> blobs;
29 blobs.push_back(std::move(
30 HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>())));
31 blobs.push_back(
32 std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
Patrick Venturea78e39f2018-11-06 18:37:06 -080033
Patrick Venture1cde5f92018-11-07 08:26:47 -080034 std::vector<DataHandlerPack> data = {
Patrick Venture84778b82019-06-26 20:11:09 -070035 {FirmwareFlags::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080036 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080037
Patrick Venture4eb55952018-11-16 15:36:24 -080038 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture7b783432020-09-22 15:55:08 -070039 std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
Patrick Venture4eb55952018-11-16 15:36:24 -080040
Patrick Venturee312f392019-06-04 07:44:37 -070041 blobs::BlobMeta meta;
Patrick Venture46637c82018-11-06 15:20:24 -080042 EXPECT_TRUE(handler->stat("asdf", &meta));
Benjamin Fair12901982019-11-12 13:55:46 -080043 /* All transport flags are set */
44 EXPECT_EQ(0xff00, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080045}
46
Patrick Ventured4e20de2019-07-18 12:48:05 -070047} // namespace
Patrick Venture1d5a31c2019-05-20 11:38:22 -070048} // namespace ipmi_flash