diff options
author | Patrick Venture <venture@google.com> | 2019-05-20 19:11:04 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-05-20 19:24:10 -0700 |
commit | 444746495ad3f951cb093c7144b7cb9218b8599f (patch) | |
tree | 2ae893be5a4ad67f04ffb9f87170aefe8b1e0677 | |
parent | 99400c82a40d334cab04100a58a6b0aa74c21b0b (diff) | |
download | ipmi-blob-tool-444746495ad3f951cb093c7144b7cb9218b8599f.tar.gz ipmi-blob-tool-444746495ad3f951cb093c7144b7cb9218b8599f.zip |
move blob command enum to blob_interface header
Move the blob command enum to the blob_interface header that can be
safely included by other code.
Change-Id: If7c613cac9bdd460fc9a6cb3b59e4fc0dd3a861d
Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r-- | src/ipmiblob/blob_handler.cpp | 2 | ||||
-rw-r--r-- | src/ipmiblob/blob_handler.hpp | 15 | ||||
-rw-r--r-- | src/ipmiblob/blob_interface.hpp | 15 | ||||
-rw-r--r-- | test/tools_blob_unittest.cpp | 93 |
4 files changed, 78 insertions, 47 deletions
diff --git a/src/ipmiblob/blob_handler.cpp b/src/ipmiblob/blob_handler.cpp index 2b79e19..039b7e0 100644 --- a/src/ipmiblob/blob_handler.cpp +++ b/src/ipmiblob/blob_handler.cpp @@ -48,7 +48,7 @@ std::vector<std::uint8_t> std::copy(ipmiPhosphorOen.begin(), ipmiPhosphorOen.end(), std::back_inserter(request)); - request.push_back(command); + request.push_back(static_cast<std::uint8_t>(command)); if (payload.size() > 0) { diff --git a/src/ipmiblob/blob_handler.hpp b/src/ipmiblob/blob_handler.hpp index 5e24b91..68708d8 100644 --- a/src/ipmiblob/blob_handler.hpp +++ b/src/ipmiblob/blob_handler.hpp @@ -11,21 +11,6 @@ namespace ipmiblob class BlobHandler : public BlobInterface { public: - enum BlobOEMCommands - { - bmcBlobGetCount = 0, - bmcBlobEnumerate = 1, - bmcBlobOpen = 2, - bmcBlobRead = 3, - bmcBlobWrite = 4, - bmcBlobCommit = 5, - bmcBlobClose = 6, - bmcBlobDelete = 7, - bmcBlobStat = 8, - bmcBlobSessionStat = 9, - bmcBlobWriteMeta = 10, - }; - /** * Create a BlobInterface pointer for use given an ipmi handler. * diff --git a/src/ipmiblob/blob_interface.hpp b/src/ipmiblob/blob_interface.hpp index 26ca837..fbd8c6a 100644 --- a/src/ipmiblob/blob_interface.hpp +++ b/src/ipmiblob/blob_interface.hpp @@ -7,6 +7,21 @@ namespace ipmiblob { +enum class BlobOEMCommands : std::uint8_t +{ + bmcBlobGetCount = 0, + bmcBlobEnumerate = 1, + bmcBlobOpen = 2, + bmcBlobRead = 3, + bmcBlobWrite = 4, + bmcBlobCommit = 5, + bmcBlobClose = 6, + bmcBlobDelete = 7, + bmcBlobStat = 8, + bmcBlobSessionStat = 9, + bmcBlobWriteMeta = 10, +}; + struct StatResponse { std::uint16_t blob_state; diff --git a/test/tools_blob_unittest.cpp b/test/tools_blob_unittest.cpp index e9f2c96..3afb61b 100644 --- a/test/tools_blob_unittest.cpp +++ b/test/tools_blob_unittest.cpp @@ -44,7 +44,8 @@ TEST_F(BlobHandlerTest, getCountIpmiHappy) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobGetCount}; + 0xcf, 0xc2, 0x00, + static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount)}; /* return 1 blob count. */ std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, @@ -66,8 +67,10 @@ TEST_F(BlobHandlerTest, enumerateBlobIpmiHappy) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobEnumerate, - 0x00, 0x00, 0x01, 0x00, + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate), + 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00}; /* return value. */ @@ -92,8 +95,10 @@ TEST_F(BlobHandlerTest, enumerateBlobIpmiNoBytes) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobEnumerate, - 0x00, 0x00, 0x01, 0x00, + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate), + 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00}; /* return value. */ @@ -115,7 +120,8 @@ TEST_F(BlobHandlerTest, getBlobListIpmiHappy) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request1 = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobGetCount}; + 0xcf, 0xc2, 0x00, + static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount)}; /* return 1 blob count. */ std::vector<std::uint8_t> resp1 = {0xcf, 0xc2, 0x00, 0x00, 0x00, @@ -127,8 +133,10 @@ TEST_F(BlobHandlerTest, getBlobListIpmiHappy) EXPECT_CALL(*ipmiMock, sendPacket(Eq(request1))).WillOnce(Return(resp1)); std::vector<std::uint8_t> request2 = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobEnumerate, - 0x00, 0x00, 0x00, 0x00, + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate), + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; /* return value. */ @@ -157,9 +165,12 @@ TEST_F(BlobHandlerTest, getStatWithMetadata) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobStat, - 0x00, 0x00, 'a', 'b', - 'c', 'd', 0x00}; + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat), + 0x00, 0x00, + 'a', 'b', + 'c', 'd', + 0x00}; /* return blob_state: 0xffff, size: 0x00, metadata 0x3445 */ std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xff, 0xff, @@ -189,9 +200,12 @@ TEST_F(BlobHandlerTest, getStatNoMetadata) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobStat, - 0x00, 0x00, 'a', 'b', - 'c', 'd', 0x00}; + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat), + 0x00, 0x00, + 'a', 'b', + 'c', 'd', + 0x00}; /* return blob_state: 0xffff, size: 0x00, metadata 0x3445 */ std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xff, @@ -222,8 +236,10 @@ TEST_F(BlobHandlerTest, getSessionStatNoMetadata) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobSessionStat, - 0x00, 0x00, 0x01, 0x00}; + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobSessionStat), + 0x00, 0x00, + 0x01, 0x00}; /* return blob_state: 0xffff, size: 0x00, metadata 0x3445 */ std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xff, @@ -254,9 +270,12 @@ TEST_F(BlobHandlerTest, openBlobSucceeds) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobOpen, - 0x00, 0x00, 0x02, 0x04, - 'a', 'b', 'c', 'd', + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobOpen), + 0x00, 0x00, + 0x02, 0x04, + 'a', 'b', + 'c', 'd', 0x00}; std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xfe, 0xed}; @@ -284,8 +303,10 @@ TEST_F(BlobHandlerTest, closeBlobSucceeds) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobClose, - 0x00, 0x00, 0x01, 0x00}; + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobClose), + 0x00, 0x00, + 0x01, 0x00}; std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00}; std::vector<std::uint8_t> reqCrc = {0x01, 0x00}; EXPECT_CALL(crcMock, generateCrc(Eq(reqCrc))).WillOnce(Return(0x00)); @@ -304,8 +325,10 @@ TEST_F(BlobHandlerTest, commitSucceedsNoData) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobCommit, - 0x00, 0x00, 0x01, 0x00, + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobCommit), + 0x00, 0x00, + 0x01, 0x00, 0x00}; std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00}; @@ -326,10 +349,14 @@ TEST_F(BlobHandlerTest, writeBytesSucceeds) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobWrite, - 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, - 'a', 'b', 'c', 'd'}; + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite), + 0x00, 0x00, + 0x01, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 'a', 'b', + 'c', 'd'}; std::vector<std::uint8_t> bytes = {'a', 'b', 'c', 'd'}; std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00}; @@ -351,10 +378,14 @@ TEST_F(BlobHandlerTest, readBytesSucceeds) BlobHandler blob(std::move(ipmi)); std::vector<std::uint8_t> request = { - 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobRead, - 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00}; + 0xcf, 0xc2, + 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobRead), + 0x00, 0x00, + 0x01, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x04, 0x00, + 0x00, 0x00}; std::vector<std::uint8_t> expectedBytes = {'a', 'b', 'c', 'd'}; std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, |