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