From 3184433756c6014e5192bdb92df9a233c62b55e7 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 13 Mar 2016 18:12:33 +0100 Subject: Moved NetworkInterfaceEnum test to a separate test project. --- tests/Network/CMakeLists.txt | 22 ++++++++++++++++++++++ tests/Network/EnumInterfaces.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/Network/EnumInterfaces.cpp (limited to 'tests/Network') 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; +} + + + + -- cgit v1.2.3 From 3d164a77cb1057e982f3217a505cb21eadf46535 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 13 Mar 2016 18:22:35 +0100 Subject: SelfTests: Organized into solution folders. --- tests/Network/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/Network') diff --git a/tests/Network/CMakeLists.txt b/tests/Network/CMakeLists.txt index e47b01e11..2e0915cca 100644 --- a/tests/Network/CMakeLists.txt +++ b/tests/Network/CMakeLists.txt @@ -78,7 +78,11 @@ set_target_properties( Google-exe NameLookup EnumInterfaces-exe - PROPERTIES FOLDER Tests + PROPERTIES FOLDER Tests/Network +) +set_target_properties( + Network + PROPERTIES FOLDER Lib ) -- cgit v1.2.3 From 82e81c01a279547fc97d63fb69ba7018f2eb632d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 13 Mar 2016 19:39:51 +0100 Subject: SelfTests: Fixed missing override keyword in EchoServer. --- tests/Network/EchoServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/Network') 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(); -- cgit v1.2.3 From ea47247dc72a7ee44f97628e45c5b6867f46bedf Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 16 Jun 2016 17:34:17 +0200 Subject: SelfTests: Print a quick message on test start. --- tests/Network/EnumInterfaces.cpp | 1 + tests/Network/Google.cpp | 3 +++ tests/Network/NameLookup.cpp | 5 +++++ 3 files changed, 9 insertions(+) (limited to 'tests/Network') diff --git a/tests/Network/EnumInterfaces.cpp b/tests/Network/EnumInterfaces.cpp index a24158c62..e4c6be219 100644 --- a/tests/Network/EnumInterfaces.cpp +++ b/tests/Network/EnumInterfaces.cpp @@ -15,6 +15,7 @@ int main(int argc, char * argv[]) { // Initialize the cNetwork subsystem: + LOGD("Initializing cNetwork..."); cNetworkSingleton::Get().Initialise(); // Enumerate all the addresses: 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; -- cgit v1.2.3 From 4d9769a4840791659e1588b3afa2ef396c181b37 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 17 Jun 2016 13:44:16 +0200 Subject: SelfTests: More logging for EnumInterfaces. --- tests/Network/EnumInterfaces.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/Network') diff --git a/tests/Network/EnumInterfaces.cpp b/tests/Network/EnumInterfaces.cpp index e4c6be219..0b716acff 100644 --- a/tests/Network/EnumInterfaces.cpp +++ b/tests/Network/EnumInterfaces.cpp @@ -23,13 +23,14 @@ int main(int argc, char * argv[]) auto IPs = cNetwork::EnumLocalIPAddresses(); for (auto & ip: IPs) { - printf(" %s\n", ip.c_str()); + LOGD(" %s", ip.c_str()); } - printf("Done.\n"); + LOGD("All addresses enumerated."); // Terminate the cNetwork subsystem: cNetworkSingleton::Get().Terminate(); + LOGD("Test finished."); return 0; } -- cgit v1.2.3