pdr: Update D-Bus mapping structure
For most PDR types, the D-Bus object structure(paths, interfaces, and
properties) should be defined in the JSON file instead of hard-coded.
Tested with JSON files:
https://gist.github.com/lxwinspur/2c3fd68cdb35e06480c4a5f7890e3a06#file-effecter_pdr-json.
pldmtool platform GetPDR -d 1
Encode request successfully
Request Message:
08 01 80 02 51 01 00 00 00 00 00 00 00 01 80 00 00 00
Success in creating the socket : RC = 3
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 18
Total length:18
Loopback response message:
08 01 80 02 51 01 00 00 00 00 00 00 00 01 80 00 00 00
On first recv(),response == request : RC = 0
Total length: 46
Shutdown Socket successful : RC = 0
Response Message:
08 01 00 02 51 00 02 00 00 00 00 00 00 00 01 1d 00 01 00 00 00 01 0b 00 00 13 00 00 00 01 00 21 00 00 00 00 00 00 00 00 00 01 c4 00 01 06
Parsed Response Msg:
nextRecordHandle: 2
responseCount: 29
recordHandle: 1
PDRHeaderVersion: 1
PDRType: 11
recordChangeNumber: 0
dataLength: 19
PLDMTerminusHandle: 0
effecterID: 1
entityType: 33
entityInstanceNumber: 0
containerID: 0
effecterSemanticID: 0
effecterInit: 0
effecterDescriptionPDR: false
compositeEffecterCount: 1
stateSetID: 196
possibleStatesSize: 1
possibleStates: 6
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ifc0cd1540b08e9b73e03d99d71a0980ef6353e72
diff --git a/test/libpldmresponder_pdr_state_effecter_test.cpp b/test/libpldmresponder_pdr_state_effecter_test.cpp
index 5c197dd..73bcfbb 100644
--- a/test/libpldmresponder_pdr_state_effecter_test.cpp
+++ b/test/libpldmresponder_pdr_state_effecter_test.cpp
@@ -52,8 +52,9 @@
bf1.byte = 2;
ASSERT_EQ(states->states[0].byte, bf1.byte);
- const auto& paths = handler.getEffecterObjs(pdr->effecter_id);
- ASSERT_EQ(paths[0], "/foo/bar");
+ const auto& [dbusMappings1, dbusValMaps1] =
+ handler.getDbusObjMaps(pdr->effecter_id);
+ ASSERT_EQ(dbusMappings1[0].objectPath, "/foo/bar");
// Check second PDR
auto record2 = pdr::getRecordByHandle(outRepo, 2, e);
@@ -91,11 +92,12 @@
ASSERT_EQ(states->states[0].byte, bf2[0].byte);
ASSERT_EQ(states->states[1].byte, bf2[1].byte);
- const auto& paths1 = handler.getEffecterObjs(pdr->effecter_id);
- ASSERT_EQ(paths1[0], "/foo/bar");
- ASSERT_EQ(paths1[1], "/foo/bar/baz");
+ const auto& [dbusMappings2, dbusValMaps2] =
+ handler.getDbusObjMaps(pdr->effecter_id);
+ ASSERT_EQ(dbusMappings2[0].objectPath, "/foo/bar");
+ ASSERT_EQ(dbusMappings2[1].objectPath, "/foo/bar/baz");
- ASSERT_THROW(handler.getEffecterObjs(0xDEAD), std::exception);
+ ASSERT_THROW(handler.getDbusObjMaps(0xDEAD), std::exception);
pldm_pdr_destroy(inPDRRepo);
pldm_pdr_destroy(outPDRRepo);
diff --git a/test/libpldmresponder_platform_test.cpp b/test/libpldmresponder_platform_test.cpp
index 2e99f5a..8dfe6f1 100644
--- a/test/libpldmresponder_platform_test.cpp
+++ b/test/libpldmresponder_platform_test.cpp
@@ -192,14 +192,12 @@
std::vector<set_effecter_state_field> stateField;
stateField.push_back({PLDM_REQUEST_SET, 1});
stateField.push_back({PLDM_REQUEST_SET, 1});
- std::string value = "xyz.openbmc_project.State.OperatingSystem."
- "Status.OSStatus.Standby";
+ std::string value = "xyz.openbmc_project.Foo.Bar.V1";
PropertyValue propertyValue = value;
MockdBusHandler handlerObj;
- DBusMapping dbusMapping{"/foo/bar",
- "xyz.openbmc_project.State.OperatingSystem.Status",
- "OperatingSystemState", "string"};
+ DBusMapping dbusMapping{"/foo/bar", "xyz.openbmc_project.Foo.Bar",
+ "propertyName", "string"};
EXPECT_CALL(handlerObj, setDbusProperty(dbusMapping, propertyValue))
.Times(2);
@@ -244,13 +242,6 @@
stateField);
ASSERT_EQ(rc, PLDM_ERROR_INVALID_DATA);
- std::vector<set_effecter_state_field> newStateField;
- newStateField.push_back({PLDM_REQUEST_SET, 1});
-
- rc = handler.setStateEffecterStatesHandler<MockdBusHandler>(handlerObj, 0x2,
- newStateField);
- ASSERT_EQ(rc, PLDM_PLATFORM_INVALID_STATE_VALUE);
-
pldm_pdr_destroy(inPDRRepo);
pldm_pdr_destroy(outPDRRepo);
}
diff --git a/test/pdr_jsons/state_effecter/good/state_effecter_pdr.json b/test/pdr_jsons/state_effecter/good/state_effecter_pdr.json
index 90e068d..e4c7311 100644
--- a/test/pdr_jsons/state_effecter/good/state_effecter_pdr.json
+++ b/test/pdr_jsons/state_effecter/good/state_effecter_pdr.json
@@ -1,63 +1,103 @@
{
- "pdrType": 11,
- "entries": [
+ "effecterPDRs": [
{
- "type": 33,
- "instance": 0,
- "container": 0,
- "effecters": [
+ "pdrType": 11,
+ "entries": [
{
- "set": {
- "id": 196,
- "size": 1,
- "states": [
- 1
- ]
- },
- "dbus": "/foo/bar"
+ "type": 33,
+ "instance": 0,
+ "container": 0,
+ "effecters": [
+ {
+ "set": {
+ "id": 196,
+ "size": 1,
+ "states": [
+ 1
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar",
+ "interface": "xyz.openbmc_project.Foo.Bar",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.V1"
+ ]
+ }
+ },
+ {
+ "set": {
+ "id": 196,
+ "size": 1,
+ "states": [
+ 1,
+ 2
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar",
+ "interface": "xyz.openbmc_project.Foo.Bar",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.V1",
+ "xyz.openbmc_project.Foo.Bar.V2"
+ ]
+ }
+ }
+ ]
},
{
- "set": {
- "id": 196,
- "size": 1,
- "states": [
- 1,
- 2
- ]
- },
- "dbus": "/foo/bar"
- }
- ]
- },
- {
- "type": 100,
- "instance": 0,
- "container": 0,
- "effecters": [
- {
- "set": {
- "id": 197,
- "size": 1,
- "states": [
- 1
- ]
- },
- "dbus": "/foo/bar"
- },
- {
- "set": {
- "id": 198,
- "size": 2,
- "states": [
- 1,
- 2,
- 5,
- 15
- ]
- },
- "dbus": "/foo/bar/baz"
+ "type": 100,
+ "instance": 0,
+ "container": 0,
+ "effecters": [
+ {
+ "set": {
+ "id": 197,
+ "size": 1,
+ "states": [
+ 1
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar",
+ "interface": "xyz.openbmc_project.Foo.Bar",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.V1"
+ ]
+ }
+ },
+ {
+ "set": {
+ "id": 198,
+ "size": 2,
+ "states": [
+ 1,
+ 2,
+ 5,
+ 15
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar/baz",
+ "interface": "xyz.openbmc_project.Foo.Bar.Baz",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.Baz.V1",
+ "xyz.openbmc_project.Foo.Bar.Baz.V2",
+ "xyz.openbmc_project.Foo.Bar.Baz.V5",
+ "xyz.openbmc_project.Foo.Bar.Baz.V15"
+ ]
+ }
+ }
+ ]
}
]
}
]
-}
\ No newline at end of file
+}
diff --git a/test/pdr_jsons/state_effecter/malformed/state_effecter_pdr.json b/test/pdr_jsons/state_effecter/malformed/state_effecter_pdr.json
index 3f4276e..bcbc37d 100644
--- a/test/pdr_jsons/state_effecter/malformed/state_effecter_pdr.json
+++ b/test/pdr_jsons/state_effecter/malformed/state_effecter_pdr.json
@@ -1,49 +1,103 @@
{
- "pdrType": 11,
- "entries": [
+ "effecterPDRs": [
{
- "type": 33
- "instance": 0,
- "container": 0,
- "effecters": [
+ "pdrType": 11,
+ "entries": [
{
- "set": {
- "id": 196,
- "size": 1,
- "states": [
- 1
- ]
- }
- }
- ]
- },
- {
- "type": 100,
- "instance": 0,
- "container": 0,
- "effecters": [
- {
- "set": {
- "id": 197,
- "size": 1,
- "states": [
- 1
- ]
- }
+ "type": 33
+ "instance": 0,
+ "container": 0,
+ "effecters": [
+ {
+ "set": {
+ "id": 196,
+ "size": 1,
+ "states": [
+ 1
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar",
+ "interface": "xyz.openbmc_project.Foo.Bar",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.V1"
+ ]
+ }
+ },
+ {
+ "set": {
+ "id": 196,
+ "size": 1,
+ "states": [
+ 1,
+ 2
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar",
+ "interface": "xyz.openbmc_project.Foo.Bar",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.V1",
+ "xyz.openbmc_project.Foo.Bar.V2"
+ ]
+ }
+ }
+ ]
},
{
- "set": {
- "id": 198,
- "size": 2,
- "states": [
- 1,
- 2,
- 5,
- 15
- ]
- }
+ "type": 100,
+ "instance": 0,
+ "container": 0,
+ "effecters": [
+ {
+ "set": {
+ "id": 197,
+ "size": 1,
+ "states": [
+ 1
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar",
+ "interface": "xyz.openbmc_project.Foo.Bar",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.V1"
+ ]
+ }
+ },
+ {
+ "set": {
+ "id": 198,
+ "size": 2,
+ "states": [
+ 1,
+ 2,
+ 5,
+ 15
+ ]
+ },
+ "dbus": {
+ "path": "/foo/bar/baz",
+ "interface": "xyz.openbmc_project.Foo.Bar.Baz",
+ "property_name": "propertyName",
+ "property_type": "string",
+ "property_values": [
+ "xyz.openbmc_project.Foo.Bar.Baz.V1",
+ "xyz.openbmc_project.Foo.Bar.Baz.V2",
+ "xyz.openbmc_project.Foo.Bar.Baz.V5",
+ "xyz.openbmc_project.Foo.Bar.Baz.V15"
+ ]
+ }
+ }
+ ]
}
]
}
]
-}
\ No newline at end of file
+}