PEL: Pass in subsystem to use with additional data
There is a requirement to pass in the subsystem to use with
the additional data field. In the process update the user
header code and SRC with the passed-in subsystem value
instead from the message registry.
Signed-off-by: Sumit Kumar <sumit_kumar@in.ibm.com>
Change-Id: I08c8c3bab100fec581df9043f4bb27b28cb556e1
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index 11b15d4..97d9b27 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -1446,3 +1446,31 @@
EXPECT_EQ(0x00080655, hexwords[0]);
}
}
+
+// Test SRC with additional data - PEL_SUBSYSTEM
+TEST_F(SRCTest, TestPELSubsystem)
+{
+ message::Entry entry;
+ entry.src.type = 0xBD;
+ entry.src.reasonCode = 0xABCD;
+ entry.subsystem = 0x42;
+ entry.src.powerFault = true;
+
+ // Values for the SRC words pointed to above
+ std::vector<std::string> adData{"PEL_SUBSYSTEM=0x20"};
+ AdditionalData ad{adData};
+ NiceMock<MockDataInterface> dataIface;
+
+ EXPECT_CALL(dataIface, getMotherboardCCIN).WillOnce(Return("ABCD"));
+
+ std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
+ "system/entry"};
+ EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
+ .WillOnce(Return(std::vector<bool>{false, false, false}));
+
+ SRC src{entry, ad, dataIface};
+
+ EXPECT_TRUE(src.valid());
+
+ EXPECT_EQ(src.asciiString(), "BD20ABCD ");
+}
diff --git a/test/openpower-pels/user_header_test.cpp b/test/openpower-pels/user_header_test.cpp
index a4bc3cb..59199fb 100644
--- a/test/openpower-pels/user_header_test.cpp
+++ b/test/openpower-pels/user_header_test.cpp
@@ -308,3 +308,24 @@
EXPECT_EQ(uh.severity(), 0x20);
EXPECT_EQ(uh.actionFlags(), 0xF000);
}
+
+// Test that the PEL Subsystem omes from the event log if any
+TEST(UserHeaderTest, UseEventLogPELSubsystem)
+{
+ using namespace openpower::pels::message;
+ Entry regEntry;
+
+ regEntry.name = "test";
+ regEntry.subsystem = 5;
+ regEntry.actionFlags = 0xC000;
+ regEntry.eventType = 1;
+ regEntry.eventScope = 2;
+
+ MockDataInterface dataIface;
+ std::vector<std::string> adData{"PEL_SUBSYSTEM=0x25"};
+ AdditionalData ad{adData};
+
+ UserHeader uh(regEntry, phosphor::logging::Entry::Level::Critical, ad,
+ dataIface);
+ ASSERT_EQ(uh.subsystem(), 0x25);
+}