1 #include "config.h"
2 
3 #include "phosphor-rsyslog-config/server-conf.hpp"
4 
5 #include <experimental/filesystem>
6 #include <sdbusplus/bus.hpp>
7 
8 #include "gmock/gmock.h"
9 #include <gtest/gtest.h>
10 
11 namespace phosphor
12 {
13 namespace logging
14 {
15 namespace test
16 {
17 
18 namespace fs = std::experimental::filesystem;
19 
20 char tmplt[] = "/tmp/logging_test.XXXXXX";
21 auto bus = sdbusplus::bus::new_default();
22 fs::path dir(fs::path(mkdtemp(tmplt)));
23 
24 class MockServer : public phosphor::rsyslog_config::Server
25 {
26   public:
27     MockServer(sdbusplus::bus::bus& bus, const std::string& path,
28                const char* filePath) :
29         phosphor::rsyslog_config::Server(bus, path, filePath)
30     {
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