Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 1 | #include "libpldmresponder/fru_parser.hpp" |
| 2 | |
| 3 | #include <gtest/gtest.h> |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 4 | TEST(FruParser, allScenarios) |
| 5 | { |
| 6 | using namespace pldm::responder::fru_parser; |
| 7 | |
Manojkiran Eda | 03b01ca | 2021-06-29 08:55:09 +0530 | [diff] [blame] | 8 | FruParser parser{"./fru_jsons/good", |
| 9 | "./fru_jsons/fru_master/fru_master.json"}; |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 10 | |
| 11 | // Get an item with a single PLDM FRU record |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 12 | FruRecordInfos cpu{ |
| 13 | {1, |
| 14 | 1, |
| 15 | {{"xyz.openbmc_project.Inventory.Decorator.Asset", "Model", "string", |
| 16 | 2}, |
| 17 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "PartNumber", |
| 18 | "string", 3}, |
| 19 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "SerialNumber", |
| 20 | "string", 4}, |
| 21 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "Manufacturer", |
| 22 | "string", 5}, |
| 23 | {"xyz.openbmc_project.Inventory.Item", "PrettyName", "string", 8}, |
| 24 | {"xyz.openbmc_project.Inventory.Decorator.AssetTag", "AssetTag", |
| 25 | "string", 11}, |
| 26 | {"xyz.openbmc_project.Inventory.Decorator.Revision", "Version", |
| 27 | "string", 10}}}, |
| 28 | {1, |
| 29 | 1, |
| 30 | {{"xyz.openbmc_project.Inventory.Decorator.Asset", "PartNumber", |
| 31 | "string", 3}, |
| 32 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "SerialNumber", |
| 33 | "string", 4}}}}; |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 34 | auto cpuInfos = |
| 35 | parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.Cpu"); |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 36 | ASSERT_EQ(cpuInfos.size(), 2); |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 37 | ASSERT_EQ(cpu == cpuInfos, true); |
| 38 | |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 39 | // Get an item type with 3 PLDM FRU records |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 40 | auto boardInfos = |
| 41 | parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.Board"); |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 42 | ASSERT_EQ(boardInfos.size(), 3); |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 43 | |
| 44 | // D-Bus lookup info for FRU information |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 45 | DBusLookupInfo lookupInfo{ |
| 46 | "xyz.openbmc_project.Inventory.Manager", |
| 47 | "/xyz/openbmc_project/inventory", |
| 48 | {"xyz.openbmc_project.Inventory.Item.Chassis", |
| 49 | "xyz.openbmc_project.Inventory.Item.Board", |
Jayashankar Padath | a137f90 | 2021-06-04 07:16:11 -0500 | [diff] [blame] | 50 | "xyz.openbmc_project.Inventory.Item.PCIeDevice", |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 51 | "xyz.openbmc_project.Inventory.Item.Board.Motherboard", |
Jayashankar Padath | a137f90 | 2021-06-04 07:16:11 -0500 | [diff] [blame] | 52 | "xyz.openbmc_project.Inventory.Item.Dimm", |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 53 | "xyz.openbmc_project.Inventory.Item.Panel", |
Jayashankar Padath | a137f90 | 2021-06-04 07:16:11 -0500 | [diff] [blame] | 54 | "xyz.openbmc_project.Inventory.Item.DiskBackplane", |
| 55 | "xyz.openbmc_project.Inventory.Item.Fan", |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 56 | "xyz.openbmc_project.Inventory.Item.PowerSupply", |
Jayashankar Padath | a137f90 | 2021-06-04 07:16:11 -0500 | [diff] [blame] | 57 | "xyz.openbmc_project.Inventory.Item.Battery", |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 58 | "xyz.openbmc_project.Inventory.Item.Vrm", |
| 59 | "xyz.openbmc_project.Inventory.Item.Cpu", |
| 60 | "xyz.openbmc_project.Inventory.Item.Bmc", |
Jayashankar Padath | a137f90 | 2021-06-04 07:16:11 -0500 | [diff] [blame] | 61 | "xyz.openbmc_project.Inventory.Item.Connector", |
| 62 | "xyz.openbmc_project.Inventory.Item.PCIeSlot", |
| 63 | "xyz.openbmc_project.Inventory.Item.System", |
| 64 | "xyz.openbmc_project.Inventory.Item.Tpm"}}; |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 65 | auto dbusInfo = parser.inventoryLookup(); |
| 66 | ASSERT_EQ(dbusInfo == lookupInfo, true); |
| 67 | |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 68 | ASSERT_THROW( |
| 69 | parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.DIMM"), |
| 70 | std::exception); |
| 71 | } |