summaryrefslogtreecommitdiffstats
path: root/tests/auto/qmutex
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-05-06 16:55:31 +1000
committerJason McDonald <jason.mcdonald@nokia.com>2011-05-06 17:40:10 +1000
commit8d2127d44e6c8af6b041688376de0e5747a1810a (patch)
treecbb3cb2690066ecaba401690499f7f5d7217386b /tests/auto/qmutex
parent8512dc16553ecf511c40a2ba7a815f777d7d5c59 (diff)
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
Diffstat (limited to 'tests/auto/qmutex')
-rw-r--r--tests/auto/qmutex/tst_qmutex.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp
index dc3ffa457c..e1ad2d2243 100644
--- a/tests/auto/qmutex/tst_qmutex.cpp
+++ b/tests/auto/qmutex/tst_qmutex.cpp
@@ -393,6 +393,7 @@ public:
static QBasicAtomicInt lockCount;
static QBasicAtomicInt sentinel;
static QMutex mutex;
+ static int errorCount;
void start()
{
t.start();
@@ -402,13 +403,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();
}
@@ -418,6 +419,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()
{
@@ -427,6 +429,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));
}