1 #include "helper.hpp" 2 #include "ipmi.hpp" 3 #include "manager_mock.hpp" 4 5 #include <cstring> 6 #include <vector> 7 8 #include <gtest/gtest.h> 9 10 namespace blobs 11 { 12 13 using ::testing::Return; 14 15 // the request here is only the subcommand byte and therefore there's no invalid 16 // length check, etc to handle within the method. 17 18 TEST(BlobCountTest, ReturnsZeroBlobs) 19 { 20 // Calling BmcBlobGetCount if there are no handlers registered should just 21 // return that there are 0 blobs. 22 23 ManagerMock mgr; 24 struct BmcBlobCountRx rep; 25 26 rep.crc = 0; 27 rep.blobCount = 0; 28 29 EXPECT_CALL(mgr, buildBlobList()).WillOnce(Return(0)); 30 31 auto result = validateReply(getBlobCount(&mgr, {})); 32 33 EXPECT_EQ(sizeof(rep), result.size()); 34 EXPECT_EQ(0, std::memcmp(result.data(), &rep, sizeof(rep))); 35 } 36 37 TEST(BlobCountTest, ReturnsTwoBlobs) 38 { 39 // Calling BmcBlobGetCount with one handler registered that knows of two 40 // blobs will return that it found two blobs. 41 42 ManagerMock mgr; 43 struct BmcBlobCountRx rep; 44 45 rep.crc = 0; 46 rep.blobCount = 2; 47 48 EXPECT_CALL(mgr, buildBlobList()).WillOnce(Return(2)); 49 50 auto result = validateReply(getBlobCount(&mgr, {})); 51 52 EXPECT_EQ(sizeof(rep), result.size()); 53 EXPECT_EQ(0, std::memcmp(result.data(), &rep, sizeof(rep))); 54 } 55 } // namespace blobs 56