summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-07-05 17:37:58 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2021-07-12 15:54:41 +0200
commit42f2a9c5ce8b28186960499ad92754c40aa04ac5 (patch)
treeaa13ae1b5b64e07f3d5d7481d5e188d52adbe2c4 /tests/auto/concurrent
parente17a776157c52aa2027036b258956903b76a675e (diff)
tst_QtConcurrentThreadEngine: fix the threadCount() test
Enable the check, that has been disabled because of instability, which makes the test-case useless. The reason for instability probably was that it doesn't always start maxThreadCount number of threads: it could be less if the workers reuse the thread pool's already created threads (if possible) instead of creating new one each time. But we can at least make sure, that we're not starting more threads than expected. Task-number: QTBUG-94463 Pick-to: 5.15 6.1 6.2 Change-Id: I8e498c377d86c49758bde0114fe6f7e0432fe993 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Diffstat (limited to 'tests/auto/concurrent')
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
index 85f83c61f7..12a7aa4bf0 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
@@ -255,25 +255,21 @@ public:
void tst_QtConcurrentThreadEngine::threadCount()
{
- //QTBUG-23333: This test is unstable
-
const int repeats = 10;
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser())->startAsynchronously().waitForFinished();
const auto count = threads.count();
- const auto count_expected = QThreadPool::globalInstance()->maxThreadCount();
- if (count != count_expected)
- QEXPECT_FAIL("", "QTBUG-23333", Abort);
- QCOMPARE(count, count_expected);
+ const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+ QVERIFY(count <= maxThreadCount);
+ QVERIFY(!threads.contains(QThread::currentThread()));
}
// Set the finish flag immediately, this should give us one thread only.
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
const auto count = threads.count();
- if (count != 1)
- QEXPECT_FAIL("", "QTBUG-23333", Abort);
QCOMPARE(count, 1);
+ QVERIFY(!threads.contains(QThread::currentThread()));
}
}