Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 1 | #include "ipmi.hpp" |
Patrick Venture | cd8dab4 | 2019-01-15 19:57:38 -0800 | [diff] [blame] | 2 | #include "manager_mock.hpp" |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 3 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 4 | #include <vector> |
| 5 | |
| 6 | #include <gtest/gtest.h> |
| 7 | |
| 8 | namespace blobs |
| 9 | { |
| 10 | |
| 11 | TEST(IpmiValidateTest, VerifyCommandMinimumLengths) |
| 12 | { |
| 13 | |
| 14 | struct TestCase |
| 15 | { |
| 16 | BlobOEMCommands cmd; |
| 17 | size_t len; |
| 18 | bool expect; |
| 19 | }; |
| 20 | |
| 21 | std::vector<TestCase> tests = { |
| 22 | {BlobOEMCommands::bmcBlobClose, sizeof(struct BmcBlobCloseTx) - 1, |
| 23 | false}, |
| 24 | {BlobOEMCommands::bmcBlobCommit, sizeof(struct BmcBlobCommitTx) - 1, |
| 25 | false}, |
| 26 | {BlobOEMCommands::bmcBlobDelete, sizeof(struct BmcBlobDeleteTx) + 1, |
| 27 | false}, |
| 28 | {BlobOEMCommands::bmcBlobEnumerate, |
| 29 | sizeof(struct BmcBlobEnumerateTx) - 1, false}, |
| 30 | {BlobOEMCommands::bmcBlobOpen, sizeof(struct BmcBlobOpenTx) + 1, false}, |
| 31 | {BlobOEMCommands::bmcBlobRead, sizeof(struct BmcBlobReadTx) - 1, false}, |
| 32 | {BlobOEMCommands::bmcBlobSessionStat, |
| 33 | sizeof(struct BmcBlobSessionStatTx) - 1, false}, |
| 34 | {BlobOEMCommands::bmcBlobStat, sizeof(struct BmcBlobStatTx) + 1, false}, |
| 35 | {BlobOEMCommands::bmcBlobWrite, sizeof(struct BmcBlobWriteTx), false}, |
| 36 | }; |
| 37 | |
| 38 | for (const auto& test : tests) |
| 39 | { |
| 40 | bool result = validateRequestLength(test.cmd, test.len); |
| 41 | EXPECT_EQ(result, test.expect); |
| 42 | } |
| 43 | } |
| 44 | } // namespace blobs |