summaryrefslogtreecommitdiffstats
path: root/test/ipmi_validate_unittest.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-09-12 08:53:29 -0700
committerPatrick Venture <venture@google.com>2018-09-15 13:11:30 -0700
commitef3aeadc9be37c47d0627e576e81a74a5bb9e94f (patch)
tree95c183977468b107bdd3faaaa988b5d853be2f00 /test/ipmi_validate_unittest.cpp
parentbaa73da1abaaf05ea1133319405fb2b891825618 (diff)
downloadphosphor-ipmi-blobs-ef3aeadc9be37c47d0627e576e81a74a5bb9e94f.tar.gz
phosphor-ipmi-blobs-ef3aeadc9be37c47d0627e576e81a74a5bb9e94f.zip
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 <venture@google.com>
Diffstat (limited to 'test/ipmi_validate_unittest.cpp')
-rw-r--r--test/ipmi_validate_unittest.cpp44
1 files changed, 44 insertions, 0 deletions
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 <vector>
+
+#include <gtest/gtest.h>
+
+namespace blobs
+{
+
+TEST(IpmiValidateTest, VerifyCommandMinimumLengths)
+{
+
+ struct TestCase
+ {
+ BlobOEMCommands cmd;
+ size_t len;
+ bool expect;
+ };
+
+ std::vector<TestCase> 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
OpenPOWER on IntegriCloud