Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -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 verificationPending. This state is achieved as a |
| 4 | * transition out of uploadInProgress. |
| 5 | */ |
| 6 | #include "firmware_handler.hpp" |
| 7 | #include "firmware_unittest.hpp" |
Patrick Venture | 01a3327 | 2019-05-23 19:48:22 -0700 | [diff] [blame] | 8 | #include "status.hpp" |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 9 | #include "util.hpp" |
| 10 | |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 11 | #include <algorithm> |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 12 | #include <cstdint> |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
| 16 | #include <gtest/gtest.h> |
| 17 | |
| 18 | namespace ipmi_flash |
| 19 | { |
| 20 | namespace |
| 21 | { |
| 22 | |
Patrick Venture | 2567ebc | 2019-05-24 10:02:53 -0700 | [diff] [blame] | 23 | using ::testing::IsEmpty; |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 24 | using ::testing::Return; |
Patrick Venture | efba42d | 2019-05-24 10:48:16 -0700 | [diff] [blame] | 25 | using ::testing::UnorderedElementsAreArray; |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * There are the following calls (parameters may vary): |
| 29 | * canHandleBlob(blob) |
| 30 | * getBlobIds |
| 31 | * deleteBlob(blob) |
| 32 | * stat(blob) |
| 33 | * stat(session) |
| 34 | * open(blob) |
| 35 | * close(session) |
| 36 | * writemeta(session) |
| 37 | * write(session) |
| 38 | * read(session) |
| 39 | * commit(session) |
| 40 | * |
| 41 | * Testing canHandleBlob is uninteresting in this state. Getting the BlobIDs |
| 42 | * will inform what canHandleBlob will return. |
| 43 | */ |
| 44 | |
| 45 | class FirmwareHandlerVerificationPendingTest : public IpmiOnlyFirmwareStaticTest |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 46 | {}; |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * getBlobIds |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 50 | */ |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 51 | TEST_F(FirmwareHandlerVerificationPendingTest, VerifyBlobIdAvailableInState) |
| 52 | { |
| 53 | /* Only in the verificationPending state (and later), should the |
Patrick Venture | 0f82ce4 | 2019-05-28 14:06:04 -0700 | [diff] [blame] | 54 | * verifyBlobId be present. |
| 55 | */ |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 56 | EXPECT_FALSE(handler->canHandleBlob(verifyBlobId)); |
| 57 | |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 58 | getToVerificationPending(staticLayoutBlobId); |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 59 | |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 60 | EXPECT_TRUE(handler->canHandleBlob(verifyBlobId)); |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 61 | EXPECT_TRUE(handler->canHandleBlob(activeImageBlobId)); |
Patrick Venture | 0f82ce4 | 2019-05-28 14:06:04 -0700 | [diff] [blame] | 62 | EXPECT_FALSE(handler->canHandleBlob(updateBlobId)); |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 65 | /* |
Patrick Venture | 2ca6652 | 2019-06-17 11:58:38 -0700 | [diff] [blame] | 66 | * delete(blob) |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 67 | */ |
Patrick Venture | 2ca6652 | 2019-06-17 11:58:38 -0700 | [diff] [blame] | 68 | TEST_F(FirmwareHandlerVerificationPendingTest, DeleteVerifyPendingAbortsProcess) |
| 69 | { |
| 70 | /* It doesn't matter what blob id is used to delete in the design, so just |
| 71 | * delete the verify blob id |
| 72 | */ |
| 73 | getToVerificationPending(staticLayoutBlobId); |
| 74 | |
| 75 | EXPECT_CALL(*verifyMockPtr, abort()).Times(0); |
| 76 | |
| 77 | ASSERT_TRUE(handler->canHandleBlob(verifyBlobId)); |
| 78 | EXPECT_TRUE(handler->deleteBlob(verifyBlobId)); |
| 79 | |
| 80 | std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId}; |
| 81 | EXPECT_THAT(handler->getBlobIds(), |
| 82 | UnorderedElementsAreArray(expectedBlobs)); |
| 83 | expectedState(FirmwareBlobHandler::UpdateState::notYetStarted); |
| 84 | } |
| 85 | |
| 86 | TEST_F(FirmwareHandlerVerificationPendingTest, DeleteActiveImageAbortsProcess) |
| 87 | { |
| 88 | getToVerificationPending(staticLayoutBlobId); |
| 89 | |
| 90 | EXPECT_CALL(*verifyMockPtr, abort()).Times(0); |
| 91 | |
| 92 | ASSERT_TRUE(handler->canHandleBlob(activeImageBlobId)); |
| 93 | EXPECT_TRUE(handler->deleteBlob(activeImageBlobId)); |
| 94 | |
| 95 | std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId}; |
| 96 | EXPECT_THAT(handler->getBlobIds(), |
| 97 | UnorderedElementsAreArray(expectedBlobs)); |
| 98 | expectedState(FirmwareBlobHandler::UpdateState::notYetStarted); |
| 99 | } |
| 100 | |
| 101 | TEST_F(FirmwareHandlerVerificationPendingTest, DeleteStaticLayoutAbortsProcess) |
| 102 | { |
| 103 | getToVerificationPending(staticLayoutBlobId); |
| 104 | |
| 105 | EXPECT_CALL(*verifyMockPtr, abort()).Times(0); |
| 106 | |
| 107 | ASSERT_TRUE(handler->canHandleBlob(staticLayoutBlobId)); |
| 108 | EXPECT_TRUE(handler->deleteBlob(staticLayoutBlobId)); |
| 109 | |
| 110 | std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId}; |
| 111 | EXPECT_THAT(handler->getBlobIds(), |
| 112 | UnorderedElementsAreArray(expectedBlobs)); |
| 113 | expectedState(FirmwareBlobHandler::UpdateState::notYetStarted); |
| 114 | } |
| 115 | |
| 116 | TEST_F(FirmwareHandlerVerificationPendingTest, DeleteHashAbortsProcess) |
| 117 | { |
| 118 | getToVerificationPending(staticLayoutBlobId); |
| 119 | |
| 120 | EXPECT_CALL(*verifyMockPtr, abort()).Times(0); |
| 121 | |
| 122 | ASSERT_TRUE(handler->canHandleBlob(hashBlobId)); |
| 123 | EXPECT_TRUE(handler->deleteBlob(hashBlobId)); |
| 124 | |
| 125 | std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId}; |
| 126 | EXPECT_THAT(handler->getBlobIds(), |
| 127 | UnorderedElementsAreArray(expectedBlobs)); |
| 128 | expectedState(FirmwareBlobHandler::UpdateState::notYetStarted); |
| 129 | } |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 130 | |
| 131 | /* |
Patrick Venture | 92f2615 | 2020-05-26 19:47:36 -0700 | [diff] [blame] | 132 | * expire(session) |
| 133 | */ |
| 134 | TEST_F(FirmwareHandlerVerificationPendingTest, |
| 135 | ExpireVerificationPendingAbortsProcess) |
| 136 | { |
| 137 | getToVerificationPending(staticLayoutBlobId); |
| 138 | |
| 139 | EXPECT_CALL(*verifyMockPtr, abort()).Times(0); |
| 140 | |
| 141 | EXPECT_TRUE(handler->expire(session)); |
| 142 | |
| 143 | std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId}; |
| 144 | EXPECT_THAT(handler->getBlobIds(), |
| 145 | UnorderedElementsAreArray(expectedBlobs)); |
| 146 | expectedState(FirmwareBlobHandler::UpdateState::notYetStarted); |
| 147 | } |
| 148 | |
| 149 | /* |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 150 | * stat(blob) |
| 151 | */ |
| 152 | TEST_F(FirmwareHandlerVerificationPendingTest, StatOnActiveImageReturnsFailure) |
| 153 | { |
| 154 | getToVerificationPending(staticLayoutBlobId); |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 155 | ASSERT_TRUE(handler->canHandleBlob(activeImageBlobId)); |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 156 | |
| 157 | blobs::BlobMeta meta; |
| 158 | EXPECT_FALSE(handler->stat(activeImageBlobId, &meta)); |
| 159 | } |
| 160 | |
| 161 | TEST_F(FirmwareHandlerVerificationPendingTest, StatOnActiveHashReturnsFailure) |
| 162 | { |
| 163 | getToVerificationPending(hashBlobId); |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 164 | ASSERT_TRUE(handler->canHandleBlob(activeHashBlobId)); |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 165 | |
| 166 | blobs::BlobMeta meta; |
| 167 | EXPECT_FALSE(handler->stat(activeHashBlobId, &meta)); |
| 168 | } |
| 169 | |
| 170 | TEST_F(FirmwareHandlerVerificationPendingTest, |
| 171 | StatOnVerificationBlobReturnsFailure) |
| 172 | { |
Patrick Venture | 1999eef | 2019-07-01 11:44:09 -0700 | [diff] [blame] | 173 | getToVerificationPending(staticLayoutBlobId); |
Patrick Venture | 0f82ce4 | 2019-05-28 14:06:04 -0700 | [diff] [blame] | 174 | ASSERT_TRUE(handler->canHandleBlob(verifyBlobId)); |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 175 | |
| 176 | blobs::BlobMeta meta; |
| 177 | EXPECT_FALSE(handler->stat(verifyBlobId, &meta)); |
| 178 | } |
| 179 | |
Patrick Venture | 1999eef | 2019-07-01 11:44:09 -0700 | [diff] [blame] | 180 | TEST_F(FirmwareHandlerVerificationPendingTest, |
| 181 | VerificationBlobNotFoundWithoutStaticDataAsWell) |
| 182 | { |
| 183 | /* If you only ever open the hash blob id, and never the firmware blob id, |
| 184 | * the verify blob isn't added. |
| 185 | */ |
| 186 | getToVerificationPending(hashBlobId); |
| 187 | EXPECT_FALSE(handler->canHandleBlob(verifyBlobId)); |
| 188 | } |
| 189 | |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 190 | TEST_F(FirmwareHandlerVerificationPendingTest, StatOnNormalBlobsReturnsSuccess) |
| 191 | { |
| 192 | getToVerificationPending(staticLayoutBlobId); |
| 193 | |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 194 | std::vector<std::string> testBlobs = {staticLayoutBlobId, hashBlobId}; |
| 195 | for (const auto& blob : testBlobs) |
| 196 | { |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 197 | ASSERT_TRUE(handler->canHandleBlob(blob)); |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 198 | blobs::BlobMeta meta = {}; |
| 199 | EXPECT_TRUE(handler->stat(blob, &meta)); |
Benjamin Fair | 1290198 | 2019-11-12 13:55:46 -0800 | [diff] [blame] | 200 | EXPECT_EQ(expectedIdleMeta, meta); |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | /* |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 205 | * open(blob) |
| 206 | */ |
Patrick Venture | da8fcd1 | 2019-05-23 18:53:50 -0700 | [diff] [blame] | 207 | TEST_F(FirmwareHandlerVerificationPendingTest, OpenVerifyBlobSucceeds) |
| 208 | { |
| 209 | getToVerificationPending(staticLayoutBlobId); |
| 210 | |
| 211 | /* the session is safe because it was already closed to get to this state. |
| 212 | */ |
| 213 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
| 214 | } |
| 215 | |
Patrick Venture | 0f82ce4 | 2019-05-28 14:06:04 -0700 | [diff] [blame] | 216 | TEST_F(FirmwareHandlerVerificationPendingTest, OpenActiveBlobsFail) |
Patrick Venture | da8fcd1 | 2019-05-23 18:53:50 -0700 | [diff] [blame] | 217 | { |
| 218 | /* Try opening the active blob Id. This test is equivalent to trying to |
| 219 | * open the active hash blob id, in that neither are ever allowed. |
| 220 | */ |
| 221 | getToVerificationPending(staticLayoutBlobId); |
| 222 | EXPECT_FALSE(handler->open(session, flags, activeImageBlobId)); |
Patrick Venture | 0f82ce4 | 2019-05-28 14:06:04 -0700 | [diff] [blame] | 223 | EXPECT_FALSE(handler->open(session, flags, activeHashBlobId)); |
Patrick Venture | da8fcd1 | 2019-05-23 18:53:50 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | TEST_F(FirmwareHandlerVerificationPendingTest, |
| 227 | OpenImageBlobTransitionsToUploadInProgress) |
| 228 | { |
| 229 | getToVerificationPending(staticLayoutBlobId); |
Patrick Venture | efba42d | 2019-05-24 10:48:16 -0700 | [diff] [blame] | 230 | |
| 231 | /* Verify the active blob for the image is in the list once to start. |
| 232 | * Note: This is truly tested under the notYetStarted::open() test. |
| 233 | */ |
| 234 | std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId, |
| 235 | verifyBlobId, activeImageBlobId}; |
| 236 | |
| 237 | EXPECT_THAT(handler->getBlobIds(), |
| 238 | UnorderedElementsAreArray(expectedBlobs)); |
| 239 | |
Patrick Venture | 6d7735d | 2019-06-21 10:03:19 -0700 | [diff] [blame] | 240 | /* Verifies it isn't triggered again. */ |
| 241 | EXPECT_CALL(*prepareMockPtr, trigger()).Times(0); |
| 242 | |
Patrick Venture | d4e20de | 2019-07-18 12:48:05 -0700 | [diff] [blame] | 243 | EXPECT_CALL(*imageMock2, open(staticLayoutBlobId)).WillOnce(Return(true)); |
Patrick Venture | da8fcd1 | 2019-05-23 18:53:50 -0700 | [diff] [blame] | 244 | EXPECT_TRUE(handler->open(session, flags, staticLayoutBlobId)); |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 245 | expectedState(FirmwareBlobHandler::UpdateState::uploadInProgress); |
Patrick Venture | efba42d | 2019-05-24 10:48:16 -0700 | [diff] [blame] | 246 | |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 247 | expectedBlobs.erase( |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 248 | std::remove(expectedBlobs.begin(), expectedBlobs.end(), verifyBlobId), |
| 249 | expectedBlobs.end()); |
Patrick Venture | 930c7b7 | 2019-05-24 11:11:08 -0700 | [diff] [blame] | 250 | |
| 251 | /* Verify the active blob ID was not added to the list twice and |
| 252 | * verifyBlobId is removed |
| 253 | */ |
Patrick Venture | efba42d | 2019-05-24 10:48:16 -0700 | [diff] [blame] | 254 | EXPECT_THAT(handler->getBlobIds(), |
| 255 | UnorderedElementsAreArray(expectedBlobs)); |
Patrick Venture | da8fcd1 | 2019-05-23 18:53:50 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | /* |
Patrick Venture | 1e389c9 | 2019-05-23 19:15:05 -0700 | [diff] [blame] | 259 | * close(session) |
| 260 | */ |
| 261 | TEST_F(FirmwareHandlerVerificationPendingTest, |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 262 | ClosingVerifyBlobWithoutCommitDoesNotChangeState) |
Patrick Venture | 1e389c9 | 2019-05-23 19:15:05 -0700 | [diff] [blame] | 263 | { |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 264 | /* commit() will change the state, closing post-commit is part of |
| 265 | * verificationStarted testing. |
| 266 | */ |
Patrick Venture | 1e389c9 | 2019-05-23 19:15:05 -0700 | [diff] [blame] | 267 | getToVerificationPending(staticLayoutBlobId); |
| 268 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 269 | expectedState(FirmwareBlobHandler::UpdateState::verificationPending); |
Patrick Venture | 1e389c9 | 2019-05-23 19:15:05 -0700 | [diff] [blame] | 270 | |
| 271 | handler->close(session); |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 272 | expectedState(FirmwareBlobHandler::UpdateState::verificationPending); |
Patrick Venture | 1e389c9 | 2019-05-23 19:15:05 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | /* |
Patrick Venture | 19044e1 | 2019-05-23 19:30:28 -0700 | [diff] [blame] | 276 | * commit(session) |
| 277 | */ |
| 278 | TEST_F(FirmwareHandlerVerificationPendingTest, |
| 279 | CommitOnVerifyBlobTriggersVerificationAndStateTransition) |
| 280 | { |
| 281 | getToVerificationPending(staticLayoutBlobId); |
| 282 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 283 | EXPECT_CALL(*verifyMockPtr, trigger()).WillOnce(Return(true)); |
Patrick Venture | 19044e1 | 2019-05-23 19:30:28 -0700 | [diff] [blame] | 284 | |
| 285 | EXPECT_TRUE(handler->commit(session, {})); |
Patrick Venture | 6fdd02e | 2019-05-28 13:02:04 -0700 | [diff] [blame] | 286 | expectedState(FirmwareBlobHandler::UpdateState::verificationStarted); |
Patrick Venture | 19044e1 | 2019-05-23 19:30:28 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /* |
Patrick Venture | da8fcd1 | 2019-05-23 18:53:50 -0700 | [diff] [blame] | 290 | * stat(session) - in this state, you can only open(verifyBlobId) without |
| 291 | * changing state. |
| 292 | */ |
Patrick Venture | 01a3327 | 2019-05-23 19:48:22 -0700 | [diff] [blame] | 293 | TEST_F(FirmwareHandlerVerificationPendingTest, StatOnVerifyBlobIdReturnsState) |
| 294 | { |
| 295 | /* If this is called before commit(), it's still verificationPending, so it |
| 296 | * just returns the state is other |
| 297 | */ |
| 298 | getToVerificationPending(staticLayoutBlobId); |
| 299 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 300 | EXPECT_CALL(*verifyMockPtr, trigger()).Times(0); |
Patrick Venture | f1f0f65 | 2019-06-03 09:10:19 -0700 | [diff] [blame] | 301 | EXPECT_CALL(*verifyMockPtr, status()).Times(0); |
Patrick Venture | 01a3327 | 2019-05-23 19:48:22 -0700 | [diff] [blame] | 302 | |
| 303 | blobs::BlobMeta meta, expectedMeta = {}; |
| 304 | expectedMeta.size = 0; |
| 305 | expectedMeta.blobState = flags; |
| 306 | expectedMeta.metadata.push_back( |
Patrick Venture | da66fd8 | 2019-06-03 11:11:24 -0700 | [diff] [blame] | 307 | static_cast<std::uint8_t>(ActionStatus::unknown)); |
Patrick Venture | 01a3327 | 2019-05-23 19:48:22 -0700 | [diff] [blame] | 308 | |
| 309 | EXPECT_TRUE(handler->stat(session, &meta)); |
| 310 | EXPECT_EQ(expectedMeta, meta); |
| 311 | } |
| 312 | |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 313 | /* |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 314 | * writemeta(session) |
| 315 | */ |
Patrick Venture | b611a08 | 2019-05-23 20:27:28 -0700 | [diff] [blame] | 316 | TEST_F(FirmwareHandlerVerificationPendingTest, WriteMetaAgainstVerifyFails) |
| 317 | { |
| 318 | /* The verifyBlobId has no data handler, which means write meta fails. */ |
| 319 | getToVerificationPending(staticLayoutBlobId); |
| 320 | |
| 321 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
| 322 | |
| 323 | std::vector<std::uint8_t> bytes = {0x01, 0x02}; |
| 324 | EXPECT_FALSE(handler->writeMeta(session, 0, bytes)); |
| 325 | } |
| 326 | |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 327 | /* |
| 328 | * write(session) |
| 329 | */ |
Patrick Venture | ab731e9 | 2019-05-24 09:58:00 -0700 | [diff] [blame] | 330 | TEST_F(FirmwareHandlerVerificationPendingTest, WriteAgainstVerifyBlobIdFails) |
| 331 | { |
| 332 | getToVerificationPending(staticLayoutBlobId); |
| 333 | |
| 334 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
| 335 | |
| 336 | std::vector<std::uint8_t> bytes = {0x01, 0x02}; |
| 337 | EXPECT_FALSE(handler->write(session, 0, bytes)); |
| 338 | } |
| 339 | |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 340 | /* |
| 341 | * read(session) |
| 342 | */ |
Patrick Venture | 2567ebc | 2019-05-24 10:02:53 -0700 | [diff] [blame] | 343 | TEST_F(FirmwareHandlerVerificationPendingTest, |
| 344 | ReadAgainstVerifyBlobIdReturnsEmpty) |
| 345 | { |
| 346 | getToVerificationPending(staticLayoutBlobId); |
| 347 | |
| 348 | EXPECT_TRUE(handler->open(session, flags, verifyBlobId)); |
Patrick Venture | 0f82ce4 | 2019-05-28 14:06:04 -0700 | [diff] [blame] | 349 | EXPECT_THAT(handler->read(session, 0, 1), IsEmpty()); |
Patrick Venture | 2567ebc | 2019-05-24 10:02:53 -0700 | [diff] [blame] | 350 | } |
Patrick Venture | b386b86 | 2019-05-23 18:42:54 -0700 | [diff] [blame] | 351 | |
Patrick Venture | 61d2ed4 | 2019-05-23 18:16:31 -0700 | [diff] [blame] | 352 | } // namespace |
| 353 | } // namespace ipmi_flash |