blob: abdd14c9500c505d3c33bdb2b7b1a137a5f73953 [file] [log] [blame]
Asmitha Karunanithia6c07572022-05-05 03:19:45 -05001#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
10namespace phosphor
11{
12namespace network
13{
14
15class TestHypNetworkManager : public testing::Test
16{
17 public:
18 sdbusplus::bus::bus bus;
19 HypNetworkMgr manager;
20 sdeventplus::Event event = sdeventplus::Event::get_default();
21 TestHypNetworkManager() :
22 bus(sdbusplus::bus::new_default()),
23 manager(bus, event, "/xyz/openbmc_test/network/hypervisor")
24 {
25 // TODO: Once the support for ipv6 has been added, the below
26 // method call to set default values in the local copy
27 // of the bios attributes should be called for ipv6 as well
28
29 manager.setDefaultBIOSTableAttrsOnIntf("if0");
30 manager.setDefaultBIOSTableAttrsOnIntf("if1");
31 manager.setDefaultHostnameInBIOSTableAttrs();
32 }
33
34 ~TestHypNetworkManager() = default;
35};
36
37TEST_F(TestHypNetworkManager, getDefaultBiosTableAttr)
38{
39 biosTableType biosAttrs = manager.getBIOSTableAttrs();
40 auto itr = biosAttrs.find("vmi_if0_ipv4_method");
41 if (itr != biosAttrs.end())
42 {
43 std::string biosAttrValue = std::get<std::string>(itr->second);
44 EXPECT_EQ(biosAttrValue, "IPv4Static");
45 }
46}
47
48TEST_F(TestHypNetworkManager, setHostnameInBiosTableAndGet)
49{
50 std::string attribute = "vmi_hostname";
51 std::string value = "testHostname";
52 manager.setBIOSTableAttr(attribute, value, "String");
53 biosTableType biosAttrs = manager.getBIOSTableAttrs();
54 auto itr = biosAttrs.find("vmi_hostname");
55 if (itr != biosAttrs.end())
56 {
57 std::string biosAttrValue = std::get<std::string>(itr->second);
58 EXPECT_EQ(biosAttrValue, value);
59 }
60}
61
62} // namespace network
63} // namespace phosphor