blob: 96723591d812ee32f0003ce89bf1c354a2e47449 [file] [log] [blame]
Patrick Venture8a4f2aa2019-05-23 08:40:21 -07001/**
2 * The goal of these tests is to verify the behavior of all blob commands given
3 * the current state is notYetStarted. The initial state.
4 */
5#include "firmware_handler.hpp"
6#include "firmware_unittest.hpp"
7
8#include <gtest/gtest.h>
9
10namespace ipmi_flash
11{
12namespace
13{
14
15using ::testing::UnorderedElementsAreArray;
16
17class FirmwareHandlerNotYetStartedTest : public IpmiOnlyFirmwareStaticTest
18{
19};
20
21/*
22 * There are the following calls (parameters may vary):
23 * Note: you cannot have a session yet, so only commands that don't take a
24 * session parameter are valid. Once you open() from this state, we will vary
25 * you transition out of this state (ensuring the above is true). Technically
26 * the firmware handler receives the session number with open(), but the blob
27 * manager is providing this normally.
28 *
29 * canHandleBlob
30 * getBlobIds
31 * deleteBlob
32 * stat
33 * open
34 *
35 * canHandleBlob is just a count check (or something similar) against what is
36 * returned by getBlobIds. It is tested in firmware_canhandle_unittest
37 */
38
39TEST_F(FirmwareHandlerNotYetStartedTest, GetBlobListValidateListContents)
40{
Patrick Venture86c22082019-05-23 09:53:25 -070041 /* TODO: Presently, /flash/verify is present from the beginning, however,
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070042 * this is going to change to simplify handling of open().
43 */
44 std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId,
45 verifyBlobId};
46
47 EXPECT_THAT(handler->getBlobIds(),
48 UnorderedElementsAreArray(expectedBlobs));
49}
50
Patrick Venture86c22082019-05-23 09:53:25 -070051/* TODO: Try deleting some blobs -- in this state it should just return failure,
52 * but it's not yet implemented
53 */
54
55/* stat(blob_id) */
56TEST_F(FirmwareHandlerNotYetStartedTest, StatEachBlobIdVerifyResults)
57{
58 /* In this original state, calling stat() on the blob ids will return the
59 * transported supported.
60 */
61 blobs::BlobMeta expected;
62 expected.blobState = FirmwareBlobHandler::UpdateFlags::ipmi;
63 expected.size = 0;
64
65 /* TODO: note, once verifyblobid isn't present in this state we can use
66 * getblobids()'s output as input
67 */
68 std::vector<std::string> testBlobs = {staticLayoutBlobId, hashBlobId};
69 for (const auto& blob : testBlobs)
70 {
71 blobs::BlobMeta meta = {};
72 EXPECT_TRUE(handler->stat(blob, &meta));
73 EXPECT_EQ(expected, meta);
74 }
75}
76
77/* open(each blob id) */
78
Patrick Venture8a4f2aa2019-05-23 08:40:21 -070079} // namespace
80} // namespace ipmi_flash