diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-03-01 07:57:03 (GMT) |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-03-01 07:57:03 (GMT) |
commit | e538957c77f71b1cc38a3c43c9f3157f65a3ff11 (patch) | |
tree | 3d013b12ba28668d127fe5532de5fc588fe63cb0 /tests/auto/qmutex/tst_qmutex.cpp | |
parent | 67d5513b5aca096dfc33952cf81219087b0e41b0 (diff) | |
parent | 2653c4fcf42ec93db16a299c29c9fe0f98680c75 (diff) | |
download | Qt-e538957c77f71b1cc38a3c43c9f3157f65a3ff11.zip Qt-e538957c77f71b1cc38a3c43c9f3157f65a3ff11.tar.gz Qt-e538957c77f71b1cc38a3c43c9f3157f65a3ff11.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts:
src/s60installs/bwins/QtGuiu.def
src/s60installs/eabi/QtGuiu.def
Diffstat (limited to 'tests/auto/qmutex/tst_qmutex.cpp')
-rw-r--r-- | tests/auto/qmutex/tst_qmutex.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index 3c4c767..ea983cb 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -67,6 +67,7 @@ private slots: void lock_unlock_locked_tryLock(); void stressTest(); void tryLockRace(); + void qtbug16115_trylock(); }; static const int iterations = 100; @@ -464,5 +465,42 @@ void tst_QMutex::tryLockRace() TryLockRaceThread::mutex.unlock(); } +static volatile int qtbug16115_trylock_counter; + +void tst_QMutex::qtbug16115_trylock() +{ + //Used to deadlock on unix + struct TrylockThread : QThread { + TrylockThread(QMutex &mut) : mut(mut) {} + QMutex &mut; + void run() { + for (int i = 0; i < 1000000; ++i) { + if (mut.tryLock(0)) { + Q_ASSERT((++qtbug16115_trylock_counter) == 1); + Q_ASSERT((--qtbug16115_trylock_counter) == 0); + mut.unlock(); + } + } + } + }; + QMutex mut; + TrylockThread t1(mut); + TrylockThread t2(mut); + TrylockThread t3(mut); + t1.start(); + t2.start(); + t3.start(); + + for (int i = 0; i < 1000000; ++i) { + mut.lock(); + Q_ASSERT((++qtbug16115_trylock_counter) == 1); + Q_ASSERT((--qtbug16115_trylock_counter) == 0); + mut.unlock(); + } + t1.wait(); + t2.wait(); + t3.wait(); +} + QTEST_MAIN(tst_QMutex) #include "tst_qmutex.moc" |