1 #include "hyp_network_manager.hpp" 2 3 #include <net/if.h> 4 5 #include <sdbusplus/bus.hpp> 6 #include <xyz/openbmc_project/Common/error.hpp> 7 8 #include <gtest/gtest.h> 9 10 namespace phosphor 11 { 12 namespace network 13 { 14 15 class TestHypNetworkManager : public testing::Test 16 { 17 public: 18 sdbusplus::bus_t bus; 19 HypNetworkMgr manager; 20 TestHypNetworkManager() : 21 bus(sdbusplus::bus::new_default()), 22 manager(bus, "/xyz/openbmc_test/network/hypervisor") 23 { 24 // TODO: Once the support for ipv6 has been added, the below 25 // method call to set default values in the local copy 26 // of the bios attributes should be called for ipv6 as well 27 28 manager.setDefaultBIOSTableAttrsOnIntf("if0"); 29 manager.setDefaultBIOSTableAttrsOnIntf("if1"); 30 manager.setDefaultHostnameInBIOSTableAttrs(); 31 } 32 33 ~TestHypNetworkManager() = default; 34 }; 35 36 TEST_F(TestHypNetworkManager, getDefaultBiosTableAttr) 37 { 38 biosTableType biosAttrs = manager.getBIOSTableAttrs(); 39 auto itr = biosAttrs.find("vmi_if0_ipv4_method"); 40 if (itr != biosAttrs.end()) 41 { 42 std::string biosAttrValue = std::get<std::string>(itr->second); 43 EXPECT_EQ(biosAttrValue, "IPv4Static"); 44 } 45 } 46 47 TEST_F(TestHypNetworkManager, setHostnameInBiosTableAndGet) 48 { 49 std::string attribute = "vmi_hostname"; 50 std::string value = "testHostname"; 51 manager.setBIOSTableAttr(attribute, value, "String"); 52 biosTableType biosAttrs = manager.getBIOSTableAttrs(); 53 auto itr = biosAttrs.find("vmi_hostname"); 54 if (itr != biosAttrs.end()) 55 { 56 std::string biosAttrValue = std::get<std::string>(itr->second); 57 EXPECT_EQ(biosAttrValue, value); 58 } 59 } 60 61 } // namespace network 62 } // namespace phosphor 63