summaryrefslogtreecommitdiffstats
path: root/tests/Network
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network')
-rw-r--r--tests/Network/CMakeLists.txt26
-rw-r--r--tests/Network/EchoServer.cpp2
-rw-r--r--tests/Network/EnumInterfaces.cpp39
-rw-r--r--tests/Network/Google.cpp3
-rw-r--r--tests/Network/NameLookup.cpp5
5 files changed, 74 insertions, 1 deletions
diff --git a/tests/Network/CMakeLists.txt b/tests/Network/CMakeLists.txt
index f93ccad8e..2e0915cca 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,28 @@ 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/Network
+)
+set_target_properties(
+ Network
+ PROPERTIES FOLDER Lib
+)
+
+
+
+
diff --git a/tests/Network/EchoServer.cpp b/tests/Network/EchoServer.cpp
index 2a420fbac..fb5b06110 100644
--- a/tests/Network/EchoServer.cpp
+++ b/tests/Network/EchoServer.cpp
@@ -75,7 +75,7 @@ class cEchoLinkCallbacks:
class cEchoServerCallbacks:
public cNetwork::cListenCallbacks
{
- virtual cTCPLink::cCallbacksPtr OnIncomingConnection(const AString & a_RemoteIPAddress, UInt16 a_RemotePort)
+ virtual cTCPLink::cCallbacksPtr OnIncomingConnection(const AString & a_RemoteIPAddress, UInt16 a_RemotePort) override
{
LOGD("New incoming connection(%s:%d).", a_RemoteIPAddress.c_str(), a_RemotePort);
return std::make_shared<cEchoLinkCallbacks>();
diff --git a/tests/Network/EnumInterfaces.cpp b/tests/Network/EnumInterfaces.cpp
new file mode 100644
index 000000000..0b716acff
--- /dev/null
+++ b/tests/Network/EnumInterfaces.cpp
@@ -0,0 +1,39 @@
+
+// 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:
+ LOGD("Initializing cNetwork...");
+ cNetworkSingleton::Get().Initialise();
+
+ // Enumerate all the addresses:
+ printf("Enumerating all IP addresses...\n");
+ auto IPs = cNetwork::EnumLocalIPAddresses();
+ for (auto & ip: IPs)
+ {
+ LOGD(" %s", ip.c_str());
+ }
+ LOGD("All addresses enumerated.");
+
+ // Terminate the cNetwork subsystem:
+ cNetworkSingleton::Get().Terminate();
+
+ LOGD("Test finished.");
+ return 0;
+}
+
+
+
+
diff --git a/tests/Network/Google.cpp b/tests/Network/Google.cpp
index 23017d23b..4332828d6 100644
--- a/tests/Network/Google.cpp
+++ b/tests/Network/Google.cpp
@@ -118,7 +118,10 @@ static void DoTest(void)
int main()
{
+ LOGD("Initializing cNetwork...\n");
cNetworkSingleton::Get().Initialise();
+
+ LOGD("Testing...");
DoTest();
cNetworkSingleton::Get().Terminate();
diff --git a/tests/Network/NameLookup.cpp b/tests/Network/NameLookup.cpp
index 4781a59ec..2904a0199 100644
--- a/tests/Network/NameLookup.cpp
+++ b/tests/Network/NameLookup.cpp
@@ -79,7 +79,12 @@ static void DoTest(void)
int main()
{
+ LOGD("Initializing cNetwork...");
+ cNetworkSingleton::Get().Initialise();
+
+ LOGD("Running test...");
DoTest();
+
cNetworkSingleton::Get().Terminate();
LOGD("Network test finished");
return 0;