14f0d1de6SSteve Foreman // Copyright 2022 Google LLC
24f0d1de6SSteve Foreman //
34f0d1de6SSteve Foreman // Licensed under the Apache License, Version 2.0 (the "License");
44f0d1de6SSteve Foreman // you may not use this file except in compliance with the License.
54f0d1de6SSteve Foreman // You may obtain a copy of the License at
64f0d1de6SSteve Foreman //
74f0d1de6SSteve Foreman //      http://www.apache.org/licenses/LICENSE-2.0
84f0d1de6SSteve Foreman //
94f0d1de6SSteve Foreman // Unless required by applicable law or agreed to in writing, software
104f0d1de6SSteve Foreman // distributed under the License is distributed on an "AS IS" BASIS,
114f0d1de6SSteve Foreman // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124f0d1de6SSteve Foreman // See the License for the specific language governing permissions and
134f0d1de6SSteve Foreman // limitations under the License.
144f0d1de6SSteve Foreman 
154f0d1de6SSteve Foreman #include "commands.hpp"
164f0d1de6SSteve Foreman #include "errors.hpp"
174f0d1de6SSteve Foreman #include "google_accel_oob.hpp"
184f0d1de6SSteve Foreman #include "handler_mock.hpp"
194f0d1de6SSteve Foreman 
204f0d1de6SSteve Foreman #include <ipmid/api.h>
214f0d1de6SSteve Foreman 
224f0d1de6SSteve Foreman #include <gtest/gtest.h>
234f0d1de6SSteve Foreman 
244f0d1de6SSteve Foreman namespace google
254f0d1de6SSteve Foreman {
264f0d1de6SSteve Foreman namespace ipmi
274f0d1de6SSteve Foreman {
284f0d1de6SSteve Foreman 
29*d455bfd6SGaurav Gandhi using ::testing::_;
304f0d1de6SSteve Foreman using ::testing::Return;
314f0d1de6SSteve Foreman 
TEST(GoogleAccelOobTest,DeviceCount_Success)324f0d1de6SSteve Foreman TEST(GoogleAccelOobTest, DeviceCount_Success)
334f0d1de6SSteve Foreman {
344f0d1de6SSteve Foreman     ::testing::StrictMock<HandlerMock> h;
354f0d1de6SSteve Foreman 
364f0d1de6SSteve Foreman     uint8_t reqBuf[1]; // Could be 0, but zero-length arrays are an extension
374f0d1de6SSteve Foreman 
384f0d1de6SSteve Foreman     struct Reply
394f0d1de6SSteve Foreman     {
404f0d1de6SSteve Foreman         uint32_t count;
414f0d1de6SSteve Foreman     } __attribute__((packed));
424f0d1de6SSteve Foreman 
434f0d1de6SSteve Foreman     constexpr uint32_t kTestDeviceCount = 2;
444f0d1de6SSteve Foreman 
454f0d1de6SSteve Foreman     EXPECT_CALL(h, accelOobDeviceCount()).WillOnce(Return(kTestDeviceCount));
464f0d1de6SSteve Foreman 
474f0d1de6SSteve Foreman     Resp r = accelOobDeviceCount(reqBuf, &h);
484f0d1de6SSteve Foreman 
494f0d1de6SSteve Foreman     const auto response = std::get<0>(r);
504f0d1de6SSteve Foreman     EXPECT_EQ(response, IPMI_CC_OK);
514f0d1de6SSteve Foreman 
524f0d1de6SSteve Foreman     const auto payload = std::get<1>(r);
534f0d1de6SSteve Foreman     ASSERT_EQ(payload.has_value(), true);
544f0d1de6SSteve Foreman     const auto payload_tuple = payload.value();
554f0d1de6SSteve Foreman     const auto reply_cmd = std::get<0>(payload_tuple);
564f0d1de6SSteve Foreman     EXPECT_EQ(reply_cmd, SysAccelOobDeviceCount);
574f0d1de6SSteve Foreman     const auto reply_buff = std::get<1>(payload_tuple);
584f0d1de6SSteve Foreman     ASSERT_EQ(reply_buff.size(), sizeof(Reply));
594f0d1de6SSteve Foreman 
604f0d1de6SSteve Foreman     auto* reply = reinterpret_cast<const Reply*>(reply_buff.data());
614f0d1de6SSteve Foreman     EXPECT_EQ(reply->count, kTestDeviceCount);
624f0d1de6SSteve Foreman }
634f0d1de6SSteve Foreman 
TEST(GoogleAccelOobTest,DeviceName_Success)644f0d1de6SSteve Foreman TEST(GoogleAccelOobTest, DeviceName_Success)
654f0d1de6SSteve Foreman {
664f0d1de6SSteve Foreman     ::testing::StrictMock<HandlerMock> h;
674f0d1de6SSteve Foreman 
684f0d1de6SSteve Foreman     struct Request
694f0d1de6SSteve Foreman     {
704f0d1de6SSteve Foreman         uint32_t index;
714f0d1de6SSteve Foreman     } __attribute__((packed));
724f0d1de6SSteve Foreman 
734f0d1de6SSteve Foreman     struct Reply
744f0d1de6SSteve Foreman     {
754f0d1de6SSteve Foreman         uint32_t index;
764f0d1de6SSteve Foreman         uint8_t length;
774f0d1de6SSteve Foreman         char name[1];
784f0d1de6SSteve Foreman     } __attribute__((packed));
794f0d1de6SSteve Foreman 
804f0d1de6SSteve Foreman     constexpr uint32_t kTestDeviceIndex = 0;
814f0d1de6SSteve Foreman     const std::string kTestDeviceName("testDeviceName");
824f0d1de6SSteve Foreman 
834f0d1de6SSteve Foreman     EXPECT_CALL(h, accelOobDeviceName(kTestDeviceIndex))
844f0d1de6SSteve Foreman         .WillOnce(Return(kTestDeviceName));
854f0d1de6SSteve Foreman 
864f0d1de6SSteve Foreman     Request reqBuf{kTestDeviceIndex};
874f0d1de6SSteve Foreman     Resp r = accelOobDeviceName(
884f0d1de6SSteve Foreman         std::span(reinterpret_cast<const uint8_t*>(&reqBuf), sizeof(Request)),
894f0d1de6SSteve Foreman         &h);
904f0d1de6SSteve Foreman 
914f0d1de6SSteve Foreman     const auto response = std::get<0>(r);
924f0d1de6SSteve Foreman     EXPECT_EQ(response, IPMI_CC_OK);
934f0d1de6SSteve Foreman 
944f0d1de6SSteve Foreman     const auto payload = std::get<1>(r);
954f0d1de6SSteve Foreman     ASSERT_EQ(payload.has_value(), true);
964f0d1de6SSteve Foreman     const auto payload_tuple = payload.value();
974f0d1de6SSteve Foreman     const auto reply_cmd = std::get<0>(payload_tuple);
984f0d1de6SSteve Foreman     EXPECT_EQ(reply_cmd, SysAccelOobDeviceName);
994f0d1de6SSteve Foreman     const auto reply_buff = std::get<1>(payload_tuple);
1004f0d1de6SSteve Foreman     ASSERT_GE(reply_buff.size(), sizeof(Reply));
1014f0d1de6SSteve Foreman 
1024f0d1de6SSteve Foreman     auto* reply = reinterpret_cast<const Reply*>(reply_buff.data());
1034f0d1de6SSteve Foreman     EXPECT_EQ(reply->index, kTestDeviceIndex);
1044f0d1de6SSteve Foreman     EXPECT_EQ(reply->length, kTestDeviceName.length());
1054f0d1de6SSteve Foreman     EXPECT_STREQ(reply->name, kTestDeviceName.c_str());
1064f0d1de6SSteve Foreman }
1074f0d1de6SSteve Foreman 
TEST(GoogleAccelOobTest,Read_Success)1084f0d1de6SSteve Foreman TEST(GoogleAccelOobTest, Read_Success)
1094f0d1de6SSteve Foreman {
1104f0d1de6SSteve Foreman     ::testing::StrictMock<HandlerMock> h;
1114f0d1de6SSteve Foreman 
1124f0d1de6SSteve Foreman     constexpr char kTestDeviceName[] = "testDeviceName";
1134f0d1de6SSteve Foreman     constexpr uint8_t kTestDeviceNameLength =
1144f0d1de6SSteve Foreman         (sizeof(kTestDeviceName) / sizeof(*kTestDeviceName)) - 1;
1154f0d1de6SSteve Foreman     constexpr uint8_t kTestToken = 0xAB;
1164f0d1de6SSteve Foreman     constexpr uint64_t kTestAddress = 0;
1174f0d1de6SSteve Foreman     constexpr uint8_t kTestReadSize = 8;
1184f0d1de6SSteve Foreman     constexpr uint64_t kTestData = 0x12345678;
1194f0d1de6SSteve Foreman 
1204f0d1de6SSteve Foreman     struct Request
1214f0d1de6SSteve Foreman     {
1224f0d1de6SSteve Foreman         uint8_t nameLength;
1234f0d1de6SSteve Foreman         char name[kTestDeviceNameLength];
1244f0d1de6SSteve Foreman         uint8_t token;
1254f0d1de6SSteve Foreman         uint64_t address;
1264f0d1de6SSteve Foreman         uint8_t num_bytes;
1274f0d1de6SSteve Foreman     } __attribute__((packed));
1284f0d1de6SSteve Foreman 
1294f0d1de6SSteve Foreman     struct Reply
1304f0d1de6SSteve Foreman     {
1314f0d1de6SSteve Foreman         uint8_t nameLength;
1324f0d1de6SSteve Foreman         char name[kTestDeviceNameLength];
1334f0d1de6SSteve Foreman         uint8_t token;
1344f0d1de6SSteve Foreman         uint64_t address;
1354f0d1de6SSteve Foreman         uint8_t num_bytes;
1364f0d1de6SSteve Foreman         uint64_t data;
1374f0d1de6SSteve Foreman     } __attribute__((packed));
1384f0d1de6SSteve Foreman 
1394f0d1de6SSteve Foreman     const std::string_view kTestDeviceNameStr(kTestDeviceName,
1404f0d1de6SSteve Foreman                                               kTestDeviceNameLength);
1414f0d1de6SSteve Foreman     EXPECT_CALL(h,
1424f0d1de6SSteve Foreman                 accelOobRead(kTestDeviceNameStr, kTestAddress, kTestReadSize))
1434f0d1de6SSteve Foreman         .WillOnce(Return(kTestData));
1444f0d1de6SSteve Foreman 
1454f0d1de6SSteve Foreman     Request reqBuf{kTestDeviceNameLength, "", kTestToken, kTestAddress,
1464f0d1de6SSteve Foreman                    kTestReadSize};
1474f0d1de6SSteve Foreman     memcpy(reqBuf.name, kTestDeviceName, kTestDeviceNameLength);
1484f0d1de6SSteve Foreman     Resp r = accelOobRead(
1494f0d1de6SSteve Foreman         std::span(reinterpret_cast<const uint8_t*>(&reqBuf), sizeof(Request)),
1504f0d1de6SSteve Foreman         &h);
1514f0d1de6SSteve Foreman 
1524f0d1de6SSteve Foreman     const auto response = std::get<0>(r);
1534f0d1de6SSteve Foreman     EXPECT_EQ(response, IPMI_CC_OK);
1544f0d1de6SSteve Foreman 
1554f0d1de6SSteve Foreman     const auto payload = std::get<1>(r);
1564f0d1de6SSteve Foreman     ASSERT_EQ(payload.has_value(), true);
1574f0d1de6SSteve Foreman     const auto payload_tuple = payload.value();
1584f0d1de6SSteve Foreman     const auto reply_cmd = std::get<0>(payload_tuple);
1594f0d1de6SSteve Foreman     EXPECT_EQ(reply_cmd, SysAccelOobRead);
1604f0d1de6SSteve Foreman     const auto reply_buff = std::get<1>(payload_tuple);
1614f0d1de6SSteve Foreman     ASSERT_GE(reply_buff.size(), sizeof(Reply));
1624f0d1de6SSteve Foreman 
1634f0d1de6SSteve Foreman     auto* reply = reinterpret_cast<const Reply*>(reply_buff.data());
1644f0d1de6SSteve Foreman     EXPECT_EQ(reply->nameLength, kTestDeviceNameLength);
1654f0d1de6SSteve Foreman     EXPECT_EQ(std::string_view(reply->name, reply->nameLength),
1664f0d1de6SSteve Foreman               kTestDeviceNameStr);
1674f0d1de6SSteve Foreman     EXPECT_EQ(reply->token, kTestToken);
1684f0d1de6SSteve Foreman     EXPECT_EQ(reply->address, kTestAddress);
1694f0d1de6SSteve Foreman     EXPECT_EQ(reply->num_bytes, kTestReadSize);
1704f0d1de6SSteve Foreman     EXPECT_EQ(reply->data, kTestData);
1714f0d1de6SSteve Foreman }
1724f0d1de6SSteve Foreman 
TEST(GoogleAccelOobTest,Write_Success)1734f0d1de6SSteve Foreman TEST(GoogleAccelOobTest, Write_Success)
1744f0d1de6SSteve Foreman {
1754f0d1de6SSteve Foreman     ::testing::StrictMock<HandlerMock> h;
1764f0d1de6SSteve Foreman 
1774f0d1de6SSteve Foreman     constexpr char kTestDeviceName[] = "testDeviceName";
1784f0d1de6SSteve Foreman     constexpr uint8_t kTestDeviceNameLength =
1794f0d1de6SSteve Foreman         (sizeof(kTestDeviceName) / sizeof(*kTestDeviceName)) - 1;
1804f0d1de6SSteve Foreman     constexpr uint8_t kTestToken = 0xAB;
1814f0d1de6SSteve Foreman     constexpr uint64_t kTestAddress = 0;
1824f0d1de6SSteve Foreman     constexpr uint8_t kTestWriteSize = 8;
1834f0d1de6SSteve Foreman     constexpr uint64_t kTestData = 0x12345678;
1844f0d1de6SSteve Foreman 
1854f0d1de6SSteve Foreman     struct Request
1864f0d1de6SSteve Foreman     {
1874f0d1de6SSteve Foreman         uint8_t nameLength;
1884f0d1de6SSteve Foreman         char name[kTestDeviceNameLength];
1894f0d1de6SSteve Foreman         uint8_t token;
1904f0d1de6SSteve Foreman         uint64_t address;
1914f0d1de6SSteve Foreman         uint8_t num_bytes;
1924f0d1de6SSteve Foreman         uint64_t data;
1934f0d1de6SSteve Foreman     } __attribute__((packed));
1944f0d1de6SSteve Foreman 
1954f0d1de6SSteve Foreman     struct Reply
1964f0d1de6SSteve Foreman     {
1974f0d1de6SSteve Foreman         uint8_t nameLength;
1984f0d1de6SSteve Foreman         char name[kTestDeviceNameLength];
1994f0d1de6SSteve Foreman         uint8_t token;
2004f0d1de6SSteve Foreman         uint64_t address;
2014f0d1de6SSteve Foreman         uint8_t num_bytes;
2024f0d1de6SSteve Foreman         uint64_t data;
2034f0d1de6SSteve Foreman     } __attribute__((packed));
2044f0d1de6SSteve Foreman 
2054f0d1de6SSteve Foreman     const std::string_view kTestDeviceNameStr(kTestDeviceName,
2064f0d1de6SSteve Foreman                                               kTestDeviceNameLength);
2074f0d1de6SSteve Foreman     EXPECT_CALL(h, accelOobWrite(kTestDeviceNameStr, kTestAddress,
2084f0d1de6SSteve Foreman                                  kTestWriteSize, kTestData))
2094f0d1de6SSteve Foreman         .WillOnce(Return());
2104f0d1de6SSteve Foreman 
2114f0d1de6SSteve Foreman     Request reqBuf{kTestDeviceNameLength, "",       kTestToken, kTestAddress,
2124f0d1de6SSteve Foreman                    kTestWriteSize,        kTestData};
2134f0d1de6SSteve Foreman     memcpy(reqBuf.name, kTestDeviceName, kTestDeviceNameLength);
2144f0d1de6SSteve Foreman     Resp r = accelOobWrite(
2154f0d1de6SSteve Foreman         std::span(reinterpret_cast<const uint8_t*>(&reqBuf), sizeof(Request)),
2164f0d1de6SSteve Foreman         &h);
2174f0d1de6SSteve Foreman 
2184f0d1de6SSteve Foreman     const auto response = std::get<0>(r);
2194f0d1de6SSteve Foreman     EXPECT_EQ(response, IPMI_CC_OK);
2204f0d1de6SSteve Foreman 
2214f0d1de6SSteve Foreman     const auto payload = std::get<1>(r);
2224f0d1de6SSteve Foreman     ASSERT_EQ(payload.has_value(), true);
2234f0d1de6SSteve Foreman     const auto payload_tuple = payload.value();
2244f0d1de6SSteve Foreman     const auto reply_cmd = std::get<0>(payload_tuple);
2254f0d1de6SSteve Foreman     EXPECT_EQ(reply_cmd, SysAccelOobWrite);
2264f0d1de6SSteve Foreman     const auto reply_buff = std::get<1>(payload_tuple);
2274f0d1de6SSteve Foreman     ASSERT_GE(reply_buff.size(), sizeof(Reply));
2284f0d1de6SSteve Foreman 
2294f0d1de6SSteve Foreman     auto* reply = reinterpret_cast<const Reply*>(reply_buff.data());
2304f0d1de6SSteve Foreman     EXPECT_EQ(reply->nameLength, kTestDeviceNameLength);
2314f0d1de6SSteve Foreman     EXPECT_EQ(std::string_view(reply->name, reply->nameLength),
2324f0d1de6SSteve Foreman               kTestDeviceNameStr);
2334f0d1de6SSteve Foreman     EXPECT_EQ(reply->token, kTestToken);
2344f0d1de6SSteve Foreman     EXPECT_EQ(reply->address, kTestAddress);
2354f0d1de6SSteve Foreman     EXPECT_EQ(reply->num_bytes, kTestWriteSize);
2364f0d1de6SSteve Foreman     EXPECT_EQ(reply->data, kTestData);
2374f0d1de6SSteve Foreman }
2384f0d1de6SSteve Foreman 
TEST(GoogleAccelOobTest,SetVrSettings_Success)239*d455bfd6SGaurav Gandhi TEST(GoogleAccelOobTest, SetVrSettings_Success)
240*d455bfd6SGaurav Gandhi {
241*d455bfd6SGaurav Gandhi     ::testing::StrictMock<HandlerMock> h;
242*d455bfd6SGaurav Gandhi     constexpr uint8_t kChipId = 2;
243*d455bfd6SGaurav Gandhi     constexpr uint8_t kSettingsId = 1;
244*d455bfd6SGaurav Gandhi     constexpr uint16_t kTestValue = 0xAABB;
245*d455bfd6SGaurav Gandhi 
246*d455bfd6SGaurav Gandhi     std::vector<uint8_t> testData = {kChipId, kSettingsId, 0xBB, 0xAA};
247*d455bfd6SGaurav Gandhi 
248*d455bfd6SGaurav Gandhi     EXPECT_CALL(h, accelSetVrSettings(_, kChipId, kSettingsId, kTestValue))
249*d455bfd6SGaurav Gandhi         .WillOnce(Return());
250*d455bfd6SGaurav Gandhi 
251*d455bfd6SGaurav Gandhi     Resp r = accelSetVrSettings(nullptr, testData, &h);
252*d455bfd6SGaurav Gandhi 
253*d455bfd6SGaurav Gandhi     const auto response = std::get<0>(r);
254*d455bfd6SGaurav Gandhi     EXPECT_EQ(response, IPMI_CC_OK);
255*d455bfd6SGaurav Gandhi 
256*d455bfd6SGaurav Gandhi     const auto payload = std::get<1>(r);
257*d455bfd6SGaurav Gandhi     ASSERT_EQ(payload.has_value(), true);
258*d455bfd6SGaurav Gandhi     const auto payload_tuple = payload.value();
259*d455bfd6SGaurav Gandhi     const auto reply_cmd = std::get<0>(payload_tuple);
260*d455bfd6SGaurav Gandhi     EXPECT_EQ(reply_cmd, SysSetAccelVrSettings);
261*d455bfd6SGaurav Gandhi     const auto reply_buff = std::get<1>(payload_tuple);
262*d455bfd6SGaurav Gandhi     ASSERT_EQ(reply_buff.size(), 0);
263*d455bfd6SGaurav Gandhi }
264*d455bfd6SGaurav Gandhi 
TEST(GoogleAccelOobTest,SetVrSettings_HandleIncorrectDataSize)265*d455bfd6SGaurav Gandhi TEST(GoogleAccelOobTest, SetVrSettings_HandleIncorrectDataSize)
266*d455bfd6SGaurav Gandhi {
267*d455bfd6SGaurav Gandhi     ::testing::StrictMock<HandlerMock> h;
268*d455bfd6SGaurav Gandhi     constexpr uint8_t kChipId = 2;
269*d455bfd6SGaurav Gandhi     uint8_t kSettingsId = 1;
270*d455bfd6SGaurav Gandhi 
271*d455bfd6SGaurav Gandhi     std::vector<uint8_t> testData = {kChipId, kSettingsId};
272*d455bfd6SGaurav Gandhi 
273*d455bfd6SGaurav Gandhi     EXPECT_CALL(h, accelSetVrSettings(_, _, _, _)).Times(0);
274*d455bfd6SGaurav Gandhi 
275*d455bfd6SGaurav Gandhi     Resp r = accelSetVrSettings(nullptr, testData, &h);
276*d455bfd6SGaurav Gandhi 
277*d455bfd6SGaurav Gandhi     const auto response = std::get<0>(r);
278*d455bfd6SGaurav Gandhi     EXPECT_EQ(response, IPMI_CC_REQ_DATA_LEN_INVALID);
279*d455bfd6SGaurav Gandhi 
280*d455bfd6SGaurav Gandhi     const auto payload = std::get<1>(r);
281*d455bfd6SGaurav Gandhi     ASSERT_EQ(payload.has_value(), false);
282*d455bfd6SGaurav Gandhi }
283*d455bfd6SGaurav Gandhi 
TEST(GoogleAccelOobTest,GetVrSettings_Success)284*d455bfd6SGaurav Gandhi TEST(GoogleAccelOobTest, GetVrSettings_Success)
285*d455bfd6SGaurav Gandhi {
286*d455bfd6SGaurav Gandhi     ::testing::StrictMock<HandlerMock> h;
287*d455bfd6SGaurav Gandhi     constexpr uint8_t kChipId = 3;
288*d455bfd6SGaurav Gandhi     constexpr uint8_t kSettingsId = 2;
289*d455bfd6SGaurav Gandhi 
290*d455bfd6SGaurav Gandhi     std::vector<uint8_t> testData = {kChipId, kSettingsId};
291*d455bfd6SGaurav Gandhi 
292*d455bfd6SGaurav Gandhi     EXPECT_CALL(h, accelGetVrSettings(_, kChipId, kSettingsId))
293*d455bfd6SGaurav Gandhi         .WillOnce(Return(0xAABB));
294*d455bfd6SGaurav Gandhi 
295*d455bfd6SGaurav Gandhi     Resp r = accelGetVrSettings(nullptr, testData, &h);
296*d455bfd6SGaurav Gandhi 
297*d455bfd6SGaurav Gandhi     const auto response = std::get<0>(r);
298*d455bfd6SGaurav Gandhi     EXPECT_EQ(response, IPMI_CC_OK);
299*d455bfd6SGaurav Gandhi 
300*d455bfd6SGaurav Gandhi     const auto payload = std::get<1>(r);
301*d455bfd6SGaurav Gandhi     ASSERT_EQ(payload.has_value(), true);
302*d455bfd6SGaurav Gandhi     const auto payload_tuple = payload.value();
303*d455bfd6SGaurav Gandhi     const auto reply_cmd = std::get<0>(payload_tuple);
304*d455bfd6SGaurav Gandhi     EXPECT_EQ(reply_cmd, SysGetAccelVrSettings);
305*d455bfd6SGaurav Gandhi     const auto reply_buff = std::get<1>(payload_tuple);
306*d455bfd6SGaurav Gandhi     ASSERT_EQ(reply_buff.size(), 2);
307*d455bfd6SGaurav Gandhi 
308*d455bfd6SGaurav Gandhi     EXPECT_EQ(reply_buff.at(0), 0xBB);
309*d455bfd6SGaurav Gandhi     EXPECT_EQ(reply_buff.at(1), 0xAA);
310*d455bfd6SGaurav Gandhi }
311*d455bfd6SGaurav Gandhi 
TEST(GoogleAccelOobTest,GetVrSettings_HandleIncorrectDataSize)312*d455bfd6SGaurav Gandhi TEST(GoogleAccelOobTest, GetVrSettings_HandleIncorrectDataSize)
313*d455bfd6SGaurav Gandhi {
314*d455bfd6SGaurav Gandhi     ::testing::StrictMock<HandlerMock> h;
315*d455bfd6SGaurav Gandhi     constexpr uint8_t kChipId = 2;
316*d455bfd6SGaurav Gandhi     uint8_t kSettingsId = 1;
317*d455bfd6SGaurav Gandhi 
318*d455bfd6SGaurav Gandhi     std::vector<uint8_t> testData = {kChipId, kSettingsId, 0xCC};
319*d455bfd6SGaurav Gandhi 
320*d455bfd6SGaurav Gandhi     EXPECT_CALL(h, accelGetVrSettings(_, _, _)).Times(0);
321*d455bfd6SGaurav Gandhi 
322*d455bfd6SGaurav Gandhi     Resp r = accelGetVrSettings(nullptr, testData, &h);
323*d455bfd6SGaurav Gandhi 
324*d455bfd6SGaurav Gandhi     const auto response = std::get<0>(r);
325*d455bfd6SGaurav Gandhi     EXPECT_EQ(response, IPMI_CC_REQ_DATA_LEN_INVALID);
326*d455bfd6SGaurav Gandhi 
327*d455bfd6SGaurav Gandhi     const auto payload = std::get<1>(r);
328*d455bfd6SGaurav Gandhi     ASSERT_EQ(payload.has_value(), false);
329*d455bfd6SGaurav Gandhi }
3304f0d1de6SSteve Foreman } // namespace ipmi
3314f0d1de6SSteve Foreman } // namespace google
332