Patrick Venture | 8a4f2aa | 2019-05-23 08:40:21 -0700 | [diff] [blame] | 1 | /** |
| 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 | |
| 10 | namespace ipmi_flash |
| 11 | { |
| 12 | namespace |
| 13 | { |
| 14 | |
| 15 | using ::testing::UnorderedElementsAreArray; |
| 16 | |
| 17 | class 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 | |
| 39 | TEST_F(FirmwareHandlerNotYetStartedTest, GetBlobListValidateListContents) |
| 40 | { |
Patrick Venture | 86c2208 | 2019-05-23 09:53:25 -0700 | [diff] [blame^] | 41 | /* TODO: Presently, /flash/verify is present from the beginning, however, |
Patrick Venture | 8a4f2aa | 2019-05-23 08:40:21 -0700 | [diff] [blame] | 42 | * 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 Venture | 86c2208 | 2019-05-23 09:53:25 -0700 | [diff] [blame^] | 51 | /* 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) */ |
| 56 | TEST_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 Venture | 8a4f2aa | 2019-05-23 08:40:21 -0700 | [diff] [blame] | 79 | } // namespace |
| 80 | } // namespace ipmi_flash |