From 6b1a5c83bdb6c4d0619d7c154a223f6a1d97d52d Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Tue, 7 Jan 2020 08:48:53 -0600 Subject: PEL: Close PEL FD after getPEL call To close the file descriptor returned from the getPEL D-Bus method call, use the 'Defer' sdeventplus object to schedule it to happen from the event loop. Signed-off-by: Matt Spinler Change-Id: I2b850a1c92215e7f66166cc5440d7071663065c0 --- test/openpower-pels/pel_manager_test.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'test/openpower-pels/pel_manager_test.cpp') diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp index 3036f30..8f3df22 100644 --- a/test/openpower-pels/pel_manager_test.cpp +++ b/test/openpower-pels/pel_manager_test.cpp @@ -28,6 +28,21 @@ namespace fs = std::filesystem; class ManagerTest : public CleanPELFiles { + public: + ManagerTest() : logManager(bus, "logging_path") + { + sd_event_default(&sdEvent); + bus.attach_event(sdEvent, SD_EVENT_PRIORITY_NORMAL); + } + + ~ManagerTest() + { + sd_event_unref(sdEvent); + } + + sdbusplus::bus::bus bus = sdbusplus::bus::new_default(); + phosphor::logging::internal::Manager logManager; + sd_event* sdEvent; }; fs::path makeTempDir() @@ -56,8 +71,6 @@ std::optional findAnyPELInRepo() // a PEL saved in the repository. TEST_F(ManagerTest, TestCreateWithPEL) { - auto bus = sdbusplus::bus::new_default(); - phosphor::logging::internal::Manager logManager(bus, "logging_path"); std::unique_ptr dataIface = std::make_unique(bus); @@ -170,8 +183,6 @@ TEST_F(ManagerTest, TestCreateWithMessageRegistry) TEST_F(ManagerTest, TestDBusMethods) { - auto bus = sdbusplus::bus::new_default(); - phosphor::logging::internal::Manager logManager(bus, "logging_path"); std::unique_ptr dataIface = std::make_unique(bus); -- cgit v1.2.1