X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e7ce668e1db4471bf59049571be288233b1322f3..32753ae949d861ddaf7c66f4c483bc57493c6c6c:/tests/net/ipc.cpp?ds=sidebyside diff --git a/tests/net/ipc.cpp b/tests/net/ipc.cpp index 5ca82bd3e4..9782867044 100644 --- a/tests/net/ipc.cpp +++ b/tests/net/ipc.cpp @@ -4,7 +4,7 @@ // Author: Vadim Zeitlin // RCS-ID: $Id$ // Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWidgets licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". @@ -15,16 +15,24 @@ #pragma hdrstop #endif -// for all others, include the necessary headers -#ifndef WX_PRECOMP -#endif +// FIXME: this tests currently sometimes hangs in Connect() for unknown reason +// and this prevents buildbot builds from working so disabling it, but +// the real problem needs to be fixed, of course +#if 0 // this test needs threads as it runs the test server in a secondary thread #if wxUSE_THREADS +// for all others, include the necessary headers +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif + #include "wx/ipc.h" #include "wx/thread.h" +#define wxUSE_SOCKETS_FOR_IPC (!wxUSE_DDE_FOR_IPC) + namespace { @@ -90,8 +98,10 @@ public: { m_conn = NULL; +#if wxUSE_SOCKETS_FOR_IPC // we must call this from the main thread wxSocketBase::Initialize(); +#endif // wxUSE_SOCKETS_FOR_IPC // we need event dispatching to work for IPC server to work m_thread = new EventThread; @@ -105,9 +115,12 @@ public: m_thread->Wait(); delete m_thread; - m_thread = NULL; + delete m_conn; + +#if wxUSE_SOCKETS_FOR_IPC wxSocketBase::Shutdown(); +#endif // wxUSE_SOCKETS_FOR_IPC } virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) @@ -175,7 +188,7 @@ private: DECLARE_NO_COPY_CLASS(IPCTestClient) }; -static IPCTestClient gs_client; +static IPCTestClient *gs_client = NULL; // ---------------------------------------------------------------------------- // the test code itself @@ -200,28 +213,28 @@ private: DECLARE_NO_COPY_CLASS(IPCTestCase) }; -// this test is not enabled by default because it requires an IPC server to run -//CPPUNIT_TEST_SUITE_REGISTRATION( IPCTestCase ); +CPPUNIT_TEST_SUITE_REGISTRATION( IPCTestCase ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IPCTestCase, "IPCTestCase" ); void IPCTestCase::Connect() { gs_server = new IPCTestServer; + gs_client = new IPCTestClient; // connecting to the wrong port should fail - CPPUNIT_ASSERT( !gs_client.Connect("localhost", "2424", IPC_TEST_TOPIC) ); + CPPUNIT_ASSERT( !gs_client->Connect("localhost", "2424", IPC_TEST_TOPIC) ); // connecting using an unsupported topic should fail (unless the server // expects a ROT-13'd topic name...) - CPPUNIT_ASSERT( !gs_client.Connect("localhost", IPC_TEST_PORT, "VCP GRFG") ); + CPPUNIT_ASSERT( !gs_client->Connect("localhost", IPC_TEST_PORT, "VCP GRFG") ); // connecting to the right port on the right topic should succeed - CPPUNIT_ASSERT( gs_client.Connect("localhost", IPC_TEST_PORT, IPC_TEST_TOPIC) ); + CPPUNIT_ASSERT( gs_client->Connect("localhost", IPC_TEST_PORT, IPC_TEST_TOPIC) ); } void IPCTestCase::Execute() { - wxConnectionBase& conn = gs_client.GetConn(); + wxConnectionBase& conn = gs_client->GetConn(); const wxString s("Date"); CPPUNIT_ASSERT( conn.Execute(s) ); @@ -233,7 +246,12 @@ void IPCTestCase::Execute() void IPCTestCase::Disconnect() { - gs_client.Disconnect(); + if ( gs_client ) + { + gs_client->Disconnect(); + delete gs_client; + gs_client = NULL; + } if ( gs_server ) { @@ -243,3 +261,5 @@ void IPCTestCase::Disconnect() } #endif // wxUSE_THREADS + +#endif // !__WINDOWS__