blob: fcb2d3479c28059bddfed943f53bba9b7a97d174 [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;
Patrick Venturec6ba8ff2020-09-23 12:42:57 -070029 blobs.emplace_back(hashBlobId, std::make_unique<ImageHandlerMock>());
30 blobs.emplace_back("asdf", std::make_unique<ImageHandlerMock>());
Patrick Venturea78e39f2018-11-06 18:37:06 -080031
Patrick Venture4934daa2020-09-22 16:37:44 -070032 std::vector<DataHandlerPack> data;
33 data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
Patrick Venturea78e39f2018-11-06 18:37:06 -080034
Patrick Venture4eb55952018-11-16 15:36:24 -080035 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Ventureda4d4a42020-09-28 11:41:05 -070036 std::move(blobs), std::move(data), CreateActionMap("asdf"));
Patrick Venture4eb55952018-11-16 15:36:24 -080037
Patrick Venturee312f392019-06-04 07:44:37 -070038 blobs::BlobMeta meta;
Patrick Venture46637c82018-11-06 15:20:24 -080039 EXPECT_TRUE(handler->stat("asdf", &meta));
Benjamin Fair12901982019-11-12 13:55:46 -080040 /* All transport flags are set */
41 EXPECT_EQ(0xff00, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080042}
43
Patrick Ventured4e20de2019-07-18 12:48:05 -070044} // namespace
Patrick Venture1d5a31c2019-05-20 11:38:22 -070045} // namespace ipmi_flash