From ef3aeadc9be37c47d0627e576e81a74a5bb9e94f Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Wed, 12 Sep 2018 08:53:29 -0700 Subject: initial drop of phosphor-ipmi-blobs This implements a majority of the OEM IPMI BLOBS protocol. The only piece missing from this is the timed expiration of sessions. Change-Id: I82c9d17b625c94fc3340edcfabbbf1ffeb5ad7ac Signed-off-by: Patrick Venture --- test/ipmi_validate_unittest.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/ipmi_validate_unittest.cpp (limited to 'test/ipmi_validate_unittest.cpp') diff --git a/test/ipmi_validate_unittest.cpp b/test/ipmi_validate_unittest.cpp new file mode 100644 index 0000000..6bf4200 --- /dev/null +++ b/test/ipmi_validate_unittest.cpp @@ -0,0 +1,44 @@ +#include "ipmi.hpp" +#include "manager_mock.hpp" + +#include + +#include + +namespace blobs +{ + +TEST(IpmiValidateTest, VerifyCommandMinimumLengths) +{ + + struct TestCase + { + BlobOEMCommands cmd; + size_t len; + bool expect; + }; + + std::vector tests = { + {BlobOEMCommands::bmcBlobClose, sizeof(struct BmcBlobCloseTx) - 1, + false}, + {BlobOEMCommands::bmcBlobCommit, sizeof(struct BmcBlobCommitTx) - 1, + false}, + {BlobOEMCommands::bmcBlobDelete, sizeof(struct BmcBlobDeleteTx) + 1, + false}, + {BlobOEMCommands::bmcBlobEnumerate, + sizeof(struct BmcBlobEnumerateTx) - 1, false}, + {BlobOEMCommands::bmcBlobOpen, sizeof(struct BmcBlobOpenTx) + 1, false}, + {BlobOEMCommands::bmcBlobRead, sizeof(struct BmcBlobReadTx) - 1, false}, + {BlobOEMCommands::bmcBlobSessionStat, + sizeof(struct BmcBlobSessionStatTx) - 1, false}, + {BlobOEMCommands::bmcBlobStat, sizeof(struct BmcBlobStatTx) + 1, false}, + {BlobOEMCommands::bmcBlobWrite, sizeof(struct BmcBlobWriteTx), false}, + }; + + for (const auto& test : tests) + { + bool result = validateRequestLength(test.cmd, test.len); + EXPECT_EQ(result, test.expect); + } +} +} // namespace blobs -- cgit v1.2.3