blob: d56a539425c50aefbf2da74d64f94bafd7c57ccf [file] [log] [blame]
Patrick Venturef18bf832018-10-26 18:14:00 -07001#include "config.h"
2
3#include "phosphor-rsyslog-config/server-conf.hpp"
4
Patrick Williams331c4852021-04-16 15:38:59 -05005#include <filesystem>
Deepak Kodihalli834dcf12018-08-30 05:05:46 -05006#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
Patrick Williams331c4852021-04-16 15:38:59 -050018namespace fs = std::filesystem;
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050019
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