blob: 3d575df355e0afb873c9a9e19aa0bf776fc1a9b8 [file] [log] [blame]
Willy Tua2056e92021-10-10 13:36:16 -07001// 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
Willy Tu3b1b4272021-03-02 17:58:10 -080015#include "commands.hpp"
16#include "flash_size.hpp"
17#include "handler_mock.hpp"
Willy Tuff3cd8e2021-09-14 22:49:55 -070018#include "helper.hpp"
Willy Tu3b1b4272021-03-02 17:58:10 -080019
20#include <cstdint>
21#include <cstring>
22#include <string>
23#include <vector>
24
25#include <gtest/gtest.h>
26
Willy Tu3b1b4272021-03-02 17:58:10 -080027using ::testing::Return;
28
29namespace google
30{
31namespace ipmi
32{
33
Willy Tu3b1b4272021-03-02 17:58:10 -080034TEST(FlashSizeCommandTest, ValidRequest)
35{
Willy Tuff3cd8e2021-09-14 22:49:55 -070036 std::vector<std::uint8_t> request = {};
Willy Tu3b1b4272021-03-02 17:58:10 -080037 uint32_t flashSize = 5422312; // 0x52BCE8
38
39 HandlerMock hMock;
40 EXPECT_CALL(hMock, getFlashSize()).WillOnce(Return(flashSize));
Willy Tuff3cd8e2021-09-14 22:49:55 -070041
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]);
Willy Tu3b1b4272021-03-02 17:58:10 -080052}
53
54} // namespace ipmi
55} // namespace google