Refactor to use new version of OEM IPMI Handler
Using the new version of ipmi handler provide a higher level wrapper
over the same functionalities. It helps us parse the input and output to
have more control of the input/output we see.
Changes to note,
- All cmd are removed from the request data. That is automatically
extracted now.
Tested:
Unit Test Passed.
All IPMI OEM command still works the same as before this change.
```
$ burn_my_bmc -command stage -image /tmp/test.txt -interface ipmipci
Set up ipmi flash updater with /flash/dummy
Received failure on delete: Received IPMI_CC: 255
Sending over the firmware image.
Find [0x1050 0x750]
bar0[0x94000000]
Upload to BMC 100% |Goooooooooooooooooooooooooooooooooooooooooooooooooooooooogle| Time: 00:00:00
Opening the verification file
Committing to /flash/verify to trigger service
Calling stat on /flash/verify session to check status
success
succeeded
```
Also tested gBMC Update workflow which worked fine.
Change-Id: Ib2bfeab0c2ec5aa72ede1ff457ef5f90e488053c
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/test/ipmi_getcount_unittest.cpp b/test/ipmi_getcount_unittest.cpp
index 34fc33d..dc1202d 100644
--- a/test/ipmi_getcount_unittest.cpp
+++ b/test/ipmi_getcount_unittest.cpp
@@ -1,3 +1,4 @@
+#include "helper.hpp"
#include "ipmi.hpp"
#include "manager_mock.hpp"
@@ -11,10 +12,6 @@
using ::testing::Return;
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
// the request here is only the subcommand byte and therefore there's no invalid
// length check, etc to handle within the method.
@@ -24,24 +21,17 @@
// return that there are 0 blobs.
ManagerMock mgr;
- size_t dataLen;
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
- struct BmcBlobCountTx req;
struct BmcBlobCountRx rep;
- uint8_t* request = reinterpret_cast<uint8_t*>(&req);
-
- req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount);
- dataLen = sizeof(req);
rep.crc = 0;
rep.blobCount = 0;
EXPECT_CALL(mgr, buildBlobList()).WillOnce(Return(0));
- EXPECT_EQ(IPMI_CC_OK, getBlobCount(&mgr, request, reply, &dataLen));
+ auto result = validateReply(getBlobCount(&mgr, {}));
- EXPECT_EQ(sizeof(rep), dataLen);
- EXPECT_EQ(0, std::memcmp(reply, &rep, sizeof(rep)));
+ EXPECT_EQ(sizeof(rep), result.size());
+ EXPECT_EQ(0, std::memcmp(result.data(), &rep, sizeof(rep)));
}
TEST(BlobCountTest, ReturnsTwoBlobs)
@@ -50,23 +40,16 @@
// blobs will return that it found two blobs.
ManagerMock mgr;
- size_t dataLen;
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
- struct BmcBlobCountTx req;
struct BmcBlobCountRx rep;
- uint8_t* request = reinterpret_cast<uint8_t*>(&req);
-
- req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount);
- dataLen = sizeof(req);
rep.crc = 0;
rep.blobCount = 2;
EXPECT_CALL(mgr, buildBlobList()).WillOnce(Return(2));
- EXPECT_EQ(IPMI_CC_OK, getBlobCount(&mgr, request, reply, &dataLen));
+ auto result = validateReply(getBlobCount(&mgr, {}));
- EXPECT_EQ(sizeof(rep), dataLen);
- EXPECT_EQ(0, std::memcmp(reply, &rep, sizeof(rep)));
+ EXPECT_EQ(sizeof(rep), result.size());
+ EXPECT_EQ(0, std::memcmp(result.data(), &rep, sizeof(rep)));
}
} // namespace blobs