1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
|