blob: 0facc339066181cff93b44fa80a7296a9d8d1a0f [file] [log] [blame]
Matt Spinler97f7abc2019-11-06 09:40:23 -06001/**
2 * Copyright © 2019 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Matt Spinler89fa0822019-07-17 13:54:30 -050016#include "extensions/openpower-pels/manager.hpp"
17#include "log_manager.hpp"
Matt Spinlere6b48f12020-04-02 09:51:39 -050018#include "mocks.hpp"
Matt Spinler89fa0822019-07-17 13:54:30 -050019#include "pel_utils.hpp"
20
21#include <fstream>
22#include <regex>
Matt Spinlere6b48f12020-04-02 09:51:39 -050023#include <sdbusplus/test/sdbus_mock.hpp>
Matt Spinlera34ab722019-12-16 10:39:32 -060024#include <xyz/openbmc_project/Common/error.hpp>
Matt Spinler89fa0822019-07-17 13:54:30 -050025
26#include <gtest/gtest.h>
27
28using namespace openpower::pels;
29namespace fs = std::filesystem;
30
Matt Spinlere6b48f12020-04-02 09:51:39 -050031using ::testing::NiceMock;
Matt Spinler3dd17e92020-08-05 15:04:27 -050032using ::testing::Return;
Matt Spinlere6b48f12020-04-02 09:51:39 -050033
Matt Spinler05c2c6c2019-12-18 14:02:09 -060034class TestLogger
35{
36 public:
37 void log(const std::string& name, phosphor::logging::Entry::Level level,
38 const EventLogger::ADMap& additionalData)
39 {
40 errName = name;
41 errLevel = level;
42 ad = additionalData;
43 }
44
45 std::string errName;
46 phosphor::logging::Entry::Level errLevel;
47 EventLogger::ADMap ad;
48};
49
Matt Spinler89fa0822019-07-17 13:54:30 -050050class ManagerTest : public CleanPELFiles
51{
Matt Spinler6b1a5c82020-01-07 08:48:53 -060052 public:
Matt Spinlere6b48f12020-04-02 09:51:39 -050053 ManagerTest() :
54 bus(sdbusplus::get_mocked_new(&sdbusInterface)),
55 logManager(bus, "logging_path")
Matt Spinler6b1a5c82020-01-07 08:48:53 -060056 {
57 sd_event_default(&sdEvent);
Matt Spinler6b1a5c82020-01-07 08:48:53 -060058 }
59
60 ~ManagerTest()
61 {
62 sd_event_unref(sdEvent);
63 }
64
Matt Spinlere6b48f12020-04-02 09:51:39 -050065 NiceMock<sdbusplus::SdBusMock> sdbusInterface;
66 sdbusplus::bus::bus bus;
Matt Spinler6b1a5c82020-01-07 08:48:53 -060067 phosphor::logging::internal::Manager logManager;
68 sd_event* sdEvent;
Matt Spinler05c2c6c2019-12-18 14:02:09 -060069 TestLogger logger;
Matt Spinler89fa0822019-07-17 13:54:30 -050070};
71
72fs::path makeTempDir()
73{
74 char path[] = "/tmp/tempnameXXXXXX";
75 std::filesystem::path dir = mkdtemp(path);
76 return dir;
77}
78
Matt Spinler67456c22019-10-21 12:22:49 -050079std::optional<fs::path> findAnyPELInRepo()
80{
81 // PELs are named <timestamp>_<ID>
82 std::regex expr{"\\d+_\\d+"};
83
84 for (auto& f : fs::directory_iterator(getPELRepoPath() / "logs"))
85 {
86 if (std::regex_search(f.path().string(), expr))
87 {
88 return f.path();
89 }
90 }
91 return std::nullopt;
92}
93
Matt Spinler7e727a32020-07-07 15:00:17 -050094size_t countPELsInRepo()
95{
96 size_t count = 0;
97 std::regex expr{"\\d+_\\d+"};
98
99 for (auto& f : fs::directory_iterator(getPELRepoPath() / "logs"))
100 {
101 if (std::regex_search(f.path().string(), expr))
102 {
103 count++;
104 }
105 }
106 return count;
107}
108
Matt Spinlerff9cec22020-07-15 13:06:35 -0500109void deletePELFile(uint32_t id)
110{
111 char search[20];
112
113 sprintf(search, "\\d+_%.8X", id);
114 std::regex expr{search};
115
116 for (auto& f : fs::directory_iterator(getPELRepoPath() / "logs"))
117 {
118 if (std::regex_search(f.path().string(), expr))
119 {
120 fs::remove(f.path());
121 break;
122 }
123 }
124}
125
Matt Spinler89fa0822019-07-17 13:54:30 -0500126// Test that using the RAWPEL=<file> with the Manager::create() call gets
127// a PEL saved in the repository.
128TEST_F(ManagerTest, TestCreateWithPEL)
129{
Matt Spinlerc8705e22019-09-11 12:36:07 -0500130 std::unique_ptr<DataInterfaceBase> dataIface =
Matt Spinlere6b48f12020-04-02 09:51:39 -0500131 std::make_unique<MockDataInterface>();
Matt Spinler89fa0822019-07-17 13:54:30 -0500132
Matt Spinler05c2c6c2019-12-18 14:02:09 -0600133 openpower::pels::Manager manager{
134 logManager, std::move(dataIface),
135 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
136 std::placeholders::_2, std::placeholders::_3)};
Matt Spinler89fa0822019-07-17 13:54:30 -0500137
138 // Create a PEL, write it to a file, and pass that filename into
139 // the create function.
Matt Spinler42828bd2019-10-11 10:39:30 -0500140 auto data = pelDataFactory(TestPELType::pelSimple);
Matt Spinler89fa0822019-07-17 13:54:30 -0500141
142 fs::path pelFilename = makeTempDir() / "rawpel";
143 std::ofstream pelFile{pelFilename};
Matt Spinler42828bd2019-10-11 10:39:30 -0500144 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
Matt Spinler89fa0822019-07-17 13:54:30 -0500145 pelFile.close();
146
147 std::string adItem = "RAWPEL=" + pelFilename.string();
148 std::vector<std::string> additionalData{adItem};
149 std::vector<std::string> associations;
150
Matt Spinler367144c2019-09-19 15:33:52 -0500151 manager.create("error message", 42, 0,
152 phosphor::logging::Entry::Level::Error, additionalData,
Matt Spinler89fa0822019-07-17 13:54:30 -0500153 associations);
154
Matt Spinler67456c22019-10-21 12:22:49 -0500155 // Find the file in the PEL repository directory
156 auto pelPathInRepo = findAnyPELInRepo();
Matt Spinler89fa0822019-07-17 13:54:30 -0500157
Matt Spinler67456c22019-10-21 12:22:49 -0500158 EXPECT_TRUE(pelPathInRepo);
Matt Spinler89fa0822019-07-17 13:54:30 -0500159
Matt Spinler475e5742019-07-18 16:09:49 -0500160 // Now remove it based on its OpenBMC event log ID
161 manager.erase(42);
162
Matt Spinler67456c22019-10-21 12:22:49 -0500163 pelPathInRepo = findAnyPELInRepo();
Matt Spinler475e5742019-07-18 16:09:49 -0500164
Matt Spinler67456c22019-10-21 12:22:49 -0500165 EXPECT_FALSE(pelPathInRepo);
Matt Spinler475e5742019-07-18 16:09:49 -0500166
Matt Spinler89fa0822019-07-17 13:54:30 -0500167 fs::remove_all(pelFilename.parent_path());
168}
Matt Spinler67456c22019-10-21 12:22:49 -0500169
Matt Spinlere95fd012020-01-07 12:53:16 -0600170TEST_F(ManagerTest, TestCreateWithInvalidPEL)
171{
172 std::unique_ptr<DataInterfaceBase> dataIface =
Matt Spinlere6b48f12020-04-02 09:51:39 -0500173 std::make_unique<MockDataInterface>();
Matt Spinlere95fd012020-01-07 12:53:16 -0600174
175 openpower::pels::Manager manager{
176 logManager, std::move(dataIface),
177 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
178 std::placeholders::_2, std::placeholders::_3)};
179
180 // Create a PEL, write it to a file, and pass that filename into
181 // the create function.
182 auto data = pelDataFactory(TestPELType::pelSimple);
183
184 // Truncate it to make it invalid.
185 data.resize(200);
186
187 fs::path pelFilename = makeTempDir() / "rawpel";
188 std::ofstream pelFile{pelFilename};
189 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
190 pelFile.close();
191
192 std::string adItem = "RAWPEL=" + pelFilename.string();
193 std::vector<std::string> additionalData{adItem};
194 std::vector<std::string> associations;
195
196 manager.create("error message", 42, 0,
197 phosphor::logging::Entry::Level::Error, additionalData,
198 associations);
199
200 // Run the event loop to log the bad PEL event
201 sdeventplus::Event e{sdEvent};
202 e.run(std::chrono::milliseconds(1));
203
204 PEL invalidPEL{data};
205 EXPECT_EQ(logger.errName, "org.open_power.Logging.Error.BadHostPEL");
206 EXPECT_EQ(logger.errLevel, phosphor::logging::Entry::Level::Error);
207 EXPECT_EQ(std::stoi(logger.ad["PLID"], nullptr, 16), invalidPEL.plid());
208 EXPECT_EQ(logger.ad["OBMC_LOG_ID"], "42");
209 EXPECT_EQ(logger.ad["SRC"], (*invalidPEL.primarySRC())->asciiString());
210 EXPECT_EQ(logger.ad["PEL_SIZE"], std::to_string(data.size()));
211
Matt Spinlerfe721892020-04-02 10:28:08 -0500212 // Check that the bad PEL data was saved to a file.
213 auto badPELData = readPELFile(getPELRepoPath() / "badPEL");
214 EXPECT_EQ(*badPELData, data);
215
Matt Spinlere95fd012020-01-07 12:53:16 -0600216 fs::remove_all(pelFilename.parent_path());
217}
218
Matt Spinler67456c22019-10-21 12:22:49 -0500219// Test that the message registry can be used to build a PEL.
220TEST_F(ManagerTest, TestCreateWithMessageRegistry)
221{
222 const auto registry = R"(
223{
224 "PELs":
225 [
226 {
227 "Name": "xyz.openbmc_project.Error.Test",
228 "Subsystem": "power_supply",
229 "ActionFlags": ["service_action", "report"],
230 "SRC":
231 {
232 "ReasonCode": "0x2030"
Harisuddin Mohamed Isa0f717e12020-01-15 20:05:33 +0800233 },
234 "Documentation":
235 {
236 "Description": "A PGOOD Fault",
237 "Message": "PS had a PGOOD Fault"
Matt Spinler67456c22019-10-21 12:22:49 -0500238 }
Matt Spinler30ddc9f2020-07-16 15:39:59 -0500239 },
240 {
241 "Name": "xyz.openbmc_project.Logging.Error.Default",
242 "Subsystem": "bmc_firmware",
243 "SRC":
244 {
245 "ReasonCode": "0x2031"
246 },
247 "Documentation":
248 {
249 "Description": "The entry used when no match found",
250 "Message": "This is a generic SRC"
251 }
Matt Spinler67456c22019-10-21 12:22:49 -0500252 }
253 ]
254}
255)";
256
Matt Spinler0d804ef2020-05-12 16:16:26 -0500257 auto path = getPELReadOnlyDataPath();
Matt Spinlerd4ffb652019-11-12 14:16:14 -0600258 fs::create_directories(path);
259 path /= "message_registry.json";
260
Matt Spinler67456c22019-10-21 12:22:49 -0500261 std::ofstream registryFile{path};
262 registryFile << registry;
263 registryFile.close();
264
Matt Spinler67456c22019-10-21 12:22:49 -0500265 std::unique_ptr<DataInterfaceBase> dataIface =
Matt Spinlere6b48f12020-04-02 09:51:39 -0500266 std::make_unique<MockDataInterface>();
Matt Spinler67456c22019-10-21 12:22:49 -0500267
Matt Spinler05c2c6c2019-12-18 14:02:09 -0600268 openpower::pels::Manager manager{
269 logManager, std::move(dataIface),
270 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
271 std::placeholders::_2, std::placeholders::_3)};
Matt Spinler67456c22019-10-21 12:22:49 -0500272
Matt Spinler30ddc9f2020-07-16 15:39:59 -0500273 std::vector<std::string> additionalData{"FOO=BAR"};
Matt Spinler67456c22019-10-21 12:22:49 -0500274 std::vector<std::string> associations;
275
276 // Create the event log to create the PEL from.
277 manager.create("xyz.openbmc_project.Error.Test", 33, 0,
278 phosphor::logging::Entry::Level::Error, additionalData,
279 associations);
280
281 // Ensure a PEL was created in the repository
282 auto pelFile = findAnyPELInRepo();
283 ASSERT_TRUE(pelFile);
284
285 auto data = readPELFile(*pelFile);
286 PEL pel(*data);
287
288 // Spot check it. Other testcases cover the details.
289 EXPECT_TRUE(pel.valid());
290 EXPECT_EQ(pel.obmcLogID(), 33);
291 EXPECT_EQ(pel.primarySRC().value()->asciiString(),
292 "BD612030 ");
Vijay Lobod354a392021-06-01 16:21:02 -0500293 // Check if the eventId creation is good
294 EXPECT_EQ(manager.getEventId(pel),
295 "BD612030 00000055 00000010 00000000 00000000 00000000 00000000 "
296 "00000000 00000000");
Matt Spinler67456c22019-10-21 12:22:49 -0500297
298 // Remove it
299 manager.erase(33);
300 pelFile = findAnyPELInRepo();
301 EXPECT_FALSE(pelFile);
302
303 // Create an event log that can't be found in the registry.
Matt Spinler30ddc9f2020-07-16 15:39:59 -0500304 // In this case, xyz.openbmc_project.Logging.Error.Default will
305 // be used as the key instead to find a registry match.
306 manager.create("xyz.openbmc_project.Error.Foo", 42, 0,
Matt Spinler67456c22019-10-21 12:22:49 -0500307 phosphor::logging::Entry::Level::Error, additionalData,
308 associations);
309
Matt Spinler30ddc9f2020-07-16 15:39:59 -0500310 // Ensure a PEL was still created in the repository
Matt Spinler67456c22019-10-21 12:22:49 -0500311 pelFile = findAnyPELInRepo();
Matt Spinler30ddc9f2020-07-16 15:39:59 -0500312 ASSERT_TRUE(pelFile);
313
314 data = readPELFile(*pelFile);
315 PEL newPEL(*data);
316
317 EXPECT_TRUE(newPEL.valid());
318 EXPECT_EQ(newPEL.obmcLogID(), 42);
319 EXPECT_EQ(newPEL.primarySRC().value()->asciiString(),
320 "BD8D2031 ");
321
322 // Check for both the original AdditionalData item as well as
323 // the ERROR_NAME item that should contain the error message
324 // property that wasn't found.
325 std::string errorName;
326 std::string adItem;
327
328 for (const auto& section : newPEL.optionalSections())
329 {
330 if (SectionID::userData == static_cast<SectionID>(section->header().id))
331 {
332 if (UserDataFormat::json ==
333 static_cast<UserDataFormat>(section->header().subType))
334 {
335 auto ud = static_cast<UserData*>(section.get());
336
337 // Check that there was a UserData section added that
338 // contains debug details about the device.
339 const auto& d = ud->data();
340 std::string jsonString{d.begin(), d.end()};
341 auto json = nlohmann::json::parse(jsonString);
342
343 if (json.contains("ERROR_NAME"))
344 {
345 errorName = json["ERROR_NAME"].get<std::string>();
346 }
347
348 if (json.contains("FOO"))
349 {
350 adItem = json["FOO"].get<std::string>();
351 }
352 }
353 }
354 if (!errorName.empty())
355 {
356 break;
357 }
358 }
359
360 EXPECT_EQ(errorName, "xyz.openbmc_project.Error.Foo");
361 EXPECT_EQ(adItem, "BAR");
Matt Spinler67456c22019-10-21 12:22:49 -0500362}
Matt Spinlera34ab722019-12-16 10:39:32 -0600363
364TEST_F(ManagerTest, TestDBusMethods)
365{
Matt Spinlera34ab722019-12-16 10:39:32 -0600366 std::unique_ptr<DataInterfaceBase> dataIface =
Matt Spinlere6b48f12020-04-02 09:51:39 -0500367 std::make_unique<MockDataInterface>();
Matt Spinlera34ab722019-12-16 10:39:32 -0600368
Matt Spinler05c2c6c2019-12-18 14:02:09 -0600369 Manager manager{logManager, std::move(dataIface),
370 std::bind(std::mem_fn(&TestLogger::log), &logger,
371 std::placeholders::_1, std::placeholders::_2,
372 std::placeholders::_3)};
Matt Spinlera34ab722019-12-16 10:39:32 -0600373
374 // Create a PEL, write it to a file, and pass that filename into
375 // the create function so there's one in the repo.
376 auto data = pelDataFactory(TestPELType::pelSimple);
377
378 fs::path pelFilename = makeTempDir() / "rawpel";
379 std::ofstream pelFile{pelFilename};
380 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
381 pelFile.close();
382
383 std::string adItem = "RAWPEL=" + pelFilename.string();
384 std::vector<std::string> additionalData{adItem};
385 std::vector<std::string> associations;
386
387 manager.create("error message", 42, 0,
388 phosphor::logging::Entry::Level::Error, additionalData,
389 associations);
390
391 // getPELFromOBMCID
392 auto newData = manager.getPELFromOBMCID(42);
393 EXPECT_EQ(newData.size(), data.size());
394
395 // Read the PEL to get the ID for later
396 PEL pel{newData};
397 auto id = pel.id();
398
399 EXPECT_THROW(
400 manager.getPELFromOBMCID(id + 1),
401 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
402
403 // getPEL
404 auto unixfd = manager.getPEL(id);
405
406 // Get the size
407 struct stat s;
408 int r = fstat(unixfd, &s);
409 ASSERT_EQ(r, 0);
410 auto size = s.st_size;
411
412 // Open the FD and check the contents
413 FILE* fp = fdopen(unixfd, "r");
414 ASSERT_NE(fp, nullptr);
415
416 std::vector<uint8_t> fdData;
417 fdData.resize(size);
418 r = fread(fdData.data(), 1, size, fp);
419 EXPECT_EQ(r, size);
420
421 EXPECT_EQ(newData, fdData);
422
423 fclose(fp);
424
Matt Spinler05c2c6c2019-12-18 14:02:09 -0600425 // Run the event loop to close the FD
426 sdeventplus::Event e{sdEvent};
427 e.run(std::chrono::milliseconds(1));
428
Matt Spinlera34ab722019-12-16 10:39:32 -0600429 EXPECT_THROW(
430 manager.getPEL(id + 1),
431 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
432
433 // hostAck
434 manager.hostAck(id);
435
436 EXPECT_THROW(
437 manager.hostAck(id + 1),
438 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
439
440 // hostReject
441 manager.hostReject(id, Manager::RejectionReason::BadPEL);
Matt Spinler05c2c6c2019-12-18 14:02:09 -0600442
443 // Run the event loop to log the bad PEL event
444 e.run(std::chrono::milliseconds(1));
445
446 EXPECT_EQ(logger.errName, "org.open_power.Logging.Error.SentBadPELToHost");
447 EXPECT_EQ(id, std::stoi(logger.ad["BAD_ID"], nullptr, 16));
448
Matt Spinlera34ab722019-12-16 10:39:32 -0600449 manager.hostReject(id, Manager::RejectionReason::HostFull);
450
451 EXPECT_THROW(
452 manager.hostReject(id + 1, Manager::RejectionReason::BadPEL),
453 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
454
455 fs::remove_all(pelFilename.parent_path());
Ramesh Iyyarf4203c42021-06-24 06:09:23 -0500456
457 // GetPELIdFromBMCLogId
458 EXPECT_EQ(pel.id(), manager.getPELIdFromBMCLogId(pel.obmcLogID()));
459 EXPECT_THROW(
460 manager.getPELIdFromBMCLogId(pel.obmcLogID() + 1),
461 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
Ramesh Iyyar530efbf2021-06-24 06:22:22 -0500462
463 // GetBMCLogIdFromPELId
464 EXPECT_EQ(pel.obmcLogID(), manager.getBMCLogIdFromPELId(pel.id()));
465 EXPECT_THROW(
466 manager.getBMCLogIdFromPELId(pel.id() + 1),
467 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
Matt Spinlera34ab722019-12-16 10:39:32 -0600468}
Matt Spinler19e72902020-01-24 11:05:20 -0600469
470// An ESEL from the wild
471const std::string esel{
472 "00 00 df 00 00 00 00 20 00 04 12 01 6f aa 00 00 "
473 "50 48 00 30 01 00 33 00 00 00 00 07 5c 69 cc 0d 00 00 00 07 5c d5 50 db "
474 "42 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 90 00 00 4e 90 00 00 4e "
475 "55 48 00 18 01 00 09 00 8a 03 40 00 00 00 00 00 ff ff 00 00 00 00 00 00 "
476 "50 53 00 50 01 01 00 00 02 00 00 09 33 2d 00 48 00 00 00 e0 00 00 10 00 "
477 "00 00 00 00 00 20 00 00 00 0c 00 02 00 00 00 fa 00 00 0c e4 00 00 00 12 "
478 "42 43 38 41 33 33 32 44 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
479 "20 20 20 20 20 20 20 20 55 44 00 1c 01 06 01 00 02 54 41 4b 00 00 00 06 "
480 "00 00 00 55 00 01 f9 20 00 00 00 00 55 44 00 24 01 06 01 00 01 54 41 4b "
481 "00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 23 01 00 02 00 05 00 00 "
482 "55 44 00 0c 01 0b 01 00 0f 01 00 00 55 44 00 10 01 04 01 00 0f 9f de 6a "
483 "00 01 00 00 55 44 00 7c 00 0c 01 00 00 13 0c 02 00 fa 0c e4 16 00 01 2c "
484 "0c 1c 16 00 00 fa 0a f0 14 00 00 fa 0b b8 14 00 00 be 09 60 12 00 01 2c "
485 "0d 7a 12 00 00 fa 0c 4e 10 00 00 fa 0c e4 10 00 00 be 0a 8c 16 00 01 2c "
486 "0c 1c 16 00 01 09 09 f6 16 00 00 fa 09 f6 14 00 00 fa 0b b8 14 00 00 fa "
487 "0a f0 14 00 00 be 08 ca 12 00 01 2c 0c e4 12 00 00 fa 0b 54 10 00 00 fa "
488 "0c 2d 10 00 00 be 08 ca 55 44 00 58 01 03 01 00 00 00 00 00 00 05 31 64 "
489 "00 00 00 00 00 05 0d d4 00 00 00 00 40 5f 06 e0 00 00 00 00 40 5d d2 00 "
490 "00 00 00 00 40 57 d3 d0 00 00 00 00 40 58 f6 a0 00 00 00 00 40 54 c9 34 "
491 "00 00 00 00 40 55 9a 10 00 00 00 00 40 4c 0a 80 00 00 00 00 00 00 27 14 "
492 "55 44 01 84 01 01 01 00 48 6f 73 74 62 6f 6f 74 20 42 75 69 6c 64 20 49 "
493 "44 3a 20 68 6f 73 74 62 6f 6f 74 2d 66 65 63 37 34 64 66 2d 70 30 61 38 "
494 "37 64 63 34 2f 68 62 69 63 6f 72 65 2e 62 69 6e 00 49 42 4d 2d 77 69 74 "
495 "68 65 72 73 70 6f 6f 6e 2d 4f 50 39 2d 76 32 2e 34 2d 39 2e 32 33 34 0a "
496 "09 6f 70 2d 62 75 69 6c 64 2d 38 32 66 34 63 66 30 0a 09 62 75 69 6c 64 "
497 "72 6f 6f 74 2d 32 30 31 39 2e 30 35 2e 32 2d 31 30 2d 67 38 39 35 39 31 "
498 "31 34 0a 09 73 6b 69 62 6f 6f 74 2d 76 36 2e 35 2d 31 38 2d 67 34 37 30 "
499 "66 66 62 35 66 32 39 64 37 0a 09 68 6f 73 74 62 6f 6f 74 2d 66 65 63 37 "
500 "34 64 66 2d 70 30 61 38 37 64 63 34 0a 09 6f 63 63 2d 65 34 35 39 37 61 "
501 "62 0a 09 6c 69 6e 75 78 2d 35 2e 32 2e 31 37 2d 6f 70 65 6e 70 6f 77 65 "
502 "72 31 2d 70 64 64 63 63 30 33 33 0a 09 70 65 74 69 74 62 6f 6f 74 2d 76 "
503 "31 2e 31 30 2e 34 0a 09 6d 61 63 68 69 6e 65 2d 78 6d 6c 2d 63 36 32 32 "
504 "63 62 35 2d 70 37 65 63 61 62 33 64 0a 09 68 6f 73 74 62 6f 6f 74 2d 62 "
505 "69 6e 61 72 69 65 73 2d 36 36 65 39 61 36 30 0a 09 63 61 70 70 2d 75 63 "
506 "6f 64 65 2d 70 39 2d 64 64 32 2d 76 34 0a 09 73 62 65 2d 36 30 33 33 30 "
507 "65 30 0a 09 68 63 6f 64 65 2d 68 77 30 39 32 31 31 39 61 2e 6f 70 6d 73 "
508 "74 0a 00 00 55 44 00 70 01 04 01 00 0f 9f de 6a 00 05 00 00 07 5f 1d f4 "
509 "30 32 43 59 34 37 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
510 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
511 "0b ac 54 02 59 41 31 39 33 34 36 39 37 30 35 38 00 00 00 00 00 00 05 22 "
512 "a1 58 01 8a 00 58 40 20 17 18 4d 2c 00 00 00 fc 01 a1 00 00 55 44 00 14 "
513 "01 08 01 00 00 00 00 01 00 00 00 5a 00 00 00 05 55 44 03 fc 01 15 31 00 "
514 "01 28 00 42 46 41 50 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 f4 "
515 "00 00 00 00 00 00 03 f4 00 00 00 0b 00 00 00 00 00 00 00 3d 2c 9b c2 84 "
516 "00 00 01 e4 00 48 43 4f fb ed 70 b1 00 00 02 01 00 00 00 00 00 00 00 09 "
517 "00 00 00 00 00 11 bd 20 00 00 00 00 00 01 f8 80 00 00 00 00 00 00 00 01 "
518 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 01 2c "
519 "00 00 00 00 00 00 07 d0 00 00 00 00 00 00 0c 1c 00 00 00 64 00 00 00 3d "
520 "2c 9b d1 11 00 00 01 e4 00 48 43 4f fb ed 70 b1 00 00 02 01 00 00 00 00 "
521 "00 00 00 0a 00 00 00 00 00 13 b5 a0 00 00 00 00 00 01 f8 80 00 00 00 00 "
522 "00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 "
523 "00 00 00 be 00 00 00 00 00 00 07 d0 00 00 00 00 00 00 0a 8c 00 00 00 64 "
524 "00 00 00 3d 2c 9b df 98 00 00 01 e4 00 48 43 4f fb ed 70 b1 00 00 02 01 "
525 "00 00 00 00 00 00 00 0b 00 00 00 00 00 15 ae 20 00 00 00 00 00 01 f8 80 "
526 "00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 "
527 "00 00 00 00 00 00 00 fa 00 00 00 00 00 00 07 d0 00 00 00 00 00 00 0c e4 "
528 "00 00 00 64 00 00 00 3d 2c 9b ea b7 00 00 01 e4 00 48 43 4f fb ed 70 b1 "
529 "00 00 02 01 00 00 00 00 00 00 00 0c 00 00 00 00 00 17 a6 a0 00 00 00 00 "
530 "00 01 f8 80 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 "
531 "00 00 00 12 00 00 00 00 00 00 00 fa 00 00 00 00 00 00 07 d0 00 00 00 00 "
532 "00 00 0c 4e 00 00 00 64 00 00 00 3d 2c 9b f6 27 00 00 01 e4 00 48 43 4f "
533 "fb ed 70 b1 00 00 02 01 00 00 00 00 00 00 00 0d 00 00 00 00 00 19 9f 20 "
534 "00 00 00 00 00 01 f8 80 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 "
535 "00 00 00 00 00 00 00 12 00 00 00 00 00 00 01 2c 00 00 00 00 00 00 07 d0 "
536 "00 00 00 00 00 00 0d 7a 00 00 00 64 00 00 00 3d 2c 9c 05 75 00 00 01 e4 "
537 "00 48 43 4f fb ed 70 b1 00 00 02 01 00 00 00 00 00 00 00 0e 00 00 00 00 "
538 "00 1b 97 a0 00 00 00 00 00 01 f8 80 00 00 00 00 00 00 00 01 00 00 00 00 "
539 "00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 be 00 00 00 00 "
540 "00 00 07 d0 00 00 00 00 00 00 09 60 00 00 00 64 00 00 00 3d 2c 9c 11 29 "
541 "00 00 01 e4 00 48 43 4f fb ed 70 b1 00 00 02 01 00 00 00 00 00 00 00 0f "
542 "00 00 00 00 00 1d 90 20 00 00 00 00 00 01 f8 80 00 00 00 00 00 00 00 01 "
543 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 fa "
544 "00 00 00 00 00 00 07 d0 00 00 00 00 00 00 0b b8 00 00 00 64 00 00 00 3d "
545 "2c 9c 1c 45 00 00 01 e4 00 48 43 4f fb ed 70 b1 00 00 02 01 00 00 00 00 "
546 "00 00 00 10 00 00 00 00 00 1f 88 a0 00 00 00 00 00 01 f8 80 00 00 00 00 "
547 "00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 "
548 "00 00 00 fa 00 00 00 00 00 00 07 d0 00 00 00 00 00 00 0a f0 00 00 00 64 "
549 "00 00 00 3d 2c 9c 2b 14 00 00 01 e4 00 48 43 4f fb ed 70 b1 00 00 02 01 "
550 "00 00 00 00 00 00 00 11 00 00 00 00 00 21 81 20 00 00 00 00 00 01 f8 80 "
551 "00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 "
552 "00 00 00 00 00 00 01 2c 00 00 00 00 00 00 07 d0 00 00 00 00 00 00 0c 1c "
553 "00 00 00 64 00 00 00 3d 2d 6d 8f 9e 00 00 01 e4 00 00 43 4f 52 d7 9c 36 "
554 "00 00 04 73 00 00 00 1c 00 00 00 3d 2d 6d 99 ac 00 00 01 e4 00 10 43 4f "
555 "3f f2 02 3d 00 00 05 58 00 00 00 00 02 00 00 01 00 00 00 00 00 00 00 40 "
556 "00 00 00 2c 55 44 00 30 01 15 31 00 01 28 00 42 46 41 50 49 5f 44 42 47 "
557 "00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 28 00 00 00 00 "
558 "00 00 00 00 55 44 01 74 01 15 31 00 01 28 00 42 46 41 50 49 5f 49 00 00 "
559 "00 00 00 00 00 00 00 00 00 00 01 6c 00 00 00 00 00 00 01 6c 00 00 00 0b "
560 "00 00 00 00 00 00 00 3c 0d 52 18 5e 00 00 01 e4 00 08 43 4f 46 79 94 13 "
561 "00 00 0a 5b 00 00 00 00 00 00 2c 00 00 00 00 24 00 00 00 3c 0d 6b 26 6c "
562 "00 00 01 e4 00 00 43 4f 4e 9b 18 74 00 00 01 03 00 00 00 1c 00 00 00 3c "
563 "12 b9 2d 13 00 00 01 e4 00 00 43 4f ea 31 ed d4 00 00 05 c4 00 00 00 1c "
564 "00 00 00 3c 13 02 73 53 00 00 01 e4 00 00 43 4f ea 31 ed d4 00 00 05 c4 "
565 "00 00 00 1c 00 00 00 3c 13 04 7c 94 00 00 01 e4 00 00 43 4f ea 31 ed d4 "
566 "00 00 05 c4 00 00 00 1c 00 00 00 3c 13 06 ad e1 00 00 01 e4 00 00 43 4f "
567 "ea 31 ed d4 00 00 05 c4 00 00 00 1c 00 00 00 3c 13 07 3f 77 00 00 01 e4 "
568 "00 00 43 4f 5e 4a 55 32 00 00 10 f2 00 00 00 1c 00 00 00 3c 13 07 4e e4 "
569 "00 00 01 e4 00 00 43 4f 5e 4a 55 32 00 00 0d 68 00 00 00 1c 00 00 00 3c "
570 "13 36 79 18 00 00 01 e4 00 00 43 4f ea 31 ed d4 00 00 05 c4 00 00 00 1c "
571 "00 00 00 3d 2c 9c 36 70 00 00 01 e4 00 00 43 4f 23 45 90 97 00 00 02 47 "
572 "00 00 00 1c 00 00 00 3d 2d 6d a3 ed 00 00 01 e4 00 08 43 4f 74 3a 5b 1a "
573 "00 00 04 cc 00 00 00 00 02 00 00 01 00 00 00 24 55 44 00 30 01 15 31 00 "
574 "01 28 00 42 53 43 41 4e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 "
575 "00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00"};
576
577TEST_F(ManagerTest, TestESELToRawData)
578{
579 auto data = Manager::eselToRawData(esel);
580
581 EXPECT_EQ(data.size(), 2464);
582
583 PEL pel{data};
584 EXPECT_TRUE(pel.valid());
585}
586
587TEST_F(ManagerTest, TestCreateWithESEL)
588{
589 std::unique_ptr<DataInterfaceBase> dataIface =
Matt Spinlere6b48f12020-04-02 09:51:39 -0500590 std::make_unique<MockDataInterface>();
Matt Spinler19e72902020-01-24 11:05:20 -0600591
592 openpower::pels::Manager manager{
593 logManager, std::move(dataIface),
594 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
595 std::placeholders::_2, std::placeholders::_3)};
596
597 {
598 std::string adItem = "ESEL=" + esel;
599 std::vector<std::string> additionalData{adItem};
600 std::vector<std::string> associations;
601
602 manager.create("error message", 37, 0,
603 phosphor::logging::Entry::Level::Error, additionalData,
604 associations);
605
606 auto data = manager.getPELFromOBMCID(37);
607 PEL pel{data};
608 EXPECT_TRUE(pel.valid());
609 }
610
611 // Now an invalid one
612 {
613 std::string adItem = "ESEL=" + esel;
614
615 // Crop it
616 adItem.resize(adItem.size() - 300);
617
618 std::vector<std::string> additionalData{adItem};
619 std::vector<std::string> associations;
620
621 manager.create("error message", 38, 0,
622 phosphor::logging::Entry::Level::Error, additionalData,
623 associations);
624
625 EXPECT_THROW(
626 manager.getPELFromOBMCID(38),
627 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
628
629 // Run the event loop to log the bad PEL event
630 sdeventplus::Event e{sdEvent};
631 e.run(std::chrono::milliseconds(1));
632
633 EXPECT_EQ(logger.errName, "org.open_power.Logging.Error.BadHostPEL");
634 EXPECT_EQ(logger.errLevel, phosphor::logging::Entry::Level::Error);
635 }
636}
Matt Spinler7e727a32020-07-07 15:00:17 -0500637
638// Test that PELs will be pruned when necessary
639TEST_F(ManagerTest, TestPruning)
640{
641 sdeventplus::Event e{sdEvent};
642
643 std::unique_ptr<DataInterfaceBase> dataIface =
644 std::make_unique<MockDataInterface>();
645
646 openpower::pels::Manager manager{
647 logManager, std::move(dataIface),
648 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
649 std::placeholders::_2, std::placeholders::_3)};
650
651 // Create 25 1000B (4096B on disk each, which is what is used for pruning)
652 // BMC non-informational PELs in the 100KB repository. After the 24th one,
653 // the repo will be 96% full and a prune should be triggered to remove all
654 // but 7 to get under 30% full. Then when the 25th is added there will be
655 // 8 left.
656
657 auto dir = makeTempDir();
658 for (int i = 1; i <= 25; i++)
659 {
660 auto data = pelFactory(42, 'O', 0x40, 0x8800, 1000);
661
662 fs::path pelFilename = dir / "rawpel";
663 std::ofstream pelFile{pelFilename};
664 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
665 pelFile.close();
666
667 std::string adItem = "RAWPEL=" + pelFilename.string();
668 std::vector<std::string> additionalData{adItem};
669 std::vector<std::string> associations;
670
671 manager.create("error message", 42, 0,
672 phosphor::logging::Entry::Level::Error, additionalData,
673 associations);
674
675 // Simulate the code getting back to the event loop
676 // after each create.
677 e.run(std::chrono::milliseconds(1));
678
679 if (i < 24)
680 {
681 EXPECT_EQ(countPELsInRepo(), i);
682 }
683 else if (i == 24)
684 {
685 // Prune occured
686 EXPECT_EQ(countPELsInRepo(), 7);
687 }
688 else // i == 25
689 {
690 EXPECT_EQ(countPELsInRepo(), 8);
691 }
692 }
693
694 try
695 {
696 // Make sure the 8 newest ones are still found.
697 for (uint32_t i = 0; i < 8; i++)
698 {
699 manager.getPEL(0x50000012 + i);
700 }
701 }
702 catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
703 {
704 ADD_FAILURE() << "PELs should have all been found";
705 }
706
707 fs::remove_all(dir);
708}
Matt Spinlerff9cec22020-07-15 13:06:35 -0500709
710// Test that manually deleting a PEL file will be recognized by the code.
711TEST_F(ManagerTest, TestPELManualDelete)
712{
713 sdeventplus::Event e{sdEvent};
714
715 std::unique_ptr<DataInterfaceBase> dataIface =
716 std::make_unique<MockDataInterface>();
717
718 openpower::pels::Manager manager{
719 logManager, std::move(dataIface),
720 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
721 std::placeholders::_2, std::placeholders::_3)};
722
723 auto data = pelDataFactory(TestPELType::pelSimple);
724 auto dir = makeTempDir();
725 fs::path pelFilename = dir / "rawpel";
726
727 std::string adItem = "RAWPEL=" + pelFilename.string();
728 std::vector<std::string> additionalData{adItem};
729 std::vector<std::string> associations;
730
731 // Add 20 PELs, they will get incrementing IDs like
732 // 0x50000001, 0x50000002, etc.
733 for (int i = 1; i <= 20; i++)
734 {
735 std::ofstream pelFile{pelFilename};
736 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
737 pelFile.close();
738
739 manager.create("error message", 42, 0,
740 phosphor::logging::Entry::Level::Error, additionalData,
741 associations);
742
743 // Sanity check this ID is really there so we can test
744 // it was deleted later. This will throw an exception if
745 // not present.
746 manager.getPEL(0x50000000 + i);
747
748 // Run an event loop pass where the internal FD is deleted
749 // after the getPEL function call.
750 e.run(std::chrono::milliseconds(1));
751 }
752
753 EXPECT_EQ(countPELsInRepo(), 20);
754
755 deletePELFile(0x50000001);
756
757 // Run a single event loop pass so the inotify event can run
758 e.run(std::chrono::milliseconds(1));
759
760 EXPECT_EQ(countPELsInRepo(), 19);
761
762 EXPECT_THROW(
763 manager.getPEL(0x50000001),
764 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
765
766 // Delete a few more, they should all get handled in the same
767 // event loop pass
768 std::vector<uint32_t> toDelete{0x50000002, 0x50000003, 0x50000004,
769 0x50000005, 0x50000006};
770 std::for_each(toDelete.begin(), toDelete.end(),
771 [](auto i) { deletePELFile(i); });
772
773 e.run(std::chrono::milliseconds(1));
774
775 EXPECT_EQ(countPELsInRepo(), 14);
776
777 std::for_each(toDelete.begin(), toDelete.end(), [&manager](const auto i) {
778 EXPECT_THROW(
779 manager.getPEL(i),
780 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
781 });
782
783 fs::remove_all(dir);
784}
785
786// Test that deleting all PELs at once is handled OK.
787TEST_F(ManagerTest, TestPELManualDeleteAll)
788{
789 sdeventplus::Event e{sdEvent};
790
791 std::unique_ptr<DataInterfaceBase> dataIface =
792 std::make_unique<MockDataInterface>();
793
794 openpower::pels::Manager manager{
795 logManager, std::move(dataIface),
796 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
797 std::placeholders::_2, std::placeholders::_3)};
798
799 auto data = pelDataFactory(TestPELType::pelSimple);
800 auto dir = makeTempDir();
801 fs::path pelFilename = dir / "rawpel";
802
803 std::string adItem = "RAWPEL=" + pelFilename.string();
804 std::vector<std::string> additionalData{adItem};
805 std::vector<std::string> associations;
806
807 // Add 200 PELs, they will get incrementing IDs like
808 // 0x50000001, 0x50000002, etc.
809 for (int i = 1; i <= 200; i++)
810 {
811 std::ofstream pelFile{pelFilename};
812 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
813 pelFile.close();
814
815 manager.create("error message", 42, 0,
816 phosphor::logging::Entry::Level::Error, additionalData,
817 associations);
818
819 // Sanity check this ID is really there so we can test
820 // it was deleted later. This will throw an exception if
821 // not present.
822 manager.getPEL(0x50000000 + i);
823
824 // Run an event loop pass where the internal FD is deleted
825 // after the getPEL function call.
826 e.run(std::chrono::milliseconds(1));
827 }
828
829 // Delete them all at once
830 auto logPath = getPELRepoPath() / "logs";
Sumit Kumar1d8835b2021-06-07 09:35:30 -0500831 std::string cmd = "rm " + logPath.string() + "/*_*";
Patrick Williamsd26fa3e2021-04-21 15:22:23 -0500832
833 {
834 auto rc = system(cmd.c_str());
835 EXPECT_EQ(rc, 0);
836 }
Matt Spinlerff9cec22020-07-15 13:06:35 -0500837
838 EXPECT_EQ(countPELsInRepo(), 0);
839
840 // It will take 5 event loop passes to process them all
841 for (int i = 0; i < 5; i++)
842 {
843 e.run(std::chrono::milliseconds(1));
844 }
845
846 for (int i = 1; i <= 200; i++)
847 {
848 EXPECT_THROW(
849 manager.getPEL(0x50000000 + i),
850 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
851 }
852
853 fs::remove_all(dir);
854}
Matt Spinler3dd17e92020-08-05 15:04:27 -0500855
856// Test that fault LEDs are turned on when PELs are created
857TEST_F(ManagerTest, TestServiceIndicators)
858{
859 std::unique_ptr<DataInterfaceBase> dataIface =
860 std::make_unique<MockDataInterface>();
861
862 MockDataInterface* mockIface =
863 reinterpret_cast<MockDataInterface*>(dataIface.get());
864
865 openpower::pels::Manager manager{
866 logManager, std::move(dataIface),
867 std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1,
868 std::placeholders::_2, std::placeholders::_3)};
869
870 // Add a PEL with a callout as if hostboot added it
871 {
872 EXPECT_CALL(*mockIface, getInventoryFromLocCode("U42", 0, true))
873 .WillOnce(Return("/system/chassis/processor"));
874
Matt Spinler993168d2021-04-07 16:05:03 -0500875 EXPECT_CALL(*mockIface,
876 setFunctional("/system/chassis/processor", false))
Matt Spinler3dd17e92020-08-05 15:04:27 -0500877 .Times(1);
878
879 // This hostboot PEL has a single hardware callout in it.
880 auto data = pelFactory(1, 'B', 0x20, 0xA400, 500);
881
882 fs::path pelFilename = makeTempDir() / "rawpel";
883 std::ofstream pelFile{pelFilename};
884 pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
885 pelFile.close();
886
887 std::string adItem = "RAWPEL=" + pelFilename.string();
888 std::vector<std::string> additionalData{adItem};
889 std::vector<std::string> associations;
890
891 manager.create("error message", 42, 0,
892 phosphor::logging::Entry::Level::Error, additionalData,
893 associations);
894
895 fs::remove_all(pelFilename.parent_path());
896 }
897
898 // Add a BMC PEL with a callout that uses the message registry
899 {
900 std::vector<std::string> names{"systemA"};
901 EXPECT_CALL(*mockIface, getSystemNames)
902 .Times(1)
Matt Spinler1ab66962020-10-29 13:21:44 -0500903 .WillOnce(Return(names));
Matt Spinler3dd17e92020-08-05 15:04:27 -0500904
905 EXPECT_CALL(*mockIface, expandLocationCode("P42-C23", 0))
906 .WillOnce(Return("U42-P42-C23"));
907
908 // First call to this is when building the Callout section
909 EXPECT_CALL(*mockIface, getInventoryFromLocCode("P42-C23", 0, false))
910 .WillOnce(Return("/system/chassis/processor"));
911
912 // Second call to this is finding the associated LED group
913 EXPECT_CALL(*mockIface, getInventoryFromLocCode("U42-P42-C23", 0, true))
914 .WillOnce(Return("/system/chassis/processor"));
915
Matt Spinler993168d2021-04-07 16:05:03 -0500916 EXPECT_CALL(*mockIface,
917 setFunctional("/system/chassis/processor", false))
Matt Spinler3dd17e92020-08-05 15:04:27 -0500918 .Times(1);
919
920 const auto registry = R"(
921 {
922 "PELs":
923 [
924 {
925 "Name": "xyz.openbmc_project.Error.Test",
926 "Subsystem": "power_supply",
927 "ActionFlags": ["service_action", "report"],
928 "SRC":
929 {
930 "ReasonCode": "0x2030"
931 },
932 "Callouts": [
933 {
934 "CalloutList": [
935 {"Priority": "high", "LocCode": "P42-C23"}
936 ]
937 }
938 ],
939 "Documentation":
940 {
941 "Description": "Test Error",
942 "Message": "Test Error"
943 }
944 }
945 ]
946 })";
947
948 auto path = getPELReadOnlyDataPath();
949 fs::create_directories(path);
950 path /= "message_registry.json";
951
952 std::ofstream registryFile{path};
953 registryFile << registry;
954 registryFile.close();
955
956 std::vector<std::string> additionalData;
957 std::vector<std::string> associations;
958
959 manager.create("xyz.openbmc_project.Error.Test", 42, 0,
960 phosphor::logging::Entry::Level::Error, additionalData,
961 associations);
962 }
963}