changed integ tests to use another port for ipc.

This commit is contained in:
Nick Bolton 2012-07-11 12:07:13 +00:00
parent 5f0402d47b
commit eca240eec7
5 changed files with 39 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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<CIpcTests>(
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<CIpcTests>(
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<CIpcTests>(
this, &CIpcTests::sendMessageToClient_handleClientConnected));
CIpcClient client;
CIpcClient client(TEST_IPC_PORT);
client.connect();
m_events.adoptHandler(