summaryrefslogtreecommitdiffstats
path: root/tests/Network
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network')
-rw-r--r--tests/Network/CMakeLists.txt22
-rw-r--r--tests/Network/EnumInterfaces.cpp37
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/Network/CMakeLists.txt b/tests/Network/CMakeLists.txt
index f93ccad8e..e47b01e11 100644
--- a/tests/Network/CMakeLists.txt
+++ b/tests/Network/CMakeLists.txt
@@ -13,6 +13,7 @@ set (Network_SRCS
${CMAKE_SOURCE_DIR}/src/OSSupport/Event.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/HostnameLookup.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/IPLookup.cpp
+ ${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkInterfaceEnum.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkSingleton.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/ServerHandleImpl.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/TCPLinkImpl.cpp
@@ -62,3 +63,24 @@ target_link_libraries(EchoServer Network)
# NameLookup: Lookup hostname-to-IP and IP-to-hostname:
add_executable(NameLookup NameLookup.cpp)
target_link_libraries(NameLookup Network)
+
+# EnumInterfaces: List all network interfaces:
+add_executable(EnumInterfaces-exe EnumInterfaces.cpp)
+target_link_libraries(EnumInterfaces-exe Network)
+add_test(NAME EnumInterfaces-test COMMAND EnumInterfaces-exe)
+
+
+
+
+# Put all the tests into a solution folder (MSVC):
+set_target_properties(
+ EchoServer
+ Google-exe
+ NameLookup
+ EnumInterfaces-exe
+ PROPERTIES FOLDER Tests
+)
+
+
+
+
diff --git a/tests/Network/EnumInterfaces.cpp b/tests/Network/EnumInterfaces.cpp
new file mode 100644
index 000000000..a24158c62
--- /dev/null
+++ b/tests/Network/EnumInterfaces.cpp
@@ -0,0 +1,37 @@
+
+// EnumInterfaces.cpp
+
+// Implements the main app entrypoint for the EnumInterfaces network test
+// Lists all network interfaces to the console
+
+#include "Globals.h"
+#include "OSSupport/Network.h"
+#include "OSSupport/NetworkSingleton.h"
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ // Initialize the cNetwork subsystem:
+ cNetworkSingleton::Get().Initialise();
+
+ // Enumerate all the addresses:
+ printf("Enumerating all IP addresses...\n");
+ auto IPs = cNetwork::EnumLocalIPAddresses();
+ for (auto & ip: IPs)
+ {
+ printf(" %s\n", ip.c_str());
+ }
+ printf("Done.\n");
+
+ // Terminate the cNetwork subsystem:
+ cNetworkSingleton::Get().Terminate();
+
+ return 0;
+}
+
+
+
+