summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-10-15 10:54:11 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-11-04 16:14:12 -0600
commitbd716f00dbdf910da44935785611b49c8719249c (patch)
treeeb06bfc2a646a19ec02f9f82836191984eb30a6d /test
parent55a697842f5d474877bb92afec2cd1c0e3100dbd (diff)
downloadphosphor-logging-bd716f00dbdf910da44935785611b49c8719249c.tar.gz
phosphor-logging-bd716f00dbdf910da44935785611b49c8719249c.zip
PEL: Create SRC section from message registry
This adds the ability to create an SRC PEL section based on the message registry entry for an OpenBMC event log. The event log's AdditionalData property is used as a source for the user defined data words of the SRC, while the other fields in the SRC's data words are filled in either from the message registry fields or from current system state or configuration. The ASCII string field of the SRC is filled in based on the message registry entry. This commit doesn't fill in every system status field, as many aren't even available anywhere yet. Also, this commit doesn't support adding callouts to an SRC, that will also be handled in the future. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I67fe44e07e4eda6bdeedb4af2eacfc197deb6eb3
Diffstat (limited to 'test')
-rw-r--r--test/openpower-pels/pel_test.cpp10
-rw-r--r--test/openpower-pels/pel_utils.cpp2
-rw-r--r--test/openpower-pels/src_test.cpp69
3 files changed, 77 insertions, 4 deletions
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index b744432..1f9917a 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -117,13 +117,21 @@ TEST_F(PELTest, CreateFromRegistryTest)
regEntry.name = "test";
regEntry.subsystem = 5;
regEntry.actionFlags = 0xC000;
+ regEntry.src.type = 0xBD;
+ regEntry.src.reasonCode = 0x1234;
- PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error};
+ AdditionalData ad;
+
+ PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error,
+ ad};
EXPECT_TRUE(pel.valid());
EXPECT_EQ(pel.privateHeader()->obmcLogID(), 42);
EXPECT_EQ(pel.userHeader()->severity(), 0x40);
+ EXPECT_EQ(pel.primarySRC().value()->asciiString(),
+ "BD051234 ");
+
// Add more checks as more sections are added
}
diff --git a/test/openpower-pels/pel_utils.cpp b/test/openpower-pels/pel_utils.cpp
index 4c94758..133e259 100644
--- a/test/openpower-pels/pel_utils.cpp
+++ b/test/openpower-pels/pel_utils.cpp
@@ -58,7 +58,7 @@ const std::vector<uint8_t> srcSectionNoCallouts{
0x00, 0x48, // SRC structure size
// Hex words 2 - 9
- 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
+ 0x02, 0x02, 0x02, 0x55, 0x03, 0x03, 0x03, 0x10, 0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09,
// ASCII string
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index 7596186..abeda0b 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -26,8 +26,8 @@ TEST(SRCTest, UnflattenFlattenTestNoCallouts)
EXPECT_EQ(src.size(), 0x48);
const auto& hexwords = src.hexwordData();
- EXPECT_EQ(0x02020202, hexwords[0]);
- EXPECT_EQ(0x03030303, hexwords[1]);
+ EXPECT_EQ(0x02020255, hexwords[0]);
+ EXPECT_EQ(0x03030310, hexwords[1]);
EXPECT_EQ(0x04040404, hexwords[2]);
EXPECT_EQ(0x05050505, hexwords[3]);
EXPECT_EQ(0x06060606, hexwords[4]);
@@ -54,6 +54,7 @@ TEST(SRCTest, UnflattenFlattenTest2Callouts)
SRC src{stream};
EXPECT_TRUE(src.valid());
+ EXPECT_EQ(src.flags(), 0x01); // Additional sections within the SRC.
// Spot check the SRC fields, but they're the same as above
EXPECT_EQ(src.asciiString(), "BD8D5678 ");
@@ -80,3 +81,67 @@ TEST(SRCTest, UnflattenFlattenTest2Callouts)
src.flatten(newStream);
EXPECT_EQ(data, newData);
}
+
+// Create an SRC from the message registry
+TEST(SRCTest, CreateTestNoCallouts)
+{
+ message::Entry entry;
+ entry.src.type = 0xBD;
+ entry.src.reasonCode = 0xABCD;
+ entry.subsystem = 0x42;
+ entry.src.powerFault = true;
+ entry.src.hexwordADFields = {{5, "TEST1"}, // Not a user defined word
+ {6, "TEST1"},
+ {7, "TEST2"},
+ {8, "TEST3"},
+ {9, "TEST4"}};
+
+ // Values for the SRC words pointed to above
+ std::vector<std::string> adData{"TEST1=0x12345678", "TEST2=12345678",
+ "TEST3=0XDEF", "TEST4=Z"};
+ AdditionalData ad{adData};
+ SRC src{entry, ad};
+
+ EXPECT_TRUE(src.valid());
+ EXPECT_TRUE(src.isPowerFaultEvent());
+ EXPECT_EQ(src.size(), baseSRCSize);
+
+ const auto& hexwords = src.hexwordData();
+
+ // The spec always refers to SRC words 2 - 9, and as the hexwordData()
+ // array index starts at 0 use the math in the [] below to make it easier
+ // to tell what is being accessed.
+ EXPECT_EQ(hexwords[2 - 2] & 0xF0000000, 0); // Partition dump status
+ EXPECT_EQ(hexwords[2 - 2] & 0x00F00000, 0); // Partition boot type
+ EXPECT_EQ(hexwords[2 - 2] & 0x000000FF, 0x55); // SRC format
+ EXPECT_EQ(hexwords[3 - 2] & 0x000000FF, 0x10); // BMC position
+
+ // Validate more fields here as the code starts filling them in.
+
+ // Ensure hex word 5 wasn't allowed to be set to TEST1's contents
+ EXPECT_EQ(hexwords[5 - 2], 0);
+
+ // The user defined hex word fields specifed in the additional data.
+ EXPECT_EQ(hexwords[6 - 2], 0x12345678); // TEST1
+ EXPECT_EQ(hexwords[7 - 2], 12345678); // TEST2
+ EXPECT_EQ(hexwords[8 - 2], 0xdef); // TEST3
+ EXPECT_EQ(hexwords[9 - 2], 0); // TEST4, but can't convert a 'Z'
+
+ EXPECT_EQ(src.asciiString(), "BD42ABCD ");
+
+ // No callouts
+ EXPECT_FALSE(src.callouts());
+
+ // May as well spot check the flatten/unflatten
+ std::vector<uint8_t> data;
+ Stream stream{data};
+ src.flatten(stream);
+
+ stream.offset(0);
+ SRC newSRC{stream};
+
+ EXPECT_TRUE(newSRC.valid());
+ EXPECT_EQ(newSRC.isPowerFaultEvent(), src.isPowerFaultEvent());
+ EXPECT_EQ(newSRC.asciiString(), src.asciiString());
+ EXPECT_FALSE(newSRC.callouts());
+}
OpenPOWER on IntegriCloud