1 #include "config.h"
2 
3 #include "phosphor-rsyslog-config/server-conf.hpp"
4 
5 #include <sdbusplus/bus.hpp>
6 
7 #include <filesystem>
8 
9 #include "gmock/gmock.h"
10 #include <gtest/gtest.h>
11 
12 namespace phosphor
13 {
14 namespace logging
15 {
16 namespace test
17 {
18 
19 namespace fs = std::filesystem;
20 
21 char tmplt[] = "/tmp/logging_test.XXXXXX";
22 auto bus = sdbusplus::bus::new_default();
23 fs::path dir(fs::path(mkdtemp(tmplt)));
24 
25 class MockServer : public phosphor::rsyslog_config::Server
26 {
27   public:
28     MockServer(sdbusplus::bus_t& bus, const std::string& path,
29                const char* filePath) :
30         phosphor::rsyslog_config::Server(bus, path, filePath)
31     {}
32 
33     MOCK_METHOD0(restart, void());
34 };
35 
36 class TestRemoteLogging : public testing::Test
37 {
38   public:
39     TestRemoteLogging()
40     {
41         configFilePath = std::string(dir.c_str()) + "/server.conf";
42         config = new MockServer(bus, BUSPATH_REMOTE_LOGGING_CONFIG,
43                                 configFilePath.c_str());
44     }
45 
46     ~TestRemoteLogging()
47     {
48         delete config;
49     }
50 
51     static void TearDownTestCase()
52     {
53         fs::remove_all(dir);
54     }
55 
56     MockServer* config;
57     std::string configFilePath;
58 };
59 
60 } // namespace test
61 } // namespace logging
62 } // namespace phosphor
63