FRU Parsing for platform specific config files

This patch adds the parsing for the platform specific config
files need to build the PLDM FRU records. The BMC FRU info is
populated in the D-Bus inventory namespace and these config JSON's
provide the necessary mapping to translate D-Bus properties into
PLDM record information.

Change-Id: I600cfb7c6dcf529465b2618a2e040aa1e66c1607
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/test/libpldmresponder_fru_test.cpp b/test/libpldmresponder_fru_test.cpp
new file mode 100644
index 0000000..6a0dbbb
--- /dev/null
+++ b/test/libpldmresponder_fru_test.cpp
@@ -0,0 +1,50 @@
+#include "libpldmresponder/fru_parser.hpp"
+
+#include <gtest/gtest.h>
+
+TEST(FruParser, allScenarios)
+{
+    using namespace pldm::responder::fru_parser;
+
+    // Empty directory condition
+    ASSERT_THROW(FruParser("./fru_json"), std::exception);
+    // No master FRU JSON
+    ASSERT_THROW(FruParser("./fru_jsons/malformed1"), std::exception);
+    // Malformed master FRU JSON
+    ASSERT_THROW(FruParser("./fru_jsons/malformed2"), std::exception);
+    // Malformed FRU JSON
+    ASSERT_THROW(FruParser("./fru_jsons/malformed3"), std::exception);
+
+    FruParser parser{"./fru_jsons/good"};
+
+    // Get an item with a single PLDM FRU record
+    FruRecordInfos cpu{{1,
+                        1,
+                        {{"xyz.openbmc_project.Inventory.Decorator.Asset",
+                          "PartNumber", "string", 3},
+                         {"xyz.openbmc_project.Inventory.Decorator.Asset",
+                          "SerialNumber", "string", 4}}}};
+    auto cpuInfos =
+        parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.Cpu");
+    ASSERT_EQ(cpuInfos.size(), 1);
+    ASSERT_EQ(cpu == cpuInfos, true);
+
+    // Get an item type with 2 PLDM FRU records
+    auto boardInfos =
+        parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.Board");
+    ASSERT_EQ(boardInfos.size(), 2);
+
+    // D-Bus lookup info for FRU information
+    DBusLookupInfo lookupInfo{"xyz.openbmc_project.Inventory.Manager",
+                              "/xyz/openbmc_project/inventory/system/",
+                              {"xyz.openbmc_project.Inventory.Item.Board",
+                               "xyz.openbmc_project.Inventory.Item.Cpu"}};
+
+    auto dbusInfo = parser.inventoryLookup();
+    ASSERT_EQ(dbusInfo == lookupInfo, true);
+
+    // Search for an invalid item type
+    ASSERT_THROW(
+        parser.getRecordInfo("xyz.openbmc_project.Inventory.Item.DIMM"),
+        std::exception);
+}