blob: cba54ea79cc3a139ad705cb6402bbde6d5395f7c [file] [log] [blame]
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -05001#include "remote_logging_tests.hpp"
Patrick Venturef18bf832018-10-26 18:14:00 -07002
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -05003#include <fstream>
Patrick Venture30047bf2018-11-01 18:52:15 -07004#include <string>
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -05005
6namespace phosphor
7{
8namespace logging
9{
10namespace test
11{
12
13std::string getConfig(const char* filePath)
14{
15 std::fstream stream(filePath, std::fstream::in);
16 std::string line;
Patrick Venture30047bf2018-11-01 18:52:15 -070017 std::getline(stream, line);
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -050018 return line;
19}
20
21TEST_F(TestRemoteLogging, testOnlyAddress)
22{
23 config->address("1.1.1.1");
Santosh Puranik0a0b5ea2019-05-22 05:25:30 -050024 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~");
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -050025}
26
27TEST_F(TestRemoteLogging, testOnlyPort)
28{
29 config->port(100);
Santosh Puranik0a0b5ea2019-05-22 05:25:30 -050030 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~");
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -050031}
32
33TEST_F(TestRemoteLogging, testGoodConfig)
34{
35 config->address("1.1.1.1");
36 config->port(100);
37 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
38}
39
40TEST_F(TestRemoteLogging, testClearAddress)
41{
42 config->address("1.1.1.1");
43 config->port(100);
44 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
45 config->address("");
Santosh Puranik0a0b5ea2019-05-22 05:25:30 -050046 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~");
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -050047}
48
49TEST_F(TestRemoteLogging, testClearPort)
50{
51 config->address("1.1.1.1");
52 config->port(100);
53 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
54 config->port(0);
Santosh Puranik0a0b5ea2019-05-22 05:25:30 -050055 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~");
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -050056}
57
Patrick Venturef18bf832018-10-26 18:14:00 -070058} // namespace test
59} // namespace logging
60} // namespace phosphor