test: Mock out MAC address access
This makes it possible for our ethernet interfaces to have MAC Addresses
detected and configured for testing without the system providing a real
NIC.
Change-Id: Ie985efec0a5e393b0b76f3d02bd3015fef6349e4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp
index a075423..c25bba9 100644
--- a/test/test_ethernet_interface.cpp
+++ b/test/test_ethernet_interface.cpp
@@ -2,6 +2,7 @@
#include "ipaddress.hpp"
#include "mock_network_manager.hpp"
#include "mock_syscall.hpp"
+#include "util.hpp"
#include <arpa/inet.h>
#include <net/if.h>
@@ -50,10 +51,12 @@
}
}
+ static constexpr ether_addr mac{0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
+
static EthernetInterface makeInterface(sdbusplus::bus::bus& bus,
MockManager& manager)
{
- mock_addIF("test0", 1);
+ mock_addIF("test0", 1, mac);
return {bus, "/xyz/openbmc_test/network/test0", false, manager};
}
@@ -125,6 +128,7 @@
TEST_F(TestEthernetInterface, NoIPaddress)
{
EXPECT_EQ(countIPObjects(), 0);
+ EXPECT_EQ(mac_address::toString(mac), interface.mACAddress());
}
TEST_F(TestEthernetInterface, AddIPAddress)