blob: 936e3bb3c330846d9f94de125cc1efe9ee8ebd86 [file] [log] [blame]
Patrick Venturef18bf832018-10-26 18:14:00 -07001#include "config.h"
2
3#include "phosphor-rsyslog-config/server-conf.hpp"
4
Deepak Kodihalli834dcf12018-08-30 05:05:46 -05005#include <experimental/filesystem>
6#include <sdbusplus/bus.hpp>
Patrick Venturef18bf832018-10-26 18:14:00 -07007
Deepak Kodihalli834dcf12018-08-30 05:05:46 -05008#include "gmock/gmock.h"
Patrick Venturef18bf832018-10-26 18:14:00 -07009#include <gtest/gtest.h>
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050010
11namespace phosphor
12{
13namespace logging
14{
15namespace test
16{
17
18namespace fs = std::experimental::filesystem;
19
20char tmplt[] = "/tmp/logging_test.XXXXXX";
21auto bus = sdbusplus::bus::new_default();
22fs::path dir(fs::path(mkdtemp(tmplt)));
23
24class MockServer : public phosphor::rsyslog_config::Server
25{
Patrick Venturef18bf832018-10-26 18:14:00 -070026 public:
27 MockServer(sdbusplus::bus::bus& bus, const std::string& path,
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050028 const char* filePath) :
Patrick Venturef18bf832018-10-26 18:14:00 -070029 phosphor::rsyslog_config::Server(bus, path, filePath)
30 {
31 }
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050032
Patrick Venturef18bf832018-10-26 18:14:00 -070033 MOCK_METHOD0(restart, void());
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050034};
35
36class TestRemoteLogging : public testing::Test
37{
Patrick Venturef18bf832018-10-26 18:14:00 -070038 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 }
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050045
Patrick Venturef18bf832018-10-26 18:14:00 -070046 ~TestRemoteLogging()
47 {
48 delete config;
49 }
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050050
Patrick Venturef18bf832018-10-26 18:14:00 -070051 static void TearDownTestCase()
52 {
53 fs::remove_all(dir);
54 }
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050055
Patrick Venturef18bf832018-10-26 18:14:00 -070056 MockServer* config;
57 std::string configFilePath;
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050058};
59
60} // namespace test
61} // namespace logging
62} // namespace phosphor