google-ipmi-sys: 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.

The input and output will be
`std::uint8_t, std::optional<std::vector<uint8_t>>`.

This represents `subcommand` and any input data.

Changes to note,
- all subcommand in the request/response struct are removed. It will be
  managed by the wrapper directly.
    - Unit tests checking for input with only the subcommand are
      removed.
- Move all reply struct to header files to be accessible in unit test.

Tested:
All IPMI OEM command still works the same as before this change.

Change-Id: I4230ab84a497a867248fe82224e32cc69b314b64
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/test/psu_unittest.cpp b/test/psu_unittest.cpp
index 257baad..a08f040 100644
--- a/test/psu_unittest.cpp
+++ b/test/psu_unittest.cpp
@@ -14,6 +14,7 @@
 
 #include "commands.hpp"
 #include "handler_mock.hpp"
+#include "helper.hpp"
 #include "psu.hpp"
 
 #include <cstdint>
@@ -22,8 +23,6 @@
 
 #include <gtest/gtest.h>
 
-#define MAX_IPMI_BUFFER 64
-
 using ::testing::Return;
 
 namespace google
@@ -33,58 +32,41 @@
 
 TEST(PsuCommandTest, InvalidRequestLength)
 {
-    std::vector<std::uint8_t> request = {SysOEMCommands::SysPsuHardReset};
-    size_t dataLen = request.size();
-    std::uint8_t reply[MAX_IPMI_BUFFER];
-
+    std::vector<std::uint8_t> request = {};
     HandlerMock hMock;
-    EXPECT_EQ(IPMI_CC_REQ_DATA_LEN_INVALID,
-              psuHardReset(request.data(), reply, &dataLen, &hMock));
+
+    EXPECT_EQ(::ipmi::responseReqDataLenInvalid(),
+              psuHardReset(request, &hMock));
 }
 
 TEST(PsuCommandTest, ValidRequest)
 {
-    std::uint32_t delayValue = 0x45;
+    std::uint8_t delayValue = 0x45;
     struct PsuResetRequest requestContents;
-    requestContents.subcommand = SysOEMCommands::SysPsuHardReset;
     requestContents.delay = delayValue;
-
     std::vector<std::uint8_t> request(sizeof(requestContents));
     std::memcpy(request.data(), &requestContents, sizeof(requestContents));
-    size_t dataLen = request.size();
-    std::uint8_t reply[MAX_IPMI_BUFFER];
 
     HandlerMock hMock;
     EXPECT_CALL(hMock, psuResetDelay(delayValue));
-    EXPECT_EQ(IPMI_CC_OK,
-              psuHardReset(request.data(), reply, &dataLen, &hMock));
-}
 
-TEST(PsuResetOnShutdownCommandTest, InvalidRequestLength)
-{
-    std::vector<std::uint8_t> request;
-    size_t dataLen = request.size();
-    std::uint8_t reply[MAX_IPMI_BUFFER];
+    auto reply = psuHardReset(request, &hMock);
+    auto result = ValidateReply(reply, /*hasData=*/false);
 
-    HandlerMock hMock;
-    EXPECT_EQ(IPMI_CC_REQ_DATA_LEN_INVALID,
-              psuHardResetOnShutdown(request.data(), reply, &dataLen, &hMock));
+    EXPECT_EQ(SysOEMCommands::SysPsuHardReset, result.first);
 }
 
 TEST(PsuResetOnShutdownCommandTest, ValidRequest)
 {
-    struct PsuResetOnShutdownRequest requestContents;
-    requestContents.subcommand = SysOEMCommands::SysPsuHardReset;
-
-    std::vector<std::uint8_t> request(sizeof(requestContents));
-    std::memcpy(request.data(), &requestContents, sizeof(requestContents));
-    size_t dataLen = request.size();
-    std::uint8_t reply[MAX_IPMI_BUFFER];
+    std::vector<std::uint8_t> request = {};
 
     HandlerMock hMock;
     EXPECT_CALL(hMock, psuResetOnShutdown());
-    EXPECT_EQ(IPMI_CC_OK,
-              psuHardResetOnShutdown(request.data(), reply, &dataLen, &hMock));
+
+    auto reply = psuHardResetOnShutdown(request, &hMock);
+    auto result = ValidateReply(reply, /*hasData=*/false);
+
+    EXPECT_EQ(SysOEMCommands::SysPsuHardResetOnShutdown, result.first);
 }
 
 } // namespace ipmi