From f682b40dcde8badb7029a063e299e1bdf1501444 Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Wed, 18 Dec 2019 13:48:08 -0600 Subject: PEL: Add ability to create event logs There are cases where the PEL code wants to be able to create OpenBMC event logs (and thus PELs) for problems it encounters when trying to create or import other PELs. For example, if the host were to send down a malformed PEL, this code would like to create a new event log and capture part of that bad PEL in the new PEL for debug purposes, as the malformed PEL cannot be reported anywhere since it is malformed. To handle this, create the EventLogger class that provides a log() function that allows the PEL extension code to create OpenBMC event logs (and thus PELs) from within. The underlying function to do the event log creating is passed in via the constructor so that it can be changed for testing. The sd_event_add_defer function (wrapped by sdeventplus) is used to dispatch the creation of a single event, so that the entry point is from the event loop. If there are still events left on the queue after that, then they will be also be scheduled with sd_event_add_defer so that the events are always created from event loop calls. EventLogger does not allow events to be added to the queue if it is being done from within the creation function so that the code can't get stuck in a loop of creating a new event every time an event is created. Signed-off-by: Matt Spinler Change-Id: I6a9062074dc62cfb6043139ff0a9f3dfcd06c708 --- test/openpower-pels/Makefile.include | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/openpower-pels/Makefile.include') diff --git a/test/openpower-pels/Makefile.include b/test/openpower-pels/Makefile.include index a700a50..09eb36b 100644 --- a/test/openpower-pels/Makefile.include +++ b/test/openpower-pels/Makefile.include @@ -4,6 +4,7 @@ check_PROGRAMS += \ additional_data_test \ ascii_string_test \ bcd_time_test \ + event_logger_test \ extended_user_header_test \ failing_mtms_test \ fru_identity_test \ @@ -353,3 +354,11 @@ json_utils_test_LDADD = \ $(test_ldadd) \ $(top_builddir)/extensions/openpower-pels/json_utils.o json_utils_test_LDFLAGS = $(test_ldflags) + +event_logger_test_SOURCES = \ + %reldir%/event_logger_test.cpp +event_logger_test_CPPFLAGS = $(test_cppflags) +event_logger_test_CXXFLAGS = $(test_cxxflags) $(SDEVENTPLUS_CFLAGS) +event_logger_test_LDADD = \ + $(test_ldadd) +event_logger_test_LDFLAGS = $(test_ldflags) $(SDEVENTPLUS_LIBS) -- cgit v1.2.1