mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-23 06:33:59 +08:00
Add a multithreaded test for IPC over sockets
Add a test exercising the IPC-over-sockets implementation from a single thread and from multiple threads concurrently (Execute, Request, Poke, Advise, combined Advise+Request, and concurrent main-thread and worker-thread Request()s). Each test starts its own server by re-executing the test program with WX_IPC_TEST_SERVER set and shuts it down again in the fixture teardown, so no server process outlives a test (or disturbs the unrelated GUI tests in test_gui). The client runs in the main Catch2 process and queries the server for state to verify it (Catch2 macros cannot run in the server process). The wait loops are wall-clock bounded so they behave under a GUI event loop, and a per-fixture watchdog aborts with a diagnostic if a test ever hangs rather than letting CI time out. The test runs in both the console "test" and the GUI "test_gui" programs. It is excluded from one configuration: wxQt, whose event loop does not reliably process a cross-thread CallAfter() (a wxQt bug fixed separately).
This commit is contained in:
committed by
Vadim Zeitlin
parent
90a9968a1d
commit
122ff6d7db
@@ -52,6 +52,7 @@ set(TEST_SRC
|
||||
misc/pathlist.cpp
|
||||
misc/typeinfotest.cpp
|
||||
net/ipc.cpp
|
||||
net/ipc_test_server.cpp
|
||||
net/socket.cpp
|
||||
net/webrequest.cpp
|
||||
regex/regextest.cpp
|
||||
@@ -124,6 +125,7 @@ set(TEST_DATA
|
||||
wx_add_test(test_base CONSOLE ${TEST_SRC}
|
||||
DATA ${TEST_DATA}
|
||||
)
|
||||
target_compile_definitions(test_base PRIVATE TEST_HAS_IPC_SERVER)
|
||||
if(wxUSE_SOCKETS)
|
||||
wx_exe_link_libraries(test_base wxnet)
|
||||
endif()
|
||||
|
||||
+16
-3
@@ -102,6 +102,7 @@ TEST_OBJECTS = \
|
||||
test_pathlist.o \
|
||||
test_typeinfotest.o \
|
||||
test_ipc.o \
|
||||
test_ipc_test_server.o \
|
||||
test_socket.o \
|
||||
test_webrequest.o \
|
||||
test_regextest.o \
|
||||
@@ -162,7 +163,7 @@ TEST_GUI_CXXFLAGS = $(__test_gui_PCH_INC) $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ \
|
||||
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \
|
||||
$(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) \
|
||||
-I$(srcdir)/../samples $(WX_CXXFLAGS) $(SAMPLES_CXXFLAGS) $(CATCH2_CFLAGS) \
|
||||
$(CPPFLAGS) $(CXXFLAGS)
|
||||
-DTEST_HAS_IPC_SERVER $(CPPFLAGS) $(CXXFLAGS)
|
||||
TEST_GUI_OBJECTS = \
|
||||
$(__test_gui___win32rc) \
|
||||
test_gui_asserthelper.o \
|
||||
@@ -265,6 +266,8 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_settings.o \
|
||||
test_gui_textwrap.o \
|
||||
test_gui_socket.o \
|
||||
test_gui_ipc.o \
|
||||
test_gui_ipc_test_server.o \
|
||||
test_gui_tlw.o \
|
||||
test_gui_dataview.o \
|
||||
test_gui_rowheightcachetest.o \
|
||||
@@ -292,6 +295,7 @@ TEST_ALLHEADERS_OBJECTS = \
|
||||
TEST_ALLHEADERS_ODEP = \
|
||||
$(_____pch_testprec_test_allheaders_testprec_h_gch___depname)
|
||||
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
@COND_DEPS_TRACKING_0@CXXC = $(CXX)
|
||||
@@ -562,7 +566,7 @@ test$(EXEEXT): $(TEST_OBJECTS) $(__test___win32rc)
|
||||
@COND_USE_PCH_1@./.pch/testprec_test_allheaders/testprec.h.gch:
|
||||
@COND_USE_PCH_1@ $(BK_MAKE_PCH) ./.pch/testprec_test_allheaders/testprec.h.gch testprec.h $(CXX) $(TEST_ALLHEADERS_CXXFLAGS)
|
||||
|
||||
data:
|
||||
data:
|
||||
@mkdir -p .
|
||||
@for f in testdata.conf horse.svg; do \
|
||||
if test ! -f ./$$f -a ! -d ./$$f ; \
|
||||
@@ -650,7 +654,7 @@ test_test_rc.o: $(srcdir)/../tests/test.rc $(TEST_ODEP)
|
||||
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_9) $(__DEBUG_DEFINE_p_9) $(__EXCEPTIONS_DEFINE_p_9) $(__RTTI_DEFINE_p_9) $(__THREAD_DEFINE_p_9) --include-dir $(srcdir) $(__DLLFLAG_p_9) --define wxUSE_GUI=0 --include-dir $(top_srcdir)/samples $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include
|
||||
|
||||
test_test.o: $(srcdir)/test.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/test.cpp
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) -DTEST_HAS_IPC_SERVER $(srcdir)/test.cpp
|
||||
|
||||
test_anytest.o: $(srcdir)/any/anytest.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/any/anytest.cpp
|
||||
@@ -781,6 +785,9 @@ test_typeinfotest.o: $(srcdir)/misc/typeinfotest.cpp $(TEST_ODEP)
|
||||
test_ipc.o: $(srcdir)/net/ipc.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/net/ipc.cpp
|
||||
|
||||
test_ipc_test_server.o: $(srcdir)/net/ipc_test_server.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/net/ipc_test_server.cpp
|
||||
|
||||
test_socket.o: $(srcdir)/net/socket.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/net/socket.cpp
|
||||
|
||||
@@ -1225,6 +1232,12 @@ test_gui_textwrap.o: $(srcdir)/misc/textwrap.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_socket.o: $(srcdir)/net/socket.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/net/socket.cpp
|
||||
|
||||
test_gui_ipc.o: $(srcdir)/net/ipc.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/net/ipc.cpp
|
||||
|
||||
test_gui_ipc_test_server.o: $(srcdir)/net/ipc_test_server.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/net/ipc_test_server.cpp
|
||||
|
||||
test_gui_tlw.o: $(srcdir)/persistence/tlw.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/persistence/tlw.cpp
|
||||
|
||||
|
||||
+6
-2
@@ -97,6 +97,7 @@ TEST_OBJECTS = \
|
||||
test_typeinfotest.obj
|
||||
|
||||
TEST_OBJECTS1=test_ipc.obj,\
|
||||
test_ipc_test_server.obj,\
|
||||
test_socket.obj,\
|
||||
test_regextest.obj,\
|
||||
test_wxregextest.obj,\
|
||||
@@ -374,10 +375,13 @@ test_pathlist.obj : [.misc]pathlist.cpp
|
||||
test_typeinfotest.obj : [.misc]typeinfotest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]typeinfotest.cpp
|
||||
|
||||
test_ipc.obj : [.net]ipc.cpp
|
||||
test_ipc.obj : [.net]ipc.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.net]ipc.cpp
|
||||
|
||||
test_socket.obj : [.net]socket.cpp
|
||||
test_ipc_test_server.obj : [.net]ipc_test_server.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.net]ipc_test_server.cpp
|
||||
|
||||
test_socket.obj : [.net]socket.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS)/warn=(disable=REFTEMPORARY)\
|
||||
[.net]socket.cpp
|
||||
|
||||
|
||||
+15
-3
@@ -74,6 +74,7 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_pathlist.o \
|
||||
$(OBJS)\test_typeinfotest.o \
|
||||
$(OBJS)\test_ipc.o \
|
||||
$(OBJS)\test_ipc_test_server.o \
|
||||
$(OBJS)\test_socket.o \
|
||||
$(OBJS)\test_webrequest.o \
|
||||
$(OBJS)\test_regextest.o \
|
||||
@@ -135,8 +136,8 @@ TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
-I$(SETUPHDIR) -I.\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall -I. \
|
||||
$(__DLLFLAG_p) -I.\..\samples -DNOPCH -I.\..\3rdparty\catch\single_include \
|
||||
$(__RTTIFLAG) $(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) \
|
||||
$(CXXFLAGS)
|
||||
$(__RTTIFLAG) $(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy \
|
||||
-DTEST_HAS_IPC_SERVER $(CPPFLAGS) $(CXXFLAGS)
|
||||
TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_test_rc.o \
|
||||
$(OBJS)\test_gui_dummy.o \
|
||||
@@ -240,6 +241,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_settings.o \
|
||||
$(OBJS)\test_gui_textwrap.o \
|
||||
$(OBJS)\test_gui_socket.o \
|
||||
$(OBJS)\test_gui_ipc.o \
|
||||
$(OBJS)\test_gui_ipc_test_server.o \
|
||||
$(OBJS)\test_gui_tlw.o \
|
||||
$(OBJS)\test_gui_dataview.o \
|
||||
$(OBJS)\test_gui_rowheightcachetest.o \
|
||||
@@ -585,7 +588,7 @@ $(OBJS)\test_dummy.o: ./dummy.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_test.o: ./test.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) -DTEST_HAS_IPC_SERVER $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_anytest.o: ./any/anytest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
@@ -716,6 +719,9 @@ $(OBJS)\test_typeinfotest.o: ./misc/typeinfotest.cpp
|
||||
$(OBJS)\test_ipc.o: ./net/ipc.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_ipc_test_server.o: ./net/ipc_test_server.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_socket.o: ./net/socket.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
@@ -1166,6 +1172,12 @@ $(OBJS)\test_gui_textwrap.o: ./misc/textwrap.cpp
|
||||
$(OBJS)\test_gui_socket.o: ./net/socket.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_ipc.o: ./net/ipc.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_ipc_test_server.o: ./net/ipc_test_server.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_tlw.o: ./persistence/tlw.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
||||
+15
-2
@@ -75,6 +75,7 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_pathlist.obj \
|
||||
$(OBJS)\test_typeinfotest.obj \
|
||||
$(OBJS)\test_ipc.obj \
|
||||
$(OBJS)\test_ipc_test_server.obj \
|
||||
$(OBJS)\test_socket.obj \
|
||||
$(OBJS)\test_webrequest.obj \
|
||||
$(OBJS)\test_regextest.obj \
|
||||
@@ -149,7 +150,8 @@ TEST_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_44)$(__DEBUGRUNTIME) /DWIN32 \
|
||||
/I$(SETUPHDIR) /I.\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
|
||||
$(__DLLFLAG_p) /I.\..\samples /DNOPCH /I.\..\3rdparty\catch\single_include \
|
||||
/D_CONSOLE $(__RTTIFLAG) $(__EXCEPTIONSFLAG) /Yu"testprec.h" \
|
||||
/Fp"$(OBJS)\testprec_test_gui.pch" $(CPPFLAGS) $(CXXFLAGS)
|
||||
/Fp"$(OBJS)\testprec_test_gui.pch" -DTEST_HAS_IPC_SERVER $(CPPFLAGS) \
|
||||
$(CXXFLAGS)
|
||||
TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_dummy.obj \
|
||||
$(OBJS)\test_gui_asserthelper.obj \
|
||||
@@ -252,6 +254,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_settings.obj \
|
||||
$(OBJS)\test_gui_textwrap.obj \
|
||||
$(OBJS)\test_gui_socket.obj \
|
||||
$(OBJS)\test_gui_ipc.obj \
|
||||
$(OBJS)\test_gui_ipc_test_server.obj \
|
||||
$(OBJS)\test_gui_tlw.obj \
|
||||
$(OBJS)\test_gui_dataview.obj \
|
||||
$(OBJS)\test_gui_rowheightcachetest.obj \
|
||||
@@ -873,7 +877,7 @@ $(OBJS)\test_dummy.obj: .\dummy.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) /Yctestprec.h .\dummy.cpp
|
||||
|
||||
$(OBJS)\test_test.obj: .\test.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\test.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) /DTEST_HAS_IPC_SERVER .\test.cpp
|
||||
|
||||
$(OBJS)\test_anytest.obj: .\any\anytest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\any\anytest.cpp
|
||||
@@ -1004,6 +1008,9 @@ $(OBJS)\test_typeinfotest.obj: .\misc\typeinfotest.cpp
|
||||
$(OBJS)\test_ipc.obj: .\net\ipc.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\net\ipc.cpp
|
||||
|
||||
$(OBJS)\test_ipc_test_server.obj: .\net\ipc_test_server.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\net\ipc_test_server.cpp
|
||||
|
||||
$(OBJS)\test_socket.obj: .\net\socket.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\net\socket.cpp
|
||||
|
||||
@@ -1454,6 +1461,12 @@ $(OBJS)\test_gui_textwrap.obj: .\misc\textwrap.cpp
|
||||
$(OBJS)\test_gui_socket.obj: .\net\socket.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\net\socket.cpp
|
||||
|
||||
$(OBJS)\test_gui_ipc.obj: .\net\ipc.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\net\ipc.cpp
|
||||
|
||||
$(OBJS)\test_gui_ipc_test_server.obj: .\net\ipc_test_server.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\net\ipc_test_server.cpp
|
||||
|
||||
$(OBJS)\test_gui_tlw.obj: .\persistence\tlw.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\persistence\tlw.cpp
|
||||
|
||||
|
||||
+922
-156
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/net/ipc_setup_test.h
|
||||
// Purpose: IPC classes unit tests
|
||||
// Author: Vadim Zeitlin
|
||||
// Copyright: (c) 2008
|
||||
// Modified by: JP Mattia, 2024
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_NET_IPC_H_
|
||||
#define _WX_TESTS_NET_IPC_H_
|
||||
|
||||
// This test was written for sockets
|
||||
#define wxUSE_SOCKETS_FOR_IPC 1
|
||||
#define wxUSE_DDE_FOR_IPC 0
|
||||
|
||||
#define IPC_TEST_PORT "4242"
|
||||
#define IPC_TEST_TOPIC "IPC TEST"
|
||||
|
||||
// Many IPC issues show up only after several iterations, and
|
||||
// MESSAGE_ITERATIONS sets the number of iterations. The value of 20 is chosen
|
||||
// as a compromise between exposing race conditions vs slowing down the
|
||||
// overall automated test process.
|
||||
//
|
||||
// For stress-testing: if the number of MESSAGE_ITERATIONS is set much beyond
|
||||
// 200, then the client-side wait bounds should likely also be increased.
|
||||
// Search for "Wait a maximum" in ipc.cpp to find those values. (The server
|
||||
// side needs no adjustment: it paces each Advise() and otherwise waits for
|
||||
// completion, so it scales with the iteration count on its own.)
|
||||
#define MESSAGE_ITERATIONS 20
|
||||
#define MESSAGE_ITERATIONS_STRING wxString::Format("%d",MESSAGE_ITERATIONS)
|
||||
|
||||
#endif // _WX_TESTS_NET_IPC_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/net/ipc_test_server.h
|
||||
// Purpose: IPC test server (in-process on Windows, same-binary subprocess
|
||||
// on Unix where wxSocket IPC requires main-thread event dispatch)
|
||||
// Author: JP Mattia
|
||||
// Copyright: (c) 2024
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_NET_IPC_TEST_SERVER_H_
|
||||
#define _WX_TESTS_NET_IPC_TEST_SERVER_H_
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
#include "wx/thread.h"
|
||||
|
||||
// Match the guard in tests/net/ipc.cpp and ipc_test_server.cpp: the IPC test is
|
||||
// excluded from wxQt, so its declarations must be too.
|
||||
#if wxUSE_THREADS && !defined(__WXQT__)
|
||||
|
||||
#include <memory>
|
||||
|
||||
// Starts the IPC test server and blocks until it is listening (or failed).
|
||||
// Stops the server in WaitForExit().
|
||||
class IPCServerThread
|
||||
{
|
||||
public:
|
||||
IPCServerThread();
|
||||
~IPCServerThread();
|
||||
|
||||
bool Start();
|
||||
void WaitForExit();
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
std::unique_ptr<Private> m_priv;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(IPCServerThread);
|
||||
};
|
||||
|
||||
// Called from tests/test.cpp when WX_IPC_TEST_SERVER is set in the environment.
|
||||
void RunIPCServerUntilStopped();
|
||||
|
||||
// Dispatch client-side socket events (implemented in ipc.cpp).
|
||||
void IPCClientDispatch(unsigned long timeoutMs = 10);
|
||||
|
||||
// Wait for a joinable thread to finish while pumping the client event loop.
|
||||
// Worker threads marshal their IPC socket I/O to the main thread (see
|
||||
// wxTCPEventHandler::RunOnMainThread), so we must keep dispatching here for those
|
||||
// marshaled jobs to run; otherwise the worker blocks forever. This is safe now
|
||||
// that workers no longer touch the socket themselves (which is what previously
|
||||
// made re-entrant dispatch corrupt the connection).
|
||||
inline void WaitForThreadWithDispatch(wxThread& thread)
|
||||
{
|
||||
while ( thread.IsRunning() )
|
||||
IPCClientDispatch(10);
|
||||
|
||||
thread.Wait();
|
||||
}
|
||||
|
||||
#endif // wxUSE_THREADS && !__WXQT__
|
||||
|
||||
#endif // _WX_TESTS_NET_IPC_TEST_SERVER_H_
|
||||
+10
-3
@@ -34,6 +34,7 @@
|
||||
|
||||
<exe id="test" template="wx_sample_console,wx_test"
|
||||
template_append="wx_append_base">
|
||||
<cxxflags>-DTEST_HAS_IPC_SERVER</cxxflags>
|
||||
<sources>
|
||||
test.cpp
|
||||
any/anytest.cpp
|
||||
@@ -79,6 +80,7 @@
|
||||
misc/pathlist.cpp
|
||||
misc/typeinfotest.cpp
|
||||
net/ipc.cpp
|
||||
net/ipc_test_server.cpp
|
||||
net/socket.cpp
|
||||
net/webrequest.cpp
|
||||
regex/regextest.cpp
|
||||
@@ -165,6 +167,9 @@
|
||||
<!-- link against GUI libraries, but be a console app: -->
|
||||
<app-type>console</app-type>
|
||||
|
||||
<!-- needed by the duplicated net/ipc.cpp test below -->
|
||||
<cxxflags>-DTEST_HAS_IPC_SERVER</cxxflags>
|
||||
|
||||
<sources>
|
||||
asserthelper.cpp
|
||||
test.cpp
|
||||
@@ -276,11 +281,13 @@
|
||||
misc/settings.cpp
|
||||
misc/textwrap.cpp
|
||||
<!--
|
||||
This one is intentionally duplicated here (it is also part of
|
||||
non-GUI test) as sockets behave differently in console and GUI
|
||||
applications.
|
||||
These are intentionally duplicated here (they are also part of
|
||||
the non-GUI test) as sockets and IPC behave differently in
|
||||
console and GUI applications.
|
||||
-->
|
||||
net/socket.cpp
|
||||
net/ipc.cpp
|
||||
net/ipc_test_server.cpp
|
||||
persistence/tlw.cpp
|
||||
persistence/dataview.cpp
|
||||
rowheightcache/rowheightcachetest.cpp
|
||||
|
||||
@@ -55,6 +55,14 @@ std::string wxTheCurrentTestClass, wxTheCurrentTestMethod;
|
||||
#include "wx/socket.h"
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
// __WXQT__ guard: see the longer note in tests/net/ipc.cpp. The IPC test (and
|
||||
// its server) is excluded from wxQt (cross-thread CallAfter() not processed by
|
||||
// the wxQt event loop, fixed separately on branch
|
||||
// jpmattia/wxQT-CallAfter-wxWakeUpIdle).
|
||||
#if wxUSE_THREADS && defined(TEST_HAS_IPC_SERVER) && !defined(__WXQT__)
|
||||
#include "net/ipc_test_server.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -340,6 +348,22 @@ public:
|
||||
|
||||
virtual int OnRun() override
|
||||
{
|
||||
#if wxUSE_THREADS && defined(TEST_HAS_IPC_SERVER) && !defined(__WXQT__)
|
||||
// The IPC test re-executes this same binary as its server (with
|
||||
// WX_IPC_TEST_SERVER set), so test_gui must run the server here too,
|
||||
// exactly as the console test does in the non-GUI OnRun() below. See the
|
||||
// note there and tests/net/ipc.cpp for the wxQt exclusion.
|
||||
if ( wxGetEnv("WX_IPC_TEST_SERVER", nullptr) )
|
||||
{
|
||||
// Suppress the idle-driven test runner: RunIPCServerUntilStopped()
|
||||
// spins its own event loop, and our OnIdle() would otherwise fire
|
||||
// there and run the whole test suite inside the server process.
|
||||
m_runTests = false;
|
||||
RunIPCServerUntilStopped();
|
||||
return 0;
|
||||
}
|
||||
#endif // wxUSE_THREADS && TEST_HAS_IPC_SERVER && !__WXQT__
|
||||
|
||||
if ( !IsGUIEnabled() )
|
||||
return 0;
|
||||
|
||||
@@ -351,6 +375,18 @@ public:
|
||||
#else // !wxUSE_GUI
|
||||
virtual int OnRun() override
|
||||
{
|
||||
#if wxUSE_THREADS && defined(TEST_HAS_IPC_SERVER) && !defined(__WXQT__)
|
||||
// The IPC test starts its server by re-executing this same binary with
|
||||
// WX_IPC_TEST_SERVER set and then running a bare event loop here. The IPC
|
||||
// sources and TEST_HAS_IPC_SERVER are built into both the console "test"
|
||||
// and "test_gui" programs, so the GUI OnRun() above has the same hook.
|
||||
if ( wxGetEnv("WX_IPC_TEST_SERVER", nullptr) )
|
||||
{
|
||||
RunIPCServerUntilStopped();
|
||||
return 0;
|
||||
}
|
||||
#endif // wxUSE_THREADS && TEST_HAS_IPC_SERVER && !__WXQT__
|
||||
|
||||
return RunTests();
|
||||
}
|
||||
#endif // wxUSE_GUI/!wxUSE_GUI
|
||||
|
||||
+4
-1
@@ -972,6 +972,7 @@
|
||||
<ClCompile Include="misc\pathlist.cpp" />
|
||||
<ClCompile Include="misc\typeinfotest.cpp" />
|
||||
<ClCompile Include="net\ipc.cpp" />
|
||||
<ClCompile Include="net\ipc_test_server.cpp" />
|
||||
<ClCompile Include="net\socket.cpp" />
|
||||
<ClCompile Include="net\webrequest.cpp" />
|
||||
<ClCompile Include="regex\regextest.cpp" />
|
||||
@@ -1002,7 +1003,9 @@
|
||||
<ClCompile Include="strings\vararg.cpp" />
|
||||
<ClCompile Include="strings\vsnprintf.cpp" />
|
||||
<ClCompile Include="strings\hexconv.cpp" />
|
||||
<ClCompile Include="test.cpp" />
|
||||
<ClCompile Include="test.cpp">
|
||||
<PreprocessorDefinitions>TEST_HAS_IPC_SERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="textfile\textfiletest.cpp" />
|
||||
<ClCompile Include="thread\atomic.cpp" />
|
||||
<ClCompile Include="thread\misc.cpp" />
|
||||
|
||||
@@ -124,6 +124,9 @@
|
||||
<ClCompile Include="net\ipc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="net\ipc_test_server.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="streams\largefile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -1024,13 +1024,17 @@
|
||||
<ClCompile Include="misc\selstoretest.cpp" />
|
||||
<ClCompile Include="misc\settings.cpp" />
|
||||
<ClCompile Include="misc\textwrap.cpp" />
|
||||
<ClCompile Include="net\ipc.cpp" />
|
||||
<ClCompile Include="net\ipc_test_server.cpp" />
|
||||
<ClCompile Include="net\socket.cpp" />
|
||||
<ClCompile Include="persistence\tlw.cpp" />
|
||||
<ClCompile Include="persistence\dataview.cpp" />
|
||||
<ClCompile Include="sizers\boxsizer.cpp" />
|
||||
<ClCompile Include="sizers\gridsizer.cpp" />
|
||||
<ClCompile Include="sizers\wrapsizer.cpp" />
|
||||
<ClCompile Include="test.cpp" />
|
||||
<ClCompile Include="test.cpp">
|
||||
<PreprocessorDefinitions>TEST_HAS_IPC_SERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="testableframe.cpp" />
|
||||
<ClCompile Include="toplevel\toplevel.cpp" />
|
||||
<ClCompile Include="validators\valnum.cpp" />
|
||||
|
||||
@@ -233,6 +233,12 @@
|
||||
<ClCompile Include="controls\slidertest.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="net\ipc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="net\ipc_test_server.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="net\socket.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
Reference in New Issue
Block a user