summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-08-22 17:47:27 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-23 11:20:37 +0200
commit8e0bac89d4b0f01b71c57f79a3b98a6ecb7f20ae (patch)
tree1edabb63f179d8f590fdf3b9b30442713762c498
parent2292bf06693c683ba353bcbea6ab9bd1209044ea (diff)
tst_QMutex: add markers to the tryLock tests
Just to make it clear which two sections go together. Change-Id: If3724d1c84172a61bdd7931cc567f4b7140d4f8a Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index 72670ab33f..d6ece1de4a 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -80,10 +80,12 @@ void tst_QMutex::tryLock()
{
testsTurn.release();
+ // TEST 1: thread can't acquire lock
threadsTurn.acquire();
QVERIFY(!normalMutex.tryLock());
testsTurn.release();
+ // TEST 2: thread can acquire lock
threadsTurn.acquire();
QVERIFY(normalMutex.tryLock());
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
@@ -92,6 +94,7 @@ void tst_QMutex::tryLock()
normalMutex.unlock();
testsTurn.release();
+ // TEST 3: thread can't acquire lock, timeout = waitTime
threadsTurn.acquire();
QTime timer;
timer.start();
@@ -99,22 +102,26 @@ void tst_QMutex::tryLock()
QVERIFY(timer.elapsed() >= waitTime);
testsTurn.release();
+ // TEST 4: thread can acquire lock, timeout = waitTime
threadsTurn.acquire();
timer.start();
QVERIFY(normalMutex.tryLock(waitTime));
QVERIFY(timer.elapsed() <= waitTime);
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
timer.start();
+ // it's non-recursive, so the following lock needs to fail
QVERIFY(!normalMutex.tryLock(waitTime));
QVERIFY(timer.elapsed() >= waitTime);
QVERIFY(lockCount.testAndSetRelaxed(1, 0));
normalMutex.unlock();
testsTurn.release();
+ // TEST 5: thread can't acquire lock, timeout = 0
threadsTurn.acquire();
QVERIFY(!normalMutex.tryLock(0));
testsTurn.release();
+ // TEST 6: thread can acquire lock, timeout = 0
threadsTurn.acquire();
timer.start();
QVERIFY(normalMutex.tryLock(0));
@@ -132,37 +139,37 @@ void tst_QMutex::tryLock()
Thread thread;
thread.start();
- // thread can't acquire lock
+ // TEST 1: thread can't acquire lock
testsTurn.acquire();
normalMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
threadsTurn.release();
- // thread can acquire lock
+ // TEST 2: thread can acquire lock
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(1, 0));
normalMutex.unlock();
threadsTurn.release();
- // thread can't acquire lock, timeout = waitTime
+ // TEST 3: thread can't acquire lock, timeout = waitTime
testsTurn.acquire();
normalMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
threadsTurn.release();
- // thread can acquire lock, timeout = waitTime
+ // TEST 4: thread can acquire lock, timeout = waitTime
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(1, 0));
normalMutex.unlock();
threadsTurn.release();
- // thread can't acquire lock, timeout = 0
+ // TEST 5: thread can't acquire lock, timeout = 0
testsTurn.acquire();
normalMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
threadsTurn.release();
- // thread can acquire lock, timeout = 0
+ // TEST 6: thread can acquire lock, timeout = 0
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(1, 0));
normalMutex.unlock();