extension: use map in create extension
Adjust the Create extension to use a map for metadata instead of
vector.
Tested: Unit tests updated and passing.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I9bd62b8dcc8b18a61958ed64de98b52a48333637
diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp
index e45fd55..18be5db 100644
--- a/test/openpower-pels/pel_manager_test.cpp
+++ b/test/openpower-pels/pel_manager_test.cpp
@@ -155,8 +155,8 @@
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
manager.create("error message", 42, 0,
@@ -201,8 +201,8 @@
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
manager.create("error message", 42, 0,
@@ -291,7 +291,7 @@
std::placeholders::_2, std::placeholders::_3),
std::move(journal)};
- std::vector<std::string> additionalData{"FOO=BAR"};
+ std::map<std::string, std::string> additionalData{{"FOO", "BAR"}};
std::vector<std::string> associations;
// Create the event log to create the PEL from.
@@ -408,8 +408,8 @@
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
manager.create("error message", 42, 0,
@@ -624,8 +624,7 @@
std::move(journal)};
{
- std::string adItem = "ESEL=" + esel;
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{{"ESEL", esel}};
std::vector<std::string> associations;
manager.create("error message", 37, 0,
@@ -639,12 +638,12 @@
// Now an invalid one
{
- std::string adItem = "ESEL=" + esel;
+ std::string adItem = esel;
// Crop it
adItem.resize(adItem.size() - 300);
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{{"ESEL", adItem}};
std::vector<std::string> associations;
manager.create("error message", 38, 0,
@@ -680,11 +679,11 @@
std::placeholders::_2, std::placeholders::_3),
std::move(journal)};
- // Create 25 1000B (4096B on disk each, which is what is used for pruning)
- // BMC non-informational PELs in the 100KB repository. After the 24th one,
- // the repo will be 96% full and a prune should be triggered to remove all
- // but 7 to get under 30% full. Then when the 25th is added there will be
- // 8 left.
+ // Create 25 1000B (4096B on disk each, which is what is used for
+ // pruning) BMC non-informational PELs in the 100KB repository. After
+ // the 24th one, the repo will be 96% full and a prune should be
+ // triggered to remove all but 7 to get under 30% full. Then when the
+ // 25th is added there will be 8 left.
auto dir = makeTempDir();
for (int i = 1; i <= 25; i++)
@@ -696,8 +695,8 @@
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
manager.create("error message", 42, 0,
@@ -759,8 +758,8 @@
auto dir = makeTempDir();
fs::path pelFilename = dir / "rawpel";
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
// Add 20 PELs, they will get incrementing IDs like
@@ -836,8 +835,8 @@
auto dir = makeTempDir();
fs::path pelFilename = dir / "rawpel";
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
// Add 200 PELs, they will get incrementing IDs like
@@ -922,8 +921,8 @@
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
manager.create("error message", 42, 0,
@@ -991,7 +990,7 @@
registryFile << registry;
registryFile.close();
- std::vector<std::string> additionalData;
+ std::map<std::string, std::string> additionalData;
std::vector<std::string> associations;
manager.create("xyz.openbmc_project.Error.Test", 42, 0,
@@ -1027,8 +1026,8 @@
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
- std::string adItem = "RAWPEL=" + pelFilename.string();
- std::vector<std::string> additionalData{adItem};
+ std::map<std::string, std::string> additionalData{
+ {"RAWPEL", pelFilename.string()}};
std::vector<std::string> associations;
manager.create("error message", 42, 0,
@@ -1052,7 +1051,8 @@
EXPECT_EQ(count, 1);
}
-// Test termination bit set for pel with critical system termination severity
+// Test termination bit set for pel with critical system termination
+// severity
TEST_F(ManagerTest, TestTerminateBitWithPELSevCriticalSysTerminate)
{
const auto registry = R"(
@@ -1097,7 +1097,7 @@
std::placeholders::_2, std::placeholders::_3),
std::move(journal)};
- std::vector<std::string> additionalData{"FOO=BAR"};
+ std::map<std::string, std::string> additionalData{{"FOO", "BAR"}};
std::vector<std::string> associations;
// Create the event log to create the PEL from.
@@ -1200,7 +1200,7 @@
std::placeholders::_2, std::placeholders::_3),
std::move(journal)};
- std::vector<std::string> additionalData;
+ std::map<std::string, std::string> additionalData;
std::vector<std::string> associations;
auto checkDeconfigured = [](bool deconfigured) {
@@ -1346,7 +1346,7 @@
std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3),
std::move(journal)};
- std::vector<std::string> additionalData;
+ std::map<std::string, std::string> additionalData;
std::vector<std::string> associations;
// Check when there's no PEL with given id.
@@ -1363,8 +1363,8 @@
{
// Verify that the guard flag is false.
EXPECT_FALSE(pel_unguarded.getGuardFlag());
- // Check that `isDeleteProhibited` returns false when the guard flag is
- // false.
+ // Check that `isDeleteProhibited` returns false when the guard flag
+ // is false.
EXPECT_FALSE(manager.isDeleteProhibited(42));
}
manager.erase(42);
@@ -1449,7 +1449,7 @@
std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3),
std::move(journal)};
- std::vector<std::string> additionalData;
+ std::map<std::string, std::string> additionalData;
std::vector<std::string> associations;
int fd = createHWIsolatedCalloutFile();
@@ -1468,9 +1468,9 @@
auto data = readPELFile(*pelFile);
PEL pel(*data);
EXPECT_TRUE(pel.valid());
- // Test case where the guard flag is set to true and the hardware isolation
- // guard is associated, which should result in `isDeleteProhibited`
- // returning true as expected.
+ // Test case where the guard flag is set to true and the hardware
+ // isolation guard is associated, which should result in
+ // `isDeleteProhibited` returning true as expected.
EXPECT_TRUE(pel.getGuardFlag());
EXPECT_TRUE(manager.isDeleteProhibited(42));
manager.erase(42);