From eca240eec7e03bd7b3492204ece0a2756b5d6b70 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 11 Jul 2012 12:07:13 +0000 Subject: [PATCH] changed integ tests to use another port for ipc. --- src/lib/ipc/CIpcClient.cpp | 13 +++++++++++++ src/lib/ipc/CIpcClient.h | 2 ++ src/lib/ipc/CIpcServer.cpp | 12 ++++++++++++ src/lib/ipc/CIpcServer.h | 2 ++ src/test/integtests/CIpcTests.cpp | 18 ++++++++++-------- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/lib/ipc/CIpcClient.cpp b/src/lib/ipc/CIpcClient.cpp index faf2d3e0..d731a0a0 100644 --- a/src/lib/ipc/CIpcClient.cpp +++ b/src/lib/ipc/CIpcClient.cpp @@ -27,6 +27,19 @@ CEvent::Type CIpcClient::s_messageReceivedEvent = CEvent::kUnknown; CIpcClient::CIpcClient() : m_serverAddress(CNetworkAddress(IPC_HOST, IPC_PORT)), m_server(nullptr) +{ + init(); +} + +CIpcClient::CIpcClient(int port) : +m_serverAddress(CNetworkAddress(IPC_HOST, port)), +m_server(nullptr) +{ + init(); +} + +void +CIpcClient::init() { m_serverAddress.resolve(); } diff --git a/src/lib/ipc/CIpcClient.h b/src/lib/ipc/CIpcClient.h index ae7d8c27..73ae6ac1 100644 --- a/src/lib/ipc/CIpcClient.h +++ b/src/lib/ipc/CIpcClient.h @@ -30,6 +30,7 @@ class CIpcMessage; class CIpcClient { public: CIpcClient(); + CIpcClient(int port); virtual ~CIpcClient(); //! @name manipulators @@ -55,6 +56,7 @@ public: //@} private: + void init(); void handleConnected(const CEvent&, void*); void handleMessageReceived(const CEvent&, void*); diff --git a/src/lib/ipc/CIpcServer.cpp b/src/lib/ipc/CIpcServer.cpp index a4bf805b..77bca4a3 100644 --- a/src/lib/ipc/CIpcServer.cpp +++ b/src/lib/ipc/CIpcServer.cpp @@ -31,6 +31,18 @@ CEvent::Type CIpcServer::s_messageReceivedEvent = CEvent::kUnknown; CIpcServer::CIpcServer() : m_address(CNetworkAddress(IPC_HOST, IPC_PORT)) +{ + init(); +} + +CIpcServer::CIpcServer(int port) : +m_address(CNetworkAddress(IPC_HOST, port)) +{ + init(); +} + +void +CIpcServer::init() { m_clientsMutex = ARCH->newMutex(); m_address.resolve(); diff --git a/src/lib/ipc/CIpcServer.h b/src/lib/ipc/CIpcServer.h index 39a7e314..925ae8d0 100644 --- a/src/lib/ipc/CIpcServer.h +++ b/src/lib/ipc/CIpcServer.h @@ -37,6 +37,7 @@ and allows the daemon and client/server to send log data to the GUI. class CIpcServer { public: CIpcServer(); + CIpcServer(int port); virtual ~CIpcServer(); //! @name manipulators @@ -64,6 +65,7 @@ public: //@} private: + void init(); void handleClientConnecting(const CEvent&, void*); void handleClientDisconnected(const CEvent&, void*); void handleMessageReceived(const CEvent&, void*); diff --git a/src/test/integtests/CIpcTests.cpp b/src/test/integtests/CIpcTests.cpp index ec0437df..e634283b 100644 --- a/src/test/integtests/CIpcTests.cpp +++ b/src/test/integtests/CIpcTests.cpp @@ -36,6 +36,8 @@ #include "CIpcMessage.h" #include "CSimpleEventQueueBuffer.h" +#define TEST_IPC_PORT 24802 + class CIpcTests : public ::testing::Test { public: @@ -71,7 +73,7 @@ public: TEST_F(CIpcTests, connectToServer) { - CIpcServer server; + CIpcServer server(TEST_IPC_PORT); server.listen(); m_connectToServer_server = &server; @@ -79,8 +81,8 @@ TEST_F(CIpcTests, connectToServer) CIpcServer::getMessageReceivedEvent(), &server, new TMethodEventJob( this, &CIpcTests::connectToServer_handleMessageReceived)); - - CIpcClient client; + + CIpcClient client(TEST_IPC_PORT); client.connect(); initQuitTimeout(2); @@ -94,7 +96,7 @@ TEST_F(CIpcTests, connectToServer) TEST_F(CIpcTests, sendMessageToServer) { - CIpcServer server; + CIpcServer server(TEST_IPC_PORT); server.listen(); // event handler sends "test" command to server. @@ -107,8 +109,8 @@ TEST_F(CIpcTests, sendMessageToServer) CIpcServer::getMessageReceivedEvent(), &server, new TMethodEventJob( this, &CIpcTests::sendMessageToServer_handleMessageReceived)); - - CIpcClient client; + + CIpcClient client(TEST_IPC_PORT); client.connect(); m_sendMessageToServer_client = &client; @@ -123,7 +125,7 @@ TEST_F(CIpcTests, sendMessageToServer) TEST_F(CIpcTests, sendMessageToClient) { - CIpcServer server; + CIpcServer server(TEST_IPC_PORT); server.listen(); m_sendMessageToClient_server = &server; @@ -133,7 +135,7 @@ TEST_F(CIpcTests, sendMessageToClient) new TMethodEventJob( this, &CIpcTests::sendMessageToClient_handleClientConnected)); - CIpcClient client; + CIpcClient client(TEST_IPC_PORT); client.connect(); m_events.adoptHandler(