From 729dd5e6930461dfec0138cc02c8bfea65582fb7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 1 Nov 2017 22:23:15 +0100 Subject: [PATCH] Work around Catch multi-thread unsafety Don't use Catch asserts in threads other than main, this doesn't work reliably. Switch to using simple wxASSERT() which doesn't give as much information as Catch asserts when the test fails, but at least allows the tests to pass when the asserts don't fail. --- tests/thread/queue.cpp | 8 +++++--- tests/thread/tls.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/thread/queue.cpp b/tests/thread/queue.cpp index 42ceb319c5..9188265d13 100644 --- a/tests/thread/queue.cpp +++ b/tests/thread/queue.cpp @@ -195,20 +195,22 @@ void *QueueTestCase::MyThread::Entry() if ( res == wxMSGQUEUE_MISC_ERROR ) return (wxThread::ExitCode)wxMSGQUEUE_MISC_ERROR; - CPPUNIT_ASSERT_EQUAL( wxMSGQUEUE_NO_ERROR, res ); + // We can't use Catch asserts outside of the main thread + // currently, unfortunately. + wxASSERT( res == wxMSGQUEUE_NO_ERROR ); } ++messagesReceived; continue; } - CPPUNIT_ASSERT_EQUAL ( result, wxMSGQUEUE_TIMEOUT ); + wxASSERT( result == wxMSGQUEUE_TIMEOUT ); break; } if ( messagesReceived != m_maxMsgCount ) { - CPPUNIT_ASSERT_EQUAL( m_type, WaitWithTimeout ); + wxASSERT( m_type == WaitWithTimeout ); return (wxThread::ExitCode)wxMSGQUEUE_TIMEOUT; } diff --git a/tests/thread/tls.cpp b/tests/thread/tls.cpp index 029f4e6be8..ab92177f33 100644 --- a/tests/thread/tls.cpp +++ b/tests/thread/tls.cpp @@ -63,8 +63,10 @@ public: gs_threadData.name = "worker"; gs_threadData.number = 2; - CPPUNIT_ASSERT_EQUAL( std::string("worker"), gs_threadData.name ); - CPPUNIT_ASSERT_EQUAL( 2, gs_threadData.number ); + // We can't use Catch asserts outside of the main thread, + // unfortunately. + wxASSERT( gs_threadData.name == std::string("worker") ); + wxASSERT( gs_threadData.number == 2 ); return NULL; }