blob: 0d818530759c82ba28897eb53657b39406a5cf64 [file] [log] [blame]
Lei YUebd3d092020-09-27 18:11:48 +08001#include "sdbus_wrapper.hpp"
2
3#include <sdbusplus/test/sdbus_mock.hpp>
4
5#include <memory>
6
7// To support ipmid_get_sd_bus_connection, we have to make the sdbusMock global
8static std::unique_ptr<sdbusplus::SdBusMock> sdbusMock;
9static std::unique_ptr<sdbusplus::bus::bus> mockedBus;
10
11sdbusplus::bus::bus& getBus()
12{
13 if (!sdbusMock)
14 {
15 sdbusMock = std::make_unique<sdbusplus::SdBusMock>();
16 }
17 mockedBus = std::make_unique<sdbusplus::bus::bus>(
18 sdbusplus::get_mocked_new(sdbusMock.get()));
19 return *mockedBus.get();
20}
21
22void clearMockedBus()
23{
24 sdbusMock.reset();
25 mockedBus.reset();
26}