diff options
Diffstat (limited to 'test/ipmi_validate_unittest.cpp')
-rw-r--r-- | test/ipmi_validate_unittest.cpp | 44 |
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 |