diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-07-05 17:37:58 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-13 10:54:31 +0000 |
commit | d95809470c3a2e3d57d43b6439515d12427f6de1 (patch) | |
tree | 9a35b340f4abb2893e08ab1c3246ca5cce7c4c6a /tests | |
parent | 63a670f5d3f689ad69467798bc1b49ad60d03b64 (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
Change-Id: I8e498c377d86c49758bde0114fe6f7e0432fe993
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
(cherry picked from commit 42f2a9c5ce8b28186960499ad92754c40aa04ac5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp | 12 |
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())); } } |