Skip to content

Commit e594063

Browse files
committedDec 5, 2024
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
1 parent 64a9eaa commit e594063

11 files changed

+117
-114
lines changed
 

‎extensions.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace logging
1717
*/
1818
using StartupFunction = std::function<void(internal::Manager&)>;
1919

20-
using AdditionalDataArg = std::vector<std::string>;
20+
using AdditionalDataArg = std::map<std::string, std::string>;
2121
using AssociationEndpointsArg = std::vector<std::string>;
2222
using FFDCArg = FFDCEntries;
2323

‎extensions/openpower-pels/additional_data.hpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,9 @@ class AdditionalData
3838
* @param[in] ad - the AdditionalData property vector with
3939
* entries of "KEY=VALUE"
4040
*/
41-
explicit AdditionalData(const std::vector<std::string>& ad)
42-
{
43-
for (auto& item : ad)
44-
{
45-
auto pos = item.find_first_of('=');
46-
if (pos == std::string::npos || pos == 0)
47-
{
48-
continue;
49-
}
50-
51-
_data[item.substr(0, pos)] = std::move(item.substr(pos + 1));
52-
}
53-
}
41+
explicit AdditionalData(const std::map<std::string, std::string>& ad) :
42+
_data(ad)
43+
{}
5444

5545
/**
5646
* @brief Returns the value of the AdditionalData item for the

‎extensions/openpower-pels/manager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Manager::~Manager()
7373

7474
void Manager::create(const std::string& message, uint32_t obmcLogID,
7575
uint64_t timestamp, Entry::Level severity,
76-
const std::vector<std::string>& additionalData,
76+
const std::map<std::string, std::string>& additionalData,
7777
const std::vector<std::string>& associations,
7878
const FFDCEntries& ffdc)
7979
{
@@ -361,7 +361,7 @@ PelFFDC Manager::convertToPelFFDC(const FFDCEntries& ffdc)
361361
void Manager::createPEL(
362362
const std::string& message, uint32_t obmcLogID, uint64_t timestamp,
363363
phosphor::logging::Entry::Level severity,
364-
const std::vector<std::string>& additionalData,
364+
const std::map<std::string, std::string>& additionalData,
365365
const std::vector<std::string>& /*associations*/, const FFDCEntries& ffdc)
366366
{
367367
auto entry = _registry.lookup(message, rg::LookupType::name);

‎extensions/openpower-pels/manager.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Manager : public PELInterface
113113
*/
114114
void create(const std::string& message, uint32_t obmcLogID,
115115
uint64_t timestamp, phosphor::logging::Entry::Level severity,
116-
const std::vector<std::string>& additionalData,
116+
const std::map<std::string, std::string>& additionalData,
117117
const std::vector<std::string>& associations,
118118
const phosphor::logging::FFDCEntries& ffdc =
119119
phosphor::logging::FFDCEntries{});
@@ -319,7 +319,7 @@ class Manager : public PELInterface
319319
*/
320320
void createPEL(const std::string& message, uint32_t obmcLogID,
321321
uint64_t timestamp, phosphor::logging::Entry::Level severity,
322-
const std::vector<std::string>& additionalData,
322+
const std::map<std::string, std::string>& additionalData,
323323
const std::vector<std::string>& associations,
324324
const phosphor::logging::FFDCEntries& ffdc);
325325

‎log_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void Manager::doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc)
452452
try
453453
{
454454
create(entry.message(), entry.id(), entry.timestamp(),
455-
entry.severity(), entry.additionalData(), assocs, ffdc);
455+
entry.severity(), entry.additionalData2(), assocs, ffdc);
456456
}
457457
catch (const std::exception& e)
458458
{

‎test/openpower-pels/additional_data_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ using namespace openpower::pels;
2121

2222
TEST(AdditionalDataTest, GetKeywords)
2323
{
24-
std::vector<std::string> data{"KEY1=VALUE1", "KEY2=VALUE2",
25-
"KEY3=", "HELLOWORLD", "=VALUE5"};
24+
std::map<std::string, std::string> data{
25+
{"KEY1", "VALUE1"}, {"KEY2", "VALUE2"}, {"KEY3", ""}};
2626
AdditionalData ad{data};
2727

2828
EXPECT_TRUE(ad.getValue("KEY1"));

‎test/openpower-pels/pel_manager_test.cpp

+37-37
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ TEST_F(ManagerTest, TestCreateWithPEL)
155155
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
156156
pelFile.close();
157157

158-
std::string adItem = "RAWPEL=" + pelFilename.string();
159-
std::vector<std::string> additionalData{adItem};
158+
std::map<std::string, std::string> additionalData{
159+
{"RAWPEL", pelFilename.string()}};
160160
std::vector<std::string> associations;
161161

162162
manager.create("error message", 42, 0,
@@ -201,8 +201,8 @@ TEST_F(ManagerTest, TestCreateWithInvalidPEL)
201201
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
202202
pelFile.close();
203203

204-
std::string adItem = "RAWPEL=" + pelFilename.string();
205-
std::vector<std::string> additionalData{adItem};
204+
std::map<std::string, std::string> additionalData{
205+
{"RAWPEL", pelFilename.string()}};
206206
std::vector<std::string> associations;
207207

208208
manager.create("error message", 42, 0,
@@ -291,7 +291,7 @@ TEST_F(ManagerTest, TestCreateWithMessageRegistry)
291291
std::placeholders::_2, std::placeholders::_3),
292292
std::move(journal)};
293293

294-
std::vector<std::string> additionalData{"FOO=BAR"};
294+
std::map<std::string, std::string> additionalData{{"FOO", "BAR"}};
295295
std::vector<std::string> associations;
296296

297297
// Create the event log to create the PEL from.
@@ -408,8 +408,8 @@ TEST_F(ManagerTest, TestDBusMethods)
408408
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
409409
pelFile.close();
410410

411-
std::string adItem = "RAWPEL=" + pelFilename.string();
412-
std::vector<std::string> additionalData{adItem};
411+
std::map<std::string, std::string> additionalData{
412+
{"RAWPEL", pelFilename.string()}};
413413
std::vector<std::string> associations;
414414

415415
manager.create("error message", 42, 0,
@@ -624,8 +624,7 @@ TEST_F(ManagerTest, TestCreateWithESEL)
624624
std::move(journal)};
625625

626626
{
627-
std::string adItem = "ESEL=" + esel;
628-
std::vector<std::string> additionalData{adItem};
627+
std::map<std::string, std::string> additionalData{{"ESEL", esel}};
629628
std::vector<std::string> associations;
630629

631630
manager.create("error message", 37, 0,
@@ -639,12 +638,12 @@ TEST_F(ManagerTest, TestCreateWithESEL)
639638

640639
// Now an invalid one
641640
{
642-
std::string adItem = "ESEL=" + esel;
641+
std::string adItem = esel;
643642

644643
// Crop it
645644
adItem.resize(adItem.size() - 300);
646645

647-
std::vector<std::string> additionalData{adItem};
646+
std::map<std::string, std::string> additionalData{{"ESEL", adItem}};
648647
std::vector<std::string> associations;
649648

650649
manager.create("error message", 38, 0,
@@ -680,11 +679,11 @@ TEST_F(ManagerTest, TestPruning)
680679
std::placeholders::_2, std::placeholders::_3),
681680
std::move(journal)};
682681

683-
// Create 25 1000B (4096B on disk each, which is what is used for pruning)
684-
// BMC non-informational PELs in the 100KB repository. After the 24th one,
685-
// the repo will be 96% full and a prune should be triggered to remove all
686-
// but 7 to get under 30% full. Then when the 25th is added there will be
687-
// 8 left.
682+
// Create 25 1000B (4096B on disk each, which is what is used for
683+
// pruning) BMC non-informational PELs in the 100KB repository. After
684+
// the 24th one, the repo will be 96% full and a prune should be
685+
// triggered to remove all but 7 to get under 30% full. Then when the
686+
// 25th is added there will be 8 left.
688687

689688
auto dir = makeTempDir();
690689
for (int i = 1; i <= 25; i++)
@@ -696,8 +695,8 @@ TEST_F(ManagerTest, TestPruning)
696695
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
697696
pelFile.close();
698697

699-
std::string adItem = "RAWPEL=" + pelFilename.string();
700-
std::vector<std::string> additionalData{adItem};
698+
std::map<std::string, std::string> additionalData{
699+
{"RAWPEL", pelFilename.string()}};
701700
std::vector<std::string> associations;
702701

703702
manager.create("error message", 42, 0,
@@ -759,8 +758,8 @@ TEST_F(ManagerTest, TestPELManualDelete)
759758
auto dir = makeTempDir();
760759
fs::path pelFilename = dir / "rawpel";
761760

762-
std::string adItem = "RAWPEL=" + pelFilename.string();
763-
std::vector<std::string> additionalData{adItem};
761+
std::map<std::string, std::string> additionalData{
762+
{"RAWPEL", pelFilename.string()}};
764763
std::vector<std::string> associations;
765764

766765
// Add 20 PELs, they will get incrementing IDs like
@@ -836,8 +835,8 @@ TEST_F(ManagerTest, TestPELManualDeleteAll)
836835
auto dir = makeTempDir();
837836
fs::path pelFilename = dir / "rawpel";
838837

839-
std::string adItem = "RAWPEL=" + pelFilename.string();
840-
std::vector<std::string> additionalData{adItem};
838+
std::map<std::string, std::string> additionalData{
839+
{"RAWPEL", pelFilename.string()}};
841840
std::vector<std::string> associations;
842841

843842
// Add 200 PELs, they will get incrementing IDs like
@@ -922,8 +921,8 @@ TEST_F(ManagerTest, TestServiceIndicators)
922921
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
923922
pelFile.close();
924923

925-
std::string adItem = "RAWPEL=" + pelFilename.string();
926-
std::vector<std::string> additionalData{adItem};
924+
std::map<std::string, std::string> additionalData{
925+
{"RAWPEL", pelFilename.string()}};
927926
std::vector<std::string> associations;
928927

929928
manager.create("error message", 42, 0,
@@ -991,7 +990,7 @@ TEST_F(ManagerTest, TestServiceIndicators)
991990
registryFile << registry;
992991
registryFile.close();
993992

994-
std::vector<std::string> additionalData;
993+
std::map<std::string, std::string> additionalData;
995994
std::vector<std::string> associations;
996995

997996
manager.create("xyz.openbmc_project.Error.Test", 42, 0,
@@ -1027,8 +1026,8 @@ TEST_F(ManagerTest, TestDuplicatePEL)
10271026
pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
10281027
pelFile.close();
10291028

1030-
std::string adItem = "RAWPEL=" + pelFilename.string();
1031-
std::vector<std::string> additionalData{adItem};
1029+
std::map<std::string, std::string> additionalData{
1030+
{"RAWPEL", pelFilename.string()}};
10321031
std::vector<std::string> associations;
10331032

10341033
manager.create("error message", 42, 0,
@@ -1052,7 +1051,8 @@ TEST_F(ManagerTest, TestDuplicatePEL)
10521051
EXPECT_EQ(count, 1);
10531052
}
10541053

1055-
// Test termination bit set for pel with critical system termination severity
1054+
// Test termination bit set for pel with critical system termination
1055+
// severity
10561056
TEST_F(ManagerTest, TestTerminateBitWithPELSevCriticalSysTerminate)
10571057
{
10581058
const auto registry = R"(
@@ -1097,7 +1097,7 @@ TEST_F(ManagerTest, TestTerminateBitWithPELSevCriticalSysTerminate)
10971097
std::placeholders::_2, std::placeholders::_3),
10981098
std::move(journal)};
10991099

1100-
std::vector<std::string> additionalData{"FOO=BAR"};
1100+
std::map<std::string, std::string> additionalData{{"FOO", "BAR"}};
11011101
std::vector<std::string> associations;
11021102

11031103
// Create the event log to create the PEL from.
@@ -1200,7 +1200,7 @@ TEST_F(ManagerTest, TestFruPlug)
12001200
std::placeholders::_2, std::placeholders::_3),
12011201
std::move(journal)};
12021202

1203-
std::vector<std::string> additionalData;
1203+
std::map<std::string, std::string> additionalData;
12041204
std::vector<std::string> associations;
12051205

12061206
auto checkDeconfigured = [](bool deconfigured) {
@@ -1346,7 +1346,7 @@ TEST_F(ManagerTest, TestPELDeleteWithoutHWIsolation)
13461346
std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
13471347
std::placeholders::_2, std::placeholders::_3),
13481348
std::move(journal)};
1349-
std::vector<std::string> additionalData;
1349+
std::map<std::string, std::string> additionalData;
13501350
std::vector<std::string> associations;
13511351

13521352
// Check when there's no PEL with given id.
@@ -1363,8 +1363,8 @@ TEST_F(ManagerTest, TestPELDeleteWithoutHWIsolation)
13631363
{
13641364
// Verify that the guard flag is false.
13651365
EXPECT_FALSE(pel_unguarded.getGuardFlag());
1366-
// Check that `isDeleteProhibited` returns false when the guard flag is
1367-
// false.
1366+
// Check that `isDeleteProhibited` returns false when the guard flag
1367+
// is false.
13681368
EXPECT_FALSE(manager.isDeleteProhibited(42));
13691369
}
13701370
manager.erase(42);
@@ -1449,7 +1449,7 @@ TEST_F(ManagerTest, TestPELDeleteWithHWIsolation)
14491449
std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
14501450
std::placeholders::_2, std::placeholders::_3),
14511451
std::move(journal)};
1452-
std::vector<std::string> additionalData;
1452+
std::map<std::string, std::string> additionalData;
14531453
std::vector<std::string> associations;
14541454

14551455
int fd = createHWIsolatedCalloutFile();
@@ -1468,9 +1468,9 @@ TEST_F(ManagerTest, TestPELDeleteWithHWIsolation)
14681468
auto data = readPELFile(*pelFile);
14691469
PEL pel(*data);
14701470
EXPECT_TRUE(pel.valid());
1471-
// Test case where the guard flag is set to true and the hardware isolation
1472-
// guard is associated, which should result in `isDeleteProhibited`
1473-
// returning true as expected.
1471+
// Test case where the guard flag is set to true and the hardware
1472+
// isolation guard is associated, which should result in
1473+
// `isDeleteProhibited` returning true as expected.
14741474
EXPECT_TRUE(pel.getGuardFlag());
14751475
EXPECT_TRUE(manager.isDeleteProhibited(42));
14761476
manager.erase(42);

‎test/openpower-pels/pel_test.cpp

+21-22
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ TEST_F(PELTest, CreateFromRegistryTest)
162162
regEntry.src.type = 0xBD;
163163
regEntry.src.reasonCode = 0x1234;
164164

165-
std::vector<std::string> data{"KEY1=VALUE1"};
165+
std::map<std::string, std::string> data{{"KEY1", "VALUE1"}};
166166
AdditionalData ad{data};
167167
NiceMock<MockDataInterface> dataIface;
168168
NiceMock<MockJournal> journal;
@@ -237,10 +237,7 @@ TEST_F(PELTest, CreateTooBigADTest)
237237
PelFFDC ffdc;
238238

239239
// Over the 16KB max PEL size
240-
std::string bigAD{"KEY1="};
241-
bigAD += std::string(17000, 'G');
242-
243-
std::vector<std::string> data{bigAD};
240+
std::map<std::string, std::string> data{{"KEY1", std::string(17000, 'G')}};
244241
AdditionalData ad{data};
245242
NiceMock<MockDataInterface> dataIface;
246243
NiceMock<MockJournal> journal;
@@ -362,8 +359,10 @@ TEST_F(PELTest, InvalidGenericTest)
362359
// Create a UserData section out of AdditionalData
363360
TEST_F(PELTest, MakeUDSectionTest)
364361
{
365-
std::vector<std::string> ad{"KEY1=VALUE1", "KEY2=VALUE2", "KEY3=VALUE3",
366-
"ESEL=TEST"};
362+
std::map<std::string, std::string> ad{{"KEY1", "VALUE1"},
363+
{"KEY2", "VALUE2"},
364+
{"KEY3", "VALUE3"},
365+
{"ESEL", "TEST"}};
367366
AdditionalData additionalData{ad};
368367

369368
auto ud = util::makeADUserDataSection(additionalData);
@@ -409,8 +408,7 @@ TEST_F(PELTest, SysInfoSectionTest)
409408
EXPECT_CALL(dataIface, getSystemIMKeyword())
410409
.WillOnce(Return(std::vector<uint8_t>{0, 1, 0x55, 0xAA}));
411410

412-
std::string pid = "_PID=" + std::to_string(getpid());
413-
std::vector<std::string> ad{pid};
411+
std::map<std::string, std::string> ad{{"_PID", std::to_string(getpid())}};
414412
AdditionalData additionalData{ad};
415413

416414
auto ud = util::makeSysInfoUserDataSection(additionalData, dataIface);
@@ -752,7 +750,7 @@ TEST_F(PELTest, CreateWithFFDCTest)
752750
regEntry.src.type = 0xBD;
753751
regEntry.src.reasonCode = 0x1234;
754752

755-
std::vector<std::string> additionalData{"KEY1=VALUE1"};
753+
std::map<std::string, std::string> additionalData{{"KEY1", "VALUE1"}};
756754
AdditionalData ad{additionalData};
757755
NiceMock<MockDataInterface> dataIface;
758756
NiceMock<MockJournal> journal;
@@ -863,10 +861,10 @@ TEST_F(PELTest, CreateWithDevCalloutsTest)
863861
file.close();
864862

865863
{
866-
std::vector<std::string> data{
867-
"CALLOUT_ERRNO=5",
868-
"CALLOUT_DEVICE_PATH=/sys/devices/platform/ahb/ahb:apb/"
869-
"ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-14/14-0072"};
864+
std::map<std::string, std::string> data{
865+
{"CALLOUT_ERRNO", "5"},
866+
{"CALLOUT_DEVICE_PATH",
867+
"/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-14/14-0072"}};
870868

871869
AdditionalData ad{data};
872870

@@ -917,10 +915,10 @@ TEST_F(PELTest, CreateWithDevCalloutsTest)
917915

918916
{
919917
// Device path not found (wrong i2c addr), so no callouts
920-
std::vector<std::string> data{
921-
"CALLOUT_ERRNO=5",
922-
"CALLOUT_DEVICE_PATH=/sys/devices/platform/ahb/ahb:apb/"
923-
"ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-14/14-0099"};
918+
std::map<std::string, std::string> data{
919+
{"CALLOUT_ERRNO", "5"},
920+
{"CALLOUT_DEVICE_PATH",
921+
"/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-14/14-0099"}};
924922

925923
AdditionalData ad{data};
926924

@@ -1149,7 +1147,7 @@ TEST_F(PELTest, CaptureJournalTest)
11491147
regEntry.src.type = 0xBD;
11501148
regEntry.src.reasonCode = 0x1234;
11511149

1152-
std::vector<std::string> data;
1150+
std::map<std::string, std::string> data{};
11531151
AdditionalData ad{data};
11541152
NiceMock<MockDataInterface> dataIface;
11551153
NiceMock<MockJournal> journal;
@@ -1231,7 +1229,8 @@ TEST_F(PELTest, CaptureJournalTest)
12311229
ad, ffdc,
12321230
dataIface, journal};
12331231

1234-
// Two more sections than the 1 extra UD section in the first testcase
1232+
// Two more sections than the 1 extra UD section in the first
1233+
// testcase
12351234
ASSERT_EQ(pel.privateHeader().sectionCount(), pelSectsWithOneUD + 2);
12361235

12371236
const auto& optionalSections = pel.optionalSections();
@@ -1289,8 +1288,8 @@ nlohmann::json getDIMMInfo(const auto& pel)
12891288
{
12901289
auto userData = static_cast<UserData*>(optionalSection.get());
12911290

1292-
// convert the userdata section to string and then parse in to json
1293-
// format
1291+
// convert the userdata section to string and then parse in to
1292+
// json format
12941293
std::string userDataString{userData->data().begin(),
12951294
userData->data().end()};
12961295
nlohmann::json userDataJson = nlohmann::json::parse(userDataString);

‎test/openpower-pels/registry_test.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ TEST_F(RegistryTest, TestGetCallouts)
688688

689689
{
690690
// Find callouts for PROC_NUM 0 on system3
691-
std::vector<std::string> adData{"PROC_NUM=0"};
691+
std::map<std::string, std::string> adData{{"PROC_NUM", "0"}};
692692
AdditionalData ad{adData};
693693
systemNames[0] = "system3";
694694

@@ -723,7 +723,7 @@ TEST_F(RegistryTest, TestGetCallouts)
723723
}
724724
{
725725
// Find callouts for PROC_NUM 1 that uses a default system entry.
726-
std::vector<std::string> adData{"PROC_NUM=1"};
726+
std::map<std::string, std::string> adData{{"PROC_NUM", "1"}};
727727
AdditionalData ad{adData};
728728
systemNames[0] = "system1";
729729

@@ -737,7 +737,7 @@ TEST_F(RegistryTest, TestGetCallouts)
737737
}
738738
{
739739
// There is no entry for PROC_NUM 2, so no callouts
740-
std::vector<std::string> adData{"PROC_NUM=2"};
740+
std::map<std::string, std::string> adData{{"PROC_NUM", "2"}};
741741
AdditionalData ad{adData};
742742

743743
auto callouts = Registry::getCallouts(json, systemNames, ad);
@@ -783,7 +783,7 @@ TEST_F(RegistryTest, TestGetCallouts)
783783

784784
// There isn't an entry in the JSON for a PROC_NUM of 8
785785
// so it should choose the P1-C1 callout.
786-
std::vector<std::string> adData{"PROC_NUM=8"};
786+
std::map<std::string, std::string> adData{{"PROC_NUM", "8"}};
787787
AdditionalData ad{adData};
788788
systemNames.clear();
789789

‎test/openpower-pels/src_test.cpp

+39-26
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ TEST_F(SRCTest, CreateTestNoCallouts)
198198
{9, {"TEST4", "DESCR4"}}};
199199

200200
// Values for the SRC words pointed to above
201-
std::vector<std::string> adData{"TEST1=0x12345678", "TEST2=12345678",
202-
"TEST3=0XDEF", "TEST4=Z"};
201+
std::map<std::string, std::string> adData{
202+
{"TEST1", "0x12345678"},
203+
{"TEST2", "12345678"},
204+
{"TEST3", "0XDEF"},
205+
{"TEST4", "Z"}};
203206
AdditionalData ad{adData};
204207
NiceMock<MockDataInterface> dataIface;
205208

@@ -260,7 +263,7 @@ TEST_F(SRCTest, BadCCINTest)
260263
entry.src.reasonCode = 0xABCD;
261264
entry.subsystem = 0x42;
262265

263-
std::vector<std::string> adData{};
266+
std::map<std::string, std::string> adData{};
264267
AdditionalData ad{adData};
265268
NiceMock<MockDataInterface> dataIface;
266269

@@ -301,8 +304,11 @@ TEST_F(SRCTest, MessageSubstitutionTest)
301304
message::Registry registry{path};
302305
auto entry = registry.lookup("0xABCD", message::LookupType::reasonCode);
303306

304-
std::vector<std::string> adData{"COMPID=0x1", "FREQUENCY=0x4",
305-
"DURATION=30", "ERRORCODE=0x01ABCDEF"};
307+
std::map<std::string, std::string> adData{
308+
{"COMPID", "0x1"},
309+
{"FREQUENCY", "0x4"},
310+
{"DURATION", "30"},
311+
{"ERRORCODE", "0x01ABCDEF"}};
306312
AdditionalData ad{adData};
307313
NiceMock<MockDataInterface> dataIface;
308314

@@ -324,7 +330,8 @@ TEST_F(SRCTest, InventoryCalloutTest)
324330
entry.src.reasonCode = 0xABCD;
325331
entry.subsystem = 0x42;
326332

327-
std::vector<std::string> adData{"CALLOUT_INVENTORY_PATH=motherboard"};
333+
std::map<std::string, std::string> adData{
334+
{"CALLOUT_INVENTORY_PATH", "motherboard"}};
328335
AdditionalData ad{adData};
329336
NiceMock<MockDataInterface> dataIface;
330337

@@ -375,7 +382,8 @@ TEST_F(SRCTest, InventoryCalloutNoLocCodeTest)
375382
entry.src.reasonCode = 0xABCD;
376383
entry.subsystem = 0x42;
377384

378-
std::vector<std::string> adData{"CALLOUT_INVENTORY_PATH=motherboard"};
385+
std::map<std::string, std::string> adData{
386+
{"CALLOUT_INVENTORY_PATH", "motherboard"}};
379387
AdditionalData ad{adData};
380388
NiceMock<MockDataInterface> dataIface;
381389

@@ -415,7 +423,8 @@ TEST_F(SRCTest, InventoryCalloutNoVPDTest)
415423
entry.src.reasonCode = 0xABCD;
416424
entry.subsystem = 0x42;
417425

418-
std::vector<std::string> adData{"CALLOUT_INVENTORY_PATH=motherboard"};
426+
std::map<std::string, std::string> adData{
427+
{"CALLOUT_INVENTORY_PATH", "motherboard"}};
419428
AdditionalData ad{adData};
420429
NiceMock<MockDataInterface> dataIface;
421430

@@ -692,7 +701,8 @@ TEST_F(SRCTest, SymbolicFRUWithInvPathTest)
692701
// The location code for the first symbolic FRU callout will
693702
// come from this inventory path since UseInventoryLocCode is set.
694703
// In this case there will be no normal FRU callout for the motherboard.
695-
std::vector<std::string> adData{"CALLOUT_INVENTORY_PATH=motherboard"};
704+
std::map<std::string, std::string> adData{
705+
{"CALLOUT_INVENTORY_PATH", "motherboard"}};
696706
AdditionalData ad{adData};
697707
NiceMock<MockDataInterface> dataIface;
698708
std::vector<std::string> names{"systemA"};
@@ -910,34 +920,36 @@ TEST_F(SRCTest, DevicePathCalloutTest)
910920

911921
{
912922
// Callouts based on the device path
913-
std::vector<std::string> items{
914-
"CALLOUT_ERRNO=5",
915-
"CALLOUT_DEVICE_PATH=/sys/devices/platform/ahb/ahb:apb/"
916-
"ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-14/14-0072"};
923+
std::map<std::string, std::string> items{
924+
{"CALLOUT_ERRNO", "5"},
925+
{"CALLOUT_DEVICE_PATH",
926+
"/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-14/14-0072"}};
917927

918928
checkCallouts(items);
919929
}
920930

921931
{
922932
// Callouts based on the I2C bus and address
923-
std::vector<std::string> items{"CALLOUT_ERRNO=5", "CALLOUT_IIC_BUS=14",
924-
"CALLOUT_IIC_ADDR=0x72"};
933+
std::map<std::string, std::string> items{{"CALLOUT_ERRNO", "5"},
934+
{"CALLOUT_IIC_BUS", "14"},
935+
{"CALLOUT_IIC_ADDR", "0x72"}};
925936
checkCallouts(items);
926937
}
927938

928939
{
929940
// Also based on I2C bus and address, but with bus = /dev/i2c-14
930-
std::vector<std::string> items{"CALLOUT_ERRNO=5", "CALLOUT_IIC_BUS=14",
931-
"CALLOUT_IIC_ADDR=0x72"};
941+
std::map<std::string, std::string> items{{"CALLOUT_ERRNO", "5"},
942+
{"CALLOUT_IIC_BUS", "14"},
943+
{"CALLOUT_IIC_ADDR", "0x72"}};
932944
checkCallouts(items);
933945
}
934946

935947
{
936948
// Callout not found
937-
std::vector<std::string> items{
938-
"CALLOUT_ERRNO=5",
939-
"CALLOUT_DEVICE_PATH=/sys/devices/platform/ahb/ahb:apb/"
940-
"ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-24/24-0012"};
949+
std::map<std::string, std::string> items{
950+
{"CALLOUT_ERRNO", "5"},
951+
{"CALLOUT_DEVICE_PATH",
952+
"/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a340.i2c-bus/i2c-24/24-0012"}};
941953

942954
AdditionalData ad{items};
943955
SRC src{entry, ad, dataIface};
@@ -951,8 +963,9 @@ TEST_F(SRCTest, DevicePathCalloutTest)
951963

952964
{
953965
// Callout not found
954-
std::vector<std::string> items{"CALLOUT_ERRNO=5", "CALLOUT_IIC_BUS=22",
955-
"CALLOUT_IIC_ADDR=0x99"};
966+
std::map<std::string, std::string> items{{"CALLOUT_ERRNO", "5"},
967+
{"CALLOUT_IIC_BUS", "22"},
968+
{"CALLOUT_IIC_ADDR", "0x99"}};
956969
AdditionalData ad{items};
957970
SRC src{entry, ad, dataIface};
958971

@@ -1290,8 +1303,8 @@ TEST_F(SRCTest, InventoryCalloutTestPriority)
12901303
entry.src.reasonCode = 0xABCD;
12911304
entry.subsystem = 0x42;
12921305

1293-
std::vector<std::string> adData{"CALLOUT_INVENTORY_PATH=motherboard",
1294-
"CALLOUT_PRIORITY=M"};
1306+
std::map<std::string, std::string> adData{
1307+
{"CALLOUT_INVENTORY_PATH", "motherboard"}, {"CALLOUT_PRIORITY", "M"}};
12951308
AdditionalData ad{adData};
12961309
NiceMock<MockDataInterface> dataIface;
12971310

@@ -1325,7 +1338,7 @@ TEST_F(SRCTest, TestPELSubsystem)
13251338
entry.subsystem = 0x42;
13261339

13271340
// Values for the SRC words pointed to above
1328-
std::vector<std::string> adData{"PEL_SUBSYSTEM=0x20"};
1341+
std::map<std::string, std::string> adData{{"PEL_SUBSYSTEM", "0x20"}};
13291342
AdditionalData ad{adData};
13301343
NiceMock<MockDataInterface> dataIface;
13311344

‎test/openpower-pels/user_header_test.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ TEST(UserHeaderTest, UseEventLogSevCritTermTest)
247247
// Leave off severity
248248

249249
MockDataInterface dataIface;
250-
std::vector<std::string> adData{"SEVERITY_DETAIL=SYSTEM_TERM"};
250+
std::map<std::string, std::string> adData{
251+
{"SEVERITY_DETAIL", "SYSTEM_TERM"}};
251252
AdditionalData ad{adData};
252253

253254
UserHeader uh(regEntry, phosphor::logging::Entry::Level::Critical, ad,
@@ -324,7 +325,7 @@ TEST(UserHeaderTest, UseEventLogPELSubsystem)
324325
regEntry.eventScope = 2;
325326

326327
MockDataInterface dataIface;
327-
std::vector<std::string> adData{"PEL_SUBSYSTEM=0x25"};
328+
std::map<std::string, std::string> adData{{"PEL_SUBSYSTEM", "0x25"}};
328329
AdditionalData ad{adData};
329330

330331
UserHeader uh(regEntry, phosphor::logging::Entry::Level::Critical, ad,
@@ -341,7 +342,7 @@ TEST(UserHeaderTest, UseEventLogPELSubsystem)
341342
regEntry.eventScope = 2;
342343

343344
MockDataInterface dataIface;
344-
std::vector<std::string> adData{"PEL_SUBSYSTEM=0x99"};
345+
std::map<std::string, std::string> adData{{"PEL_SUBSYSTEM", "0x99"}};
345346
AdditionalData ad{adData};
346347

347348
UserHeader uh(regEntry, phosphor::logging::Entry::Level::Critical, ad,
@@ -358,7 +359,7 @@ TEST(UserHeaderTest, UseEventLogPELSubsystem)
358359
regEntry.eventScope = 2;
359360

360361
MockDataInterface dataIface;
361-
std::vector<std::string> adData;
362+
std::map<std::string, std::string> adData;
362363
AdditionalData ad{adData};
363364

364365
UserHeader uh(regEntry, phosphor::logging::Entry::Level::Critical, ad,

0 commit comments

Comments
 (0)
Please sign in to comment.