summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-08-29 08:33:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-29 10:25:01 +0200
commit5eb91476f15650c1cd443502fca093b21315ea09 (patch)
treed9ecac5ad9fdc8e5f99113b4c2b4a8380c0d7a72 /tests/auto/corelib/thread
parent4774ff8eb1a653162ff76ae49d67137f720469b0 (diff)
tst_qthreadpool: fix flaky test I introduced in last commit
(dacf9961da86) In order to see 2 active threads, we must check activeThreadCount() before the runnable finishes. Change-Id: I1a48b41e0c1fd81a65d915b9bd1e741ff267ed2b Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/thread')
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index cdf240d757..4a9932798c 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -638,6 +638,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
public:
QAtomicInt count;
QSemaphore waitForStarted;
+ QSemaphore waitBeforeDone;
WaitingTask() { setAutoDelete(false); }
@@ -645,6 +646,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
{
count.ref();
waitForStarted.release();
+ waitBeforeDone.acquire();
}
};
@@ -663,6 +665,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
threadpool->start(task);
QCOMPARE(threadpool->activeThreadCount(), 2);
task->waitForStarted.acquire();
+ task->waitBeforeDone.release();
QTRY_COMPARE(task->count.load(), 1);
QTRY_COMPARE(threadpool->activeThreadCount(), 1);
@@ -675,6 +678,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
threadpool->start(task);
QTRY_COMPARE(threadpool->activeThreadCount(), 2);
task->waitForStarted.acquire();
+ task->waitBeforeDone.release();
QTRY_COMPARE(task->count.load(), 2);
QTRY_COMPARE(threadpool->activeThreadCount(), 1);