From 69b256285b5c5d7d650c6abb19ac05a51e29d0d8 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 19 Aug 2014 10:26:15 +0200 Subject: [PATCH] tst_qsqlthread: Move manual qWait calls into QTRY_VERIFY Reduces the average runtime of this test for me by ~600ms, but due to the threading variance the exact reduction is hard to tell. Change-Id: I96a9f949ae2381f69d9364e6637db0db4bd3b165 Reviewed-by: Joerg Bornemann --- .../auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index 61b4305d13..fc6122ebeb 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -383,8 +383,7 @@ void tst_QSqlThread::simpleThreading() t1.start(); t2.start(); - while (threadFinishedCount < 2) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= 2); } // This test creates two threads that clone their db connection and read @@ -409,8 +408,7 @@ void tst_QSqlThread::readWriteThreading() producer.start(); consumer.start(); - while (threadFinishedCount < 2) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= 2); } // run with n threads in parallel. Change this constant to hammer the poor DB server even more @@ -433,8 +431,7 @@ void tst_QSqlThread::readFromSingleConnection() reader->start(); } - while (threadFinishedCount < maxThreadCount) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= maxThreadCount); #endif } @@ -459,8 +456,7 @@ void tst_QSqlThread::readWriteFromSingleConnection() writer->start(); } - while (threadFinishedCount < maxThreadCount * 2) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= maxThreadCount * 2); #endif } @@ -485,8 +481,7 @@ void tst_QSqlThread::preparedReadWriteFromSingleConnection() writer->start(); } - while (threadFinishedCount < maxThreadCount * 2) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= maxThreadCount * 2); #endif }