PEL: Create PEL from parameters

Add a constructor to the PEL class so it can be built from the message
registry entry for that error along with the event log properties.

When support for new sections are added, they will be created here as
well along with the PrivateHeader and UserHeader section classes.

Eventually, this constructor will be called from the Manager class after
it is told a new event log has been created and after it looks up that
error's PEL message registry entry.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2d8ca550736aab45a30ac3db9861723b33e6cd32
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index ba71dc2..6d888b7 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -1,3 +1,4 @@
+#include "elog_entry.hpp"
 #include "extensions/openpower-pels/pel.hpp"
 #include "pel_utils.hpp"
 
@@ -86,10 +87,6 @@
     EXPECT_FALSE(pel->userHeader()->valid());
     EXPECT_FALSE(pel->valid());
 
-    // Ensure we can still flatten bad data
-    auto newData = pel->data();
-    EXPECT_EQ(*data, newData);
-
     // Now corrupt the private header
     data = pelDataFactory(TestPelType::pelSimple);
     data->at(0) = 0;
@@ -109,3 +106,21 @@
     EXPECT_FALSE(pel->userHeader()->valid());
     EXPECT_FALSE(pel->valid());
 }
+
+TEST_F(PELTest, CreateFromRegistryTest)
+{
+    message::Entry regEntry;
+    uint64_t timestamp = 5;
+
+    regEntry.name = "test";
+    regEntry.subsystem = 5;
+    regEntry.actionFlags = 0xC000;
+
+    PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error};
+
+    EXPECT_TRUE(pel.valid());
+    EXPECT_EQ(pel.privateHeader()->obmcLogID(), 42);
+    EXPECT_EQ(pel.userHeader()->severity(), 0x40);
+
+    // Add more checks as more sections are added
+}