blob: e9b64b3ab39a16e5776a969a3504889a8afad509 [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 <sdbusplus/bus.hpp>
Patrick Venturef18bf832018-10-26 18:14:00 -07006
Patrick Williams2544b412022-10-04 08:41:06 -05007#include <filesystem>
8
Deepak Kodihalli834dcf12018-08-30 05:05:46 -05009#include "gmock/gmock.h"
Patrick Venturef18bf832018-10-26 18:14:00 -070010#include <gtest/gtest.h>
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050011
12namespace phosphor
13{
14namespace logging
15{
16namespace test
17{
18
Patrick Williams331c4852021-04-16 15:38:59 -050019namespace fs = std::filesystem;
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050020
21char tmplt[] = "/tmp/logging_test.XXXXXX";
22auto bus = sdbusplus::bus::new_default();
23fs::path dir(fs::path(mkdtemp(tmplt)));
24
25class MockServer : public phosphor::rsyslog_config::Server
26{
Patrick Venturef18bf832018-10-26 18:14:00 -070027 public:
Patrick Williams45e83522022-07-22 19:26:52 -050028 MockServer(sdbusplus::bus_t& bus, const std::string& path,
Deepak Kodihalli834dcf12018-08-30 05:05:46 -050029 const char* filePath) :
Patrick Venturef18bf832018-10-26 18:14:00 -070030 phosphor::rsyslog_config::Server(bus, path, filePath)
Patrick Williams2544b412022-10-04 08:41:06 -050031 {}
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