blob: 6bf420034ec2b658ce0e262d40ee45124572cbec [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{
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