Add Json Config support for entity to DBus string
The entity map comprises both entity types and their corresponding
names, essential for generating unique D-Bus paths for each entity.
However, challenges arise due to variations in path generation across
companies, often dictated by differing entity types. To address this,
enabling configurability of EntityID becomes imperative, empowering
communities to tailor configurations to their specific use cases.
Testing:
Unit tests passed
Change-Id: I3981fde64bd00940caa5067a9472fd948e74cbf0
Signed-off-by: Kamalkumar Patel <kamalkumar.patel@ibm.com>
diff --git a/host-bmc/test/entitymap_test.json b/host-bmc/test/entitymap_test.json
new file mode 100644
index 0000000..7dc08f2
--- /dev/null
+++ b/host-bmc/test/entitymap_test.json
@@ -0,0 +1,19 @@
+{
+ "Description": {
+ "_comment": [
+ "This file serves as a crucial tool for testing JSON parsing capabilities, facilitating the population of the Entitymap by harnessing its data."
+ ]
+ },
+ "EntityTypeToDbusStringMap": {
+ "45": "chassis",
+ "60": "io_board",
+ "63": "system_management_module",
+ "64": "motherboard",
+ "67": "dcm",
+ "80": "io_module",
+ "135": "cpu",
+ "190": "socket",
+ "32813": "system",
+ "32903": "core"
+ }
+}
diff --git a/host-bmc/test/meson.build b/host-bmc/test/meson.build
index 66d75b7..fd3e8c9 100644
--- a/host-bmc/test/meson.build
+++ b/host-bmc/test/meson.build
@@ -4,6 +4,7 @@
test_sources = [
'../../common/utils.cpp',
+ '../utils.cpp',
'../custom_dbus.cpp',
'../utils.cpp'
]
diff --git a/host-bmc/test/utils_test.cpp b/host-bmc/test/utils_test.cpp
index 701f4cb..373274f 100644
--- a/host-bmc/test/utils_test.cpp
+++ b/host-bmc/test/utils_test.cpp
@@ -1,4 +1,5 @@
#include "../utils.hpp"
+#include "common/utils.hpp"
#include <libpldm/pdr.h>
@@ -9,6 +10,13 @@
namespace fs = std::filesystem;
using namespace pldm;
using namespace pldm::utils;
+using namespace pldm::hostbmc::utils;
+
+TEST(EntityAssociation, parseEntityMap)
+{
+ EntityMaps entityMaps = parseEntityMap("./entitymap_test.json");
+ EXPECT_EQ(entityMaps.size(), 10);
+}
TEST(EntityAssociation, addObjectPathEntityAssociations1)
{
@@ -80,8 +88,8 @@
l5b}};
ObjectPathMaps objPathMap;
- pldm::hostbmc::utils::updateEntityAssociation(entityAssociations, tree,
- objPathMap);
+ EntityMaps entityMaps = parseEntityMap("./entitymap_test.json");
+ updateEntityAssociation(entityAssociations, tree, objPathMap, entityMaps);
EXPECT_EQ(objPathMap.size(), retObjectMaps.size());