From 99c2b4059e708a7cba6740a0e832ef5f480a9f12 Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Thu, 23 May 2019 14:29:16 -0500 Subject: OpenPower PEL Extension support framework The goal of extensions is to extend phosphor-logging's `xyz.openbmc_project.Logging.Entry` log support to allow other log formats to be created without incurring extra D-Bus call overhead. The README.md change in this commit provides additional documentation on how extensions work. The summary is that they allow code that resides in this repository to provide functions that can be called at certain points (startup, log creation/deletion) such that the code can then create their own logs based on the contents of an OpenBMC log. A specific extension's code is compiled in using a --enable configure option, so platforms that did not use those log formats would incur no performance/size penalties. This commit provides the support for extensions, plus a basic OpenPower PEL (Platform Event Log) extension as the first extension. PELs are event logs used only on some OpenPower systems. Signed-off-by: Matt Spinler Change-Id: Ifbb31325261c157678c29bbebc7f6d32d282582f --- test/extensions_test.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 test/extensions_test.cpp (limited to 'test/extensions_test.cpp') diff --git a/test/extensions_test.cpp b/test/extensions_test.cpp new file mode 100644 index 0000000..17c3395 --- /dev/null +++ b/test/extensions_test.cpp @@ -0,0 +1,98 @@ +#include "elog_entry.hpp" +#include "extensions.hpp" + +#include + +using namespace phosphor::logging; + +// gtest doesn't like this happening in another file, so do it here. +StartupFunctions Extensions::startupFunctions{}; +CreateFunctions Extensions::createFunctions{}; +DeleteFunctions Extensions::deleteFunctions{}; +DeleteProhibitedFunctions Extensions::deleteProhibitedFunctions{}; +Extensions::DefaultErrorCaps Extensions::defaultErrorCaps = + Extensions::DefaultErrorCaps::enable; + +void startup1(internal::Manager& manager) +{ +} + +void startup2(internal::Manager& manager) +{ +} + +void create1(const std::string& message, uint32_t id, uint64_t timestamp, + Entry::Level severity, const AdditionalDataArg& additionalData, + const AssociationEndpointsArg& assocs) +{ +} + +void create2(const std::string& message, uint32_t id, uint64_t timestamp, + Entry::Level severity, const AdditionalDataArg& additionalData, + const AssociationEndpointsArg& assocs) +{ +} + +void deleteLog1(uint32_t id) +{ +} + +void deleteLog2(uint32_t id) +{ +} + +void deleteProhibited1(uint32_t id, bool& prohibited) +{ + prohibited = true; +} + +void deleteProhibited2(uint32_t id, bool& prohibited) +{ + prohibited = true; +} + +DISABLE_LOG_ENTRY_CAPS(); +REGISTER_EXTENSION_FUNCTION(startup1); +REGISTER_EXTENSION_FUNCTION(startup2); +REGISTER_EXTENSION_FUNCTION(create1); +REGISTER_EXTENSION_FUNCTION(create2); +REGISTER_EXTENSION_FUNCTION(deleteProhibited1); +REGISTER_EXTENSION_FUNCTION(deleteProhibited2); +REGISTER_EXTENSION_FUNCTION(deleteLog1); +REGISTER_EXTENSION_FUNCTION(deleteLog2); + +TEST(ExtensionsTest, FunctionCallTest) +{ + auto bus = sdbusplus::bus::new_default(); + internal::Manager manager(bus, "testpath"); + + EXPECT_EQ(Extensions::getStartupFunctions().size(), 2); + for (auto& s : Extensions::getStartupFunctions()) + { + s(manager); + } + + AdditionalDataArg ad; + AssociationEndpointsArg assocs; + EXPECT_EQ(Extensions::getCreateFunctions().size(), 2); + for (auto& c : Extensions::getCreateFunctions()) + { + c("test", 5, 6, Entry::Level::Informational, ad, assocs); + } + + EXPECT_EQ(Extensions::getDeleteFunctions().size(), 2); + for (auto& d : Extensions::getDeleteFunctions()) + { + d(5); + } + + EXPECT_EQ(Extensions::getDeleteProhibitedFunctions().size(), 2); + for (auto& p : Extensions::getDeleteProhibitedFunctions()) + { + bool prohibited = false; + p(5, prohibited); + EXPECT_TRUE(prohibited); + } + + EXPECT_TRUE(Extensions::disableDefaultLogCaps()); +} -- cgit v1.2.1