PEL: Save AdditionalData in a UserData section
Save the contents of the AdditionalData OpenBMC event log property as
JSON in a UserData PEL section.
For example, if the AdditionalData property, which is an array of
strings, looks like:
["KEY1=VALUE1", "KEY=VALUE2"]
Then the data stored as ASCII text in the UserData section is:
{"KEY1":"VALUE1","KEY2":"VALUE2"}
If one of the keys is "ESEL", then that entry is removed from the
UserData output as that contains a full raw PEL from the host sent down
as ASCII text.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ia6ffabb39fdb4315ec2152744414e44f7d2ec4aa
diff --git a/test/openpower-pels/additional_data_test.cpp b/test/openpower-pels/additional_data_test.cpp
index 2be06c4..1bf4af7 100644
--- a/test/openpower-pels/additional_data_test.cpp
+++ b/test/openpower-pels/additional_data_test.cpp
@@ -24,4 +24,11 @@
EXPECT_FALSE(ad.getValue("HELLOWORLD"));
EXPECT_FALSE(ad.getValue("VALUE5"));
+
+ auto json = ad.toJSON();
+ std::string expected = R"({"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":""})";
+ EXPECT_EQ(json.dump(), expected);
+
+ ad.remove("KEY1");
+ EXPECT_FALSE(ad.getValue("KEY1"));
}