face: Prevent infinite loop in TcpFactory and UdpFactory
Change-Id: Idd694bc08033c524f3c0e569ed74341aa33fce31
Refs: #2292
diff --git a/core/network-interface.cpp b/core/network-interface.cpp
index d7eebbd..1aad63e 100644
--- a/core/network-interface.cpp
+++ b/core/network-interface.cpp
@@ -54,9 +54,25 @@
"NetworkInterfaceInfo must provide a default constructor");
#endif
+#ifdef WITH_TESTS
+static shared_ptr<std::vector<NetworkInterfaceInfo>> s_debugNetworkInterfaces = nullptr;
+
+void
+setDebugNetworkInterfaces(shared_ptr<std::vector<NetworkInterfaceInfo>> interfaces)
+{
+ s_debugNetworkInterfaces = interfaces;
+}
+#endif
+
std::vector<NetworkInterfaceInfo>
listNetworkInterfaces()
{
+#ifdef WITH_TESTS
+ if (s_debugNetworkInterfaces != nullptr) {
+ return *s_debugNetworkInterfaces;
+ }
+#endif
+
using namespace boost::asio::ip;
using std::strerror;