blob: 59feedd5bb84cc9ca13370bf5f83c3d4492a51d4 [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>
4
5namespace phosphor
6{
7namespace logging
8{
9namespace test
10{
11
12std::string getConfig(const char* filePath)
13{
14 std::fstream stream(filePath, std::fstream::in);
15 std::string line;
16 getline(stream, line);
17 return line;
18}
19
20TEST_F(TestRemoteLogging, testOnlyAddress)
21{
22 config->address("1.1.1.1");
23 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
24}
25
26TEST_F(TestRemoteLogging, testOnlyPort)
27{
28 config->port(100);
29 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
30}
31
32TEST_F(TestRemoteLogging, testGoodConfig)
33{
34 config->address("1.1.1.1");
35 config->port(100);
36 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
37}
38
39TEST_F(TestRemoteLogging, testClearAddress)
40{
41 config->address("1.1.1.1");
42 config->port(100);
43 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
44 config->address("");
45 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
46}
47
48TEST_F(TestRemoteLogging, testClearPort)
49{
50 config->address("1.1.1.1");
51 config->port(100);
52 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
53 config->port(0);
54 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
55}
56
Patrick Venturef18bf832018-10-26 18:14:00 -070057} // namespace test
58} // namespace logging
59} // namespace phosphor