1 #include "remote_logging_tests.hpp" 2 3 #include <fstream> 4 #include <string> 5 6 namespace phosphor 7 { 8 namespace logging 9 { 10 namespace test 11 { 12 13 std::string getConfig(const char* filePath) 14 { 15 std::fstream stream(filePath, std::fstream::in); 16 std::string line; 17 std::getline(stream, line); 18 return line; 19 } 20 21 TEST_F(TestRemoteLogging, testOnlyAddress) 22 { 23 config->address("1.1.1.1"); 24 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); 25 } 26 27 TEST_F(TestRemoteLogging, testOnlyPort) 28 { 29 config->port(100); 30 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); 31 } 32 33 TEST_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 40 TEST_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(""); 46 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); 47 } 48 49 TEST_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); 55 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); 56 } 57 58 } // namespace test 59 } // namespace logging 60 } // namespace phosphor 61