platform-mc: Terminus name handling
`PLDM-stack: Adding sensor monitoring section` design spec details that
the `Terminus name` is required to create the terminus's sensors,
states, effecters... D-Bus interfaces and `Terminus Name` can be
encoded in the Terminus's `Entity Auxiliary Names PDR` or in the MCTP
Entity-manager endpoint EID configuration file.
[1] https://gerrit.openbmc.org/c/openbmc/docs/+/47252/34/designs/pldm-stack.md#433
Section `28.18 Entity Auxiliary Names PDR` in DSP0248 V1.2.2 details
about the PDRs response for the name of one PLDM entity. When the
containerID is `0x0000` this entity is `Overall system` or `top most
containing entity`. The name of this entity will can be used as
`Terminus name`.
Support parsing `Entity Auxiliary Names PDR` and find the `Terminus
name` if it is reponsed in the terminus' PDRs. `Terminus Name` string
will be assigned to local variable and can be used as prefix for
sensors, state, effecters... names.
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I701537c48651b9de86de77941b752e30de112916
diff --git a/common/test/pldm_utils_test.cpp b/common/test/pldm_utils_test.cpp
index 86704c4..73cd92c 100644
--- a/common/test/pldm_utils_test.cpp
+++ b/common/test/pldm_utils_test.cpp
@@ -1094,3 +1094,15 @@
rc = isValidEID(254);
EXPECT_EQ(rc, true);
}
+
+TEST(TrimNameForDbus, goodTest)
+{
+ std::string name = "Name with space";
+ std::string_view expectedName = "Name_with__space";
+ std::string_view result = trimNameForDbus(name);
+ EXPECT_EQ(expectedName, result);
+ name = "Name 1\0";
+ expectedName = "Name_1";
+ result = trimNameForDbus(name);
+ EXPECT_EQ(expectedName, result);
+}