1
0

Moved NetworkInterfaceEnum test to a separate test project.

This commit is contained in:
Mattes D 2016-03-13 18:12:33 +01:00
parent ec998e821f
commit 3184433756
3 changed files with 59 additions and 28 deletions

View File

@ -22,34 +22,6 @@
#ifdef SELF_TEST
static class cEnumIPAddressTest
{
public:
cEnumIPAddressTest(void)
{
cSelfTests::Get().Register(std::function<void(void)>(&Test), "Network IP enumeration");
}
static void Test(void)
{
LOG("Enumerating all IP addresses...");
auto IPs = cNetwork::EnumLocalIPAddresses();
for (auto & ip: IPs)
{
LOG(" %s", ip.c_str());
}
LOG("Done.");
}
} g_EnumIPAddressTest;
#endif // SELF_TEST
#ifdef _WIN32
/** Converts the SOCKET_ADDRESS structure received from the OS into an IP address string. */

View File

@ -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
)

View File

@ -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;
}