PEL: Update D-Bus event sev based on PEL severity
Put in checks to ensure the D-Bus event log severity agrees with the
final PEL severity for PELs created by the BMC. The D-bus property is
what is used in the Redfish event log, and we want to avoid cases like
having a Critical event log for an informational PEL.
This could happen in the case where the PEL message registry entry for
the event has a hardcoded or manufacturing specific severity value that
is different than the severity the D-Bus event log is first created
with.
This commit ensures that:
* If the PEL is nonError/recovered, the D-Bus severity is one of the
non error ones.
* If the PEL isn't nonError/recovered, then the D-Bus severity also
isn't.
* If the PEL is critical, the D-Bus severity is also critical.
It doesn't try to update the D-Bus severity for every PEL severity
because there isn't a one to one mapping - e.g. Notice, Debug, and
Informational D-Bus severities all map to a PEL severity of
nonError(informational).
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I6b0006034090e6d8e33e9f8b136ae50cce489f6e
diff --git a/test/openpower-pels/severity_test.cpp b/test/openpower-pels/severity_test.cpp
index 29c3bc3..b006aa9 100644
--- a/test/openpower-pels/severity_test.cpp
+++ b/test/openpower-pels/severity_test.cpp
@@ -31,3 +31,43 @@
ASSERT_EQ(convertOBMCSeverityToPEL(LogSeverity::Alert), 0x40);
ASSERT_EQ(convertOBMCSeverityToPEL(LogSeverity::Error), 0x40);
}
+
+TEST(SeverityTest, fixupLogSeverityTest)
+{
+ struct TestParams
+ {
+ LogSeverity sevIn;
+ SeverityType pelSevIn;
+ std::optional<LogSeverity> sevOut;
+ };
+
+ const std::vector<TestParams> testParams{
+ // Convert nonInfo sevs to info
+ {LogSeverity::Error, SeverityType::nonError,
+ LogSeverity::Informational},
+ {LogSeverity::Critical, SeverityType::recovered,
+ LogSeverity::Informational},
+ {LogSeverity::Warning, SeverityType::nonError,
+ LogSeverity::Informational},
+
+ // Convert info sevs to nonInfo
+ {LogSeverity::Informational, SeverityType::predictive,
+ LogSeverity::Warning},
+ {LogSeverity::Notice, SeverityType::unrecoverable, LogSeverity::Error},
+ {LogSeverity::Debug, SeverityType::critical, LogSeverity::Critical},
+
+ // Convert non-critical to critical
+ {LogSeverity::Warning, SeverityType::critical, LogSeverity::Critical},
+
+ // No change
+ {LogSeverity::Informational, SeverityType::nonError, std::nullopt},
+ {LogSeverity::Debug, SeverityType::recovered, std::nullopt},
+ {LogSeverity::Notice, SeverityType::nonError, std::nullopt},
+ {LogSeverity::Error, SeverityType::unrecoverable, std::nullopt},
+ {LogSeverity::Critical, SeverityType::unrecoverable, std::nullopt}};
+
+ for (const auto& test : testParams)
+ {
+ EXPECT_EQ(fixupLogSeverity(test.sevIn, test.pelSevIn), test.sevOut);
+ }
+}