diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2017-08-23 16:53:52 +0530 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-11-07 01:54:16 +0000 |
commit | 09f6157b38fb498c0a9bc06fef8d1d82205e0de7 (patch) | |
tree | 3b86101b9f4187daa3db8742243ca9aaa4b822ab | |
parent | 6dec390f676fb6327f5815d1db16064f898040dd (diff) | |
download | phosphor-networkd-09f6157b38fb498c0a9bc06fef8d1d82205e0de7.tar.gz phosphor-networkd-09f6157b38fb498c0a9bc06fef8d1d82205e0de7.zip |
Test: Add test cases for static DNS processing
Fixes openbmc/openbmc#2107
Change-Id: Id6810be3527e4861430077364a5af4dc00e52f3b
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r-- | test/test_ethernet_interface.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp index edc12fb..27fbb67 100644 --- a/test/test_ethernet_interface.cpp +++ b/test/test_ethernet_interface.cpp @@ -104,6 +104,27 @@ class TestEthernetInterface : public testing::Test } + // Validates if the DNS entries have been correctly processed + void validateResolvFile(ServerList values) + { + // Check whether the entries has been written to resolv.conf + fs::path resolvFile = confDir; + resolvFile /= "resolv.conf"; + + // Passed in "value" is what is read from the config file + interface.writeDNSEntries(values, resolvFile); + std::string expectedServers = "### Generated manually via dbus settings ###"; + expectedServers += + "nameserver 9.1.1.1nameserver 9.2.2.2nameserver 9.3.3.3"; + + std::string actualServers{}; + std::fstream stream(resolvFile.string().c_str(), std::fstream::in); + for (std::string line; std::getline(stream, line);) + { + actualServers += line; + } + EXPECT_EQ(expectedServers , actualServers); + } }; TEST_F(TestEthernetInterface, NoIPaddress) @@ -169,6 +190,19 @@ TEST_F(TestEthernetInterface, CheckObjectPath) gateway)); } +TEST_F(TestEthernetInterface, addNameServers) +{ + ServerList servers = {"9.1.1.1","9.2.2.2","9.3.3.3"}; + interface.nameservers(servers); + fs::path filePath = confDir; + filePath /= "00-bmc-test0.network"; + config::Parser parser(filePath.string()); + auto values = parser.getValues("Network", "DNS"); + EXPECT_EQ(servers , values); + + validateResolvFile(values); +} + TEST_F(TestEthernetInterface, addNTPServers) { ServerList servers = {"10.1.1.1","10.2.2.2","10.3.3.3"}; |