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