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_unittest.cpp b/test/ipmi_unittest.cpp
index 8f27ed7..ed2f026 100644
--- a/test/ipmi_unittest.cpp
+++ b/test/ipmi_unittest.cpp
@@ -14,47 +14,37 @@
TEST(StringInputTest, NullPointerInput)
{
// The method should verify it did receive a non-null input pointer.
-
- EXPECT_STREQ("", stringFromBuffer(NULL, 5).c_str());
+ EXPECT_STREQ("", stringFromBuffer({}).c_str());
}
TEST(StringInputTest, ZeroBytesInput)
{
// Verify that if the input length is 0 that it'll return the empty string.
-
- const char* request = "asdf";
- EXPECT_STREQ("", stringFromBuffer(request, 0).c_str());
+ const std::string request = "asdf";
+ EXPECT_STREQ("", stringFromBuffer(
+ std::vector<uint8_t>(request.begin(), request.end()))
+ .c_str());
}
TEST(StringInputTest, NulTerminatorNotFound)
{
// Verify that if there isn't a nul-terminator found in an otherwise valid
// string, it'll return the emptry string.
-
- char request[MAX_IPMI_BUFFER];
- std::memset(request, 'a', sizeof(request));
- EXPECT_STREQ("", stringFromBuffer(request, sizeof(request)).c_str());
-}
-
-TEST(StringInputTest, TwoNulsFound)
-{
- // Verify it makes you use the entire data region for the string.
- char request[MAX_IPMI_BUFFER];
- request[0] = 'a';
- request[1] = 0;
- std::memset(&request[2], 'b', sizeof(request) - 2);
- request[MAX_IPMI_BUFFER - 1] = 0;
-
- // This case has two strings, and the last character is a nul-terminator.
- EXPECT_STREQ("", stringFromBuffer(request, sizeof(request)).c_str());
+ std::array<char, MAX_IPMI_BUFFER> request;
+ std::memset(request.data(), 'a', sizeof(request));
+ EXPECT_STREQ("", stringFromBuffer(
+ std::vector<uint8_t>(request.begin(), request.end()))
+ .c_str());
}
TEST(StringInputTest, NulTerminatorFound)
{
// Verify that if it's provided a valid nul-terminated string, it'll
// return it.
-
- const char* request = "asdf";
- EXPECT_STREQ("asdf", stringFromBuffer(request, 5).c_str());
+ std::string request = "asdf";
+ request.push_back('\0');
+ EXPECT_STREQ("asdf", stringFromBuffer(std::vector<uint8_t>(request.begin(),
+ request.end()))
+ .c_str());
}
} // namespace blobs