Bob King | 8e4cb64 | 2020-04-24 13:18:53 +0800 | [diff] [blame] | 1 | /** |
| 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 | |
| 27 | using namespace phosphor::power::regulators; |
| 28 | |
| 29 | TEST(CompareVPDActionTests, Constructor) |
| 30 | { |
Bob King | a76898f | 2020-10-13 15:08:33 +0800 | [diff] [blame] | 31 | 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 King | 8e4cb64 | 2020-04-24 13:18:53 +0800 | [diff] [blame] | 36 | EXPECT_EQ(action.getKeyword(), "CCIN"); |
| 37 | EXPECT_EQ(action.getValue(), "2D35"); |
| 38 | } |
| 39 | |
| 40 | TEST(CompareVPDActionTests, Execute) |
| 41 | { |
| 42 | // TODO: Not implemented yet |
| 43 | } |
| 44 | |
| 45 | TEST(CompareVPDActionTests, GetFRU) |
| 46 | { |
Bob King | a76898f | 2020-10-13 15:08:33 +0800 | [diff] [blame] | 47 | 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 King | 8e4cb64 | 2020-04-24 13:18:53 +0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | TEST(CompareVPDActionTests, GetKeyword) |
| 55 | { |
Bob King | a76898f | 2020-10-13 15:08:33 +0800 | [diff] [blame] | 56 | CompareVPDAction action{ |
| 57 | "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN", |
| 58 | "2D35"}; |
Bob King | 8e4cb64 | 2020-04-24 13:18:53 +0800 | [diff] [blame] | 59 | EXPECT_EQ(action.getKeyword(), "CCIN"); |
| 60 | } |
| 61 | |
| 62 | TEST(CompareVPDActionTests, GetValue) |
| 63 | { |
Bob King | a76898f | 2020-10-13 15:08:33 +0800 | [diff] [blame] | 64 | CompareVPDAction action{ |
| 65 | "/xyz/openbmc_project/inventory/system/chassis/disk_backplane", "CCIN", |
| 66 | "2D35"}; |
Bob King | 8e4cb64 | 2020-04-24 13:18:53 +0800 | [diff] [blame] | 67 | EXPECT_EQ(action.getValue(), "2D35"); |
| 68 | } |
| 69 | |
| 70 | TEST(CompareVPDActionTests, ToString) |
| 71 | { |
Bob King | a76898f | 2020-10-13 15:08:33 +0800 | [diff] [blame] | 72 | 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 King | 8e4cb64 | 2020-04-24 13:18:53 +0800 | [diff] [blame] | 79 | } |