From: Jason McDonald Date: Fri, 6 May 2011 06:55:31 +0000 (+1000) Subject: Remove Q_ASSERT's from QMutex autotest X-Git-Tag: qt-v5.0.0-alpha1~4297^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f872c1a06561bdaa6f05fa33fe0c4b0a42b13179;p=profile%2Fivi%2Fqtbase.git Remove Q_ASSERT's from QMutex autotest Don't perform actions needed for the test inside Q_ASSERT, because these actions won't happen in a non-debug build. Instead count the number of failures and verify that the count is zero at the end of the test. Change-Id: Ibe0d194111e5247118d59a7760f0946d2c44faf9 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern (cherry picked from commit 8d2127d44e6c8af6b041688376de0e5747a1810a) --- diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index 99fa985..c3b3575 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -462,6 +462,7 @@ public: static QBasicAtomicInt lockCount; static QBasicAtomicInt sentinel; static QMutex mutex; + static int errorCount; void start() { t.start(); @@ -471,13 +472,13 @@ public: { while (t.elapsed() < one_minute) { mutex.lock(); - Q_ASSERT(!sentinel.ref()); - Q_ASSERT(sentinel.deref()); + if (sentinel.ref()) ++errorCount; + if (!sentinel.deref()) ++errorCount; lockCount.ref(); mutex.unlock(); if (mutex.tryLock()) { - Q_ASSERT(!sentinel.ref()); - Q_ASSERT(sentinel.deref()); + if (sentinel.ref()) ++errorCount; + if (!sentinel.deref()) ++errorCount; lockCount.ref(); mutex.unlock(); } @@ -487,6 +488,7 @@ public: QMutex StressTestThread::mutex; QBasicAtomicInt StressTestThread::lockCount = Q_BASIC_ATOMIC_INITIALIZER(0); QBasicAtomicInt StressTestThread::sentinel = Q_BASIC_ATOMIC_INITIALIZER(-1); +int StressTestThread::errorCount = 0; void tst_QMutex::stressTest() { @@ -496,6 +498,7 @@ void tst_QMutex::stressTest() QVERIFY(threads[0].wait(one_minute + 10000)); for (int i = 1; i < threadCount; ++i) QVERIFY(threads[i].wait(10000)); + QCOMPARE(StressTestThread::errorCount, 0); qDebug("locked %d times", int(StressTestThread::lockCount)); }