blob: 3606f5aa256e2adc7469cdb4ee823fc02892d21e [file] [log] [blame]
Deepak Kodihalli834dcf12018-08-30 05:05:46 -05001#include <gtest/gtest.h>
2#include <experimental/filesystem>
3#include <sdbusplus/bus.hpp>
4#include "config.h"
5#include "phosphor-rsyslog-config/server-conf.hpp"
6#include "gmock/gmock.h"
7
8namespace phosphor
9{
10namespace logging
11{
12namespace test
13{
14
15namespace fs = std::experimental::filesystem;
16
17char tmplt[] = "/tmp/logging_test.XXXXXX";
18auto bus = sdbusplus::bus::new_default();
19fs::path dir(fs::path(mkdtemp(tmplt)));
20
21class MockServer : public phosphor::rsyslog_config::Server
22{
23 public:
24 MockServer(sdbusplus::bus::bus& bus,
25 const std::string& path,
26 const char* filePath) :
27 phosphor::rsyslog_config::Server(bus, path, filePath)
28 {
29 }
30
31 MOCK_METHOD0(restart, void());
32};
33
34class TestRemoteLogging : public testing::Test
35{
36 public:
37 TestRemoteLogging()
38 {
39 configFilePath = std::string(dir.c_str()) + "/server.conf";
40 config =
41 new MockServer(bus,
42 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
64