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 | |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 8 | FruParser parser{"./fru_jsons/good"}; |
| 9 | |
| 10 | // Get an item with a single PLDM FRU record |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 11 | FruRecordInfos cpu{ |
| 12 | {1, |
| 13 | 1, |
| 14 | {{"xyz.openbmc_project.Inventory.Decorator.Asset", "Model", "string", |
| 15 | 2}, |
| 16 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "PartNumber", |
| 17 | "string", 3}, |
| 18 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "SerialNumber", |
| 19 | "string", 4}, |
| 20 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "Manufacturer", |
| 21 | "string", 5}, |
| 22 | {"xyz.openbmc_project.Inventory.Item", "PrettyName", "string", 8}, |
| 23 | {"xyz.openbmc_project.Inventory.Decorator.AssetTag", "AssetTag", |
| 24 | "string", 11}, |
| 25 | {"xyz.openbmc_project.Inventory.Decorator.Revision", "Version", |
| 26 | "string", 10}}}, |
| 27 | {1, |
| 28 | 1, |
| 29 | {{"xyz.openbmc_project.Inventory.Decorator.Asset", "PartNumber", |
| 30 | "string", 3}, |
| 31 | {"xyz.openbmc_project.Inventory.Decorator.Asset", "SerialNumber", |
| 32 | "string", 4}}}}; |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 33 | auto cpuInfos = |
| 34 | parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.Cpu"); |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 35 | ASSERT_EQ(cpuInfos.size(), 2); |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 36 | ASSERT_EQ(cpu == cpuInfos, true); |
| 37 | |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 38 | // Get an item type with 3 PLDM FRU records |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 39 | auto boardInfos = |
| 40 | parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.Board"); |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 41 | ASSERT_EQ(boardInfos.size(), 3); |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 42 | |
| 43 | // D-Bus lookup info for FRU information |
Deepak Kodihalli | da07960 | 2020-08-05 03:23:03 -0500 | [diff] [blame] | 44 | DBusLookupInfo lookupInfo{ |
| 45 | "xyz.openbmc_project.Inventory.Manager", |
| 46 | "/xyz/openbmc_project/inventory", |
| 47 | {"xyz.openbmc_project.Inventory.Item.Chassis", |
| 48 | "xyz.openbmc_project.Inventory.Item.Board", |
| 49 | "xyz.openbmc_project.Inventory.Item.Board.Motherboard", |
| 50 | "xyz.openbmc_project.Inventory.Item.Panel", |
| 51 | "xyz.openbmc_project.Inventory.Item.PowerSupply", |
| 52 | "xyz.openbmc_project.Inventory.Item.Vrm", |
| 53 | "xyz.openbmc_project.Inventory.Item.Cpu", |
| 54 | "xyz.openbmc_project.Inventory.Item.Bmc", |
| 55 | "xyz.openbmc_project.Inventory.Item.Dimm", |
| 56 | "xyz.openbmc_project.Inventory.Item.Tpm", |
| 57 | "xyz.openbmc_project.Inventory.Item.System"}}; |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 58 | auto dbusInfo = parser.inventoryLookup(); |
| 59 | ASSERT_EQ(dbusInfo == lookupInfo, true); |
| 60 | |
Tom Joseph | 151d533 | 2019-11-17 22:21:45 +0530 | [diff] [blame] | 61 | ASSERT_THROW( |
| 62 | parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.DIMM"), |
| 63 | std::exception); |
| 64 | } |