diff options
Diffstat (limited to 'tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp')
-rw-r--r-- | tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index 881f2b5c7c..298834caf6 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -49,10 +49,6 @@ #include <QtSql> #include "qdebug.h" -#ifdef Q_OS_LINUX -#include <sched.h> -#endif - const QString qtest(qTableName("qtest", __FILE__, QSqlDatabase())); // set this define if Oracle is built with threading support //#define QOCI_THREADED @@ -81,7 +77,10 @@ public slots: void cleanup(); protected slots: - void threadFinished() { ++threadFinishedCount; } + void threadFinished() { + ++threadFinishedCount; + qDebug("Thread finished, total finished: %d", threadFinishedCount); + } private slots: void simpleThreading_data() { generic_data(); } @@ -158,9 +157,7 @@ public: q.bindValue(1, "threaddy"); q.bindValue(2, 10); QVERIFY_SQL(q, exec()); -#ifdef Q_OS_LINUX - sched_yield(); -#endif + QThread::yieldCurrentThread(); } } @@ -196,9 +193,7 @@ public: q2.bindValue("id", q1.value(0)); q1.clear(); QVERIFY_SQL(q2, exec()); -#ifdef Q_OS_LINUX - sched_yield(); -#endif + QThread::yieldCurrentThread(); } } @@ -391,8 +386,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 @@ -417,8 +411,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 @@ -441,8 +434,7 @@ void tst_QSqlThread::readFromSingleConnection() reader->start(); } - while (threadFinishedCount < maxThreadCount) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= maxThreadCount); #endif } @@ -467,8 +459,7 @@ void tst_QSqlThread::readWriteFromSingleConnection() writer->start(); } - while (threadFinishedCount < maxThreadCount * 2) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= maxThreadCount * 2); #endif } @@ -493,8 +484,7 @@ void tst_QSqlThread::preparedReadWriteFromSingleConnection() writer->start(); } - while (threadFinishedCount < maxThreadCount * 2) - QTest::qWait(100); + QTRY_VERIFY(threadFinishedCount >= maxThreadCount * 2); #endif } |