1 // Copyright 2021 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "commands.hpp"
16 #include "flash_size.hpp"
17 #include "handler_mock.hpp"
18 #include "helper.hpp"
19
20 #include <cstdint>
21 #include <cstring>
22 #include <string>
23 #include <vector>
24
25 #include <gtest/gtest.h>
26
27 using ::testing::Return;
28
29 namespace google
30 {
31 namespace ipmi
32 {
33
TEST(FlashSizeCommandTest,ValidRequest)34 TEST(FlashSizeCommandTest, ValidRequest)
35 {
36 std::vector<std::uint8_t> request = {};
37 uint32_t flashSize = 5422312; // 0x52BCE8
38
39 HandlerMock hMock;
40 EXPECT_CALL(hMock, getFlashSize()).WillOnce(Return(flashSize));
41
42 auto reply = getFlashSize(request, &hMock);
43 auto result = ValidateReply(reply);
44 auto& data = result.second;
45
46 EXPECT_EQ(sizeof(struct GetFlashSizeReply), data.size());
47 EXPECT_EQ(SysOEMCommands::SysGetFlashSize, result.first);
48 EXPECT_EQ(0, data[3]);
49 EXPECT_EQ(0x52, data[2]);
50 EXPECT_EQ(0xBC, data[1]);
51 EXPECT_EQ(0xE8, data[0]);
52 }
53
54 } // namespace ipmi
55 } // namespace google
56