blob: d44e2e83fd77a666cc54c013b03b0f2a313d5133 [file] [log] [blame]
Bob King8e4cb642020-04-24 13:18:53 +08001/**
2 * Copyright © 2020 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "action_environment.hpp"
17#include "compare_vpd_action.hpp"
18#include "id_map.hpp"
19
20#include <exception>
21#include <memory>
22#include <stdexcept>
23#include <utility>
24
25#include <gtest/gtest.h>
26
27using namespace phosphor::power::regulators;
28
29TEST(CompareVPDActionTests, Constructor)
30{
Bob Kinga76898f2020-10-13 15:08:33 +080031 CompareVPDAction action{
32 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN",
33 "2D35"};
34 EXPECT_EQ(action.getFRU(),
35 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane");
Bob King8e4cb642020-04-24 13:18:53 +080036 EXPECT_EQ(action.getKeyword(), "CCIN");
37 EXPECT_EQ(action.getValue(), "2D35");
38}
39
40TEST(CompareVPDActionTests, Execute)
41{
42 // TODO: Not implemented yet
43}
44
45TEST(CompareVPDActionTests, GetFRU)
46{
Bob Kinga76898f2020-10-13 15:08:33 +080047 CompareVPDAction action{
48 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN",
49 "2D35"};
50 EXPECT_EQ(action.getFRU(),
51 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane");
Bob King8e4cb642020-04-24 13:18:53 +080052}
53
54TEST(CompareVPDActionTests, GetKeyword)
55{
Bob Kinga76898f2020-10-13 15:08:33 +080056 CompareVPDAction action{
57 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN",
58 "2D35"};
Bob King8e4cb642020-04-24 13:18:53 +080059 EXPECT_EQ(action.getKeyword(), "CCIN");
60}
61
62TEST(CompareVPDActionTests, GetValue)
63{
Bob Kinga76898f2020-10-13 15:08:33 +080064 CompareVPDAction action{
65 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN",
66 "2D35"};
Bob King8e4cb642020-04-24 13:18:53 +080067 EXPECT_EQ(action.getValue(), "2D35");
68}
69
70TEST(CompareVPDActionTests, ToString)
71{
Bob Kinga76898f2020-10-13 15:08:33 +080072 CompareVPDAction action{
73 "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN",
74 "2D35"};
75 EXPECT_EQ(action.toString(), "compare_vpd: { fru: "
76 "/xyz/openbmc_project/inventory/system/"
77 "chassis/disk_backplane, keyword: "
78 "CCIN, value: 2D35 }");
Bob King8e4cb642020-04-24 13:18:53 +080079}