1*90f8d9b4SHannu Lounento #include <sdbusplus/bus.hpp> 2*90f8d9b4SHannu Lounento #include <sdbusplus/test/sdbus_mock.hpp> 3*90f8d9b4SHannu Lounento 4*90f8d9b4SHannu Lounento #include <exception> 5*90f8d9b4SHannu Lounento 6*90f8d9b4SHannu Lounento #include <gtest/gtest.h> 7*90f8d9b4SHannu Lounento 8*90f8d9b4SHannu Lounento class Exception : public ::testing::Test 9*90f8d9b4SHannu Lounento { 10*90f8d9b4SHannu Lounento protected: 11*90f8d9b4SHannu Lounento sdbusplus::SdBusMock sdbusMock; 12*90f8d9b4SHannu Lounento sdbusplus::bus_t bus = sdbusplus::get_mocked_new(&sdbusMock); 13*90f8d9b4SHannu Lounento std::exception_ptr e = 14*90f8d9b4SHannu Lounento std::make_exception_ptr(std::runtime_error{"current exception"}); 15*90f8d9b4SHannu Lounento SetUp()16*90f8d9b4SHannu Lounento void SetUp() override 17*90f8d9b4SHannu Lounento { 18*90f8d9b4SHannu Lounento bus.set_current_exception(e); 19*90f8d9b4SHannu Lounento } 20*90f8d9b4SHannu Lounento }; 21*90f8d9b4SHannu Lounento TEST_F(Exception,BusProcessRethrowsTheCurrentException)22*90f8d9b4SHannu LounentoTEST_F(Exception, BusProcessRethrowsTheCurrentException) 23*90f8d9b4SHannu Lounento { 24*90f8d9b4SHannu Lounento EXPECT_THROW(bus.process(), std::runtime_error); 25*90f8d9b4SHannu Lounento } 26*90f8d9b4SHannu Lounento TEST_F(Exception,BusProcessDiscardRethrowsTheCurrentException)27*90f8d9b4SHannu LounentoTEST_F(Exception, BusProcessDiscardRethrowsTheCurrentException) 28*90f8d9b4SHannu Lounento { 29*90f8d9b4SHannu Lounento EXPECT_THROW(bus.process_discard(), std::runtime_error); 30*90f8d9b4SHannu Lounento } 31