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