summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-05-09 03:46:32 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2011-05-09 08:37:39 (GMT)
commit00f724c943b83f10f9ca9475570708536947538e (patch)
tree5ee84cad7bf50d8d4882cd55d39d0208366953f2
parent0c157af3e5aa7c56c53b9eabe1510cc639610969 (diff)
downloadQt-00f724c943b83f10f9ca9475570708536947538e.zip
Qt-00f724c943b83f10f9ca9475570708536947538e.tar.gz
Qt-00f724c943b83f10f9ca9475570708536947538e.tar.bz2
Remove Q_ASSERT's from qreadwritelock autotest
The tryWriteLock testfunction didn't do anything useful in non-debug builds, due to the thread having the important code inside Q_ASSERT's, which are no-ops in non-debug builds. This commit removes the Q_ASSERT's, counts the number of failures in the thread and fails the test if there are any failures recorded. Change-Id: I4750f66eeba22ab51ba348ebc06704052421f1ae Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern
-rw-r--r--tests/auto/qreadwritelock/tst_qreadwritelock.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/tests/auto/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/qreadwritelock/tst_qreadwritelock.cpp
index e0cc2fa..0d575a1 100644
--- a/tests/auto/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/auto/qreadwritelock/tst_qreadwritelock.cpp
@@ -362,34 +362,45 @@ void tst_QReadWriteLock::tryWriteLock()
class Thread : public QThread
{
public:
+ Thread() : failureCount(0) { }
void run()
{
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(!readWriteLock.tryLockForWrite());
+ if (readWriteLock.tryLockForWrite())
+ failureCount++;
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(readWriteLock.tryLockForWrite());
- Q_ASSERT(lockCount.testAndSetRelaxed(0, 1));
- Q_ASSERT(lockCount.testAndSetRelaxed(1, 0));
+ if (!readWriteLock.tryLockForWrite())
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(0, 1))
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(1, 0))
+ failureCount++;
readWriteLock.unlock();
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(!readWriteLock.tryLockForWrite(1000));
+ if (readWriteLock.tryLockForWrite(1000))
+ failureCount++;
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(readWriteLock.tryLockForWrite(1000));
- Q_ASSERT(lockCount.testAndSetRelaxed(0, 1));
- Q_ASSERT(lockCount.testAndSetRelaxed(1, 0));
+ if (!readWriteLock.tryLockForWrite(1000))
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(0, 1))
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(1, 0))
+ failureCount++;
readWriteLock.unlock();
testsTurn.release();
threadsTurn.acquire();
}
+
+ int failureCount;
};
Thread thread;
@@ -419,6 +430,8 @@ void tst_QReadWriteLock::tryWriteLock()
testsTurn.acquire();
threadsTurn.release();
thread.wait();
+
+ QCOMPARE(thread.failureCount, 0);
}
}