From 2b308d4cb5cdf2f3374404c83dc0b193fcb78612 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 15 Nov 2012 18:16:30 +0100 Subject: Fix QMutex::tryLock timeout computation on Linux The timeout is in millisecond. So we just need to divide by 1000 to get the number of seconds Regression introduced in f587e8f4fd670f11fa1e878c1015d7241033559a Reported in the comments of QTBUG-24795 Change-Id: Id16e05e7d04d33605860926f7516d14cdefd6a36 Reviewed-by: Thiago Macieira --- tests/auto/corelib/thread/qmutex/tst_qmutex.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 3c199b7fc3..7e3e720739 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -132,6 +132,14 @@ void tst_QMutex::tryLock() normalMutex.unlock(); testsTurn.release(); + // TEST 7 overflow: thread can acquire lock, timeout = 3000 (QTBUG-24795) + threadsTurn.acquire(); + timer.start(); + QVERIFY(normalMutex.tryLock(3000)); + QVERIFY(timer.elapsed() < 3000); + normalMutex.unlock(); + testsTurn.release(); + threadsTurn.acquire(); } }; @@ -175,6 +183,13 @@ void tst_QMutex::tryLock() normalMutex.unlock(); threadsTurn.release(); + // TEST 7: thread can acquire lock, timeout = 3000 (QTBUG-24795) + testsTurn.acquire(); + normalMutex.lock(); + threadsTurn.release(); + QThread::msleep(100); + normalMutex.unlock(); + // wait for thread to finish testsTurn.acquire(); threadsTurn.release(); -- cgit v1.2.3