blob: a0b5178b146703805521c799e849e80b9f003718 [file] [log] [blame]
Nikhil Namjoshi5e70dc82022-09-16 00:36:07 +00001// Copyright 2022 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 "bmc_mode.hpp"
16#include "commands.hpp"
17#include "handler_mock.hpp"
18#include "helper.hpp"
19
20#include <vector>
21
22#include <gtest/gtest.h>
23
24using ::testing::Return;
25
26namespace google
27{
28namespace ipmi
29{
30
31TEST(BmcModeCommandTest, ValidRequest)
32{
33 std::vector<std::uint8_t> request = {};
34 uint8_t bmcMode = 0; // Non Bare Metal Mode
35
36 HandlerMock hMock;
37 EXPECT_CALL(hMock, getBmcMode()).WillOnce(Return(bmcMode));
38
39 auto reply = getBmcMode(request, &hMock);
40 auto result = ValidateReply(reply);
41 auto& data = result.second;
42
43 EXPECT_EQ(1, data.size());
44 EXPECT_EQ(SysOEMCommands::SysGetBmcMode, result.first);
45 EXPECT_EQ(0, data[0]);
46
47 bmcMode = 1; // Bare Metal Mode
48
49 EXPECT_CALL(hMock, getBmcMode()).WillOnce(Return(bmcMode));
50
51 reply = getBmcMode(request, &hMock);
52 result = ValidateReply(reply);
53 data = result.second;
54
55 EXPECT_EQ(1, data.size());
56 EXPECT_EQ(SysOEMCommands::SysGetBmcMode, result.first);
57 EXPECT_EQ(1, data[0]);
58
59 bmcMode = 2; // Bare Metal Cleaning Mode
60
61 EXPECT_CALL(hMock, getBmcMode()).WillOnce(Return(bmcMode));
62
63 reply = getBmcMode(request, &hMock);
64 result = ValidateReply(reply);
65 data = result.second;
66
67 EXPECT_EQ(1, data.size());
68 EXPECT_EQ(SysOEMCommands::SysGetBmcMode, result.first);
69 EXPECT_EQ(2, data[0]);
70}
71
72} // namespace ipmi
73} // namespace google