blob: 65914ac2e3b487aba60593c051b8c56df627fe81 [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:
Patrick Williamsc38b0712022-07-22 19:26:54 -050018 sdbusplus::bus_t bus;
Asmitha Karunanithia6c07572022-05-05 03:19:45 -050019 HypNetworkMgr manager;
Asmitha Karunanithia6c07572022-05-05 03:19:45 -050020 TestHypNetworkManager() :
21 bus(sdbusplus::bus::new_default()),
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -080022 manager(bus, "/xyz/openbmc_test/network/hypervisor")
Asmitha Karunanithia6c07572022-05-05 03:19:45 -050023 {
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
36TEST_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
47TEST_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