summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-06-12 14:52:23 +0200
committerMarc Mutz <[email protected]>2025-06-16 17:55:24 +0200
commit39af5f1794aaa3120c75d10efdf35df3a84a0dea (patch)
tree20f2df7fdbf44fa6898565683b7f49f87a4820ff /tests
parent30a94c63eef1b6f629a048ea8f4cc91e211c4587 (diff)
tst_QPointer: ensure we reap all threads in raceCondition()
The old code would return from the test function upon the first wait() failure. It should, however, reap (join) all the following threads, too, or fail trying. So drag the QVERIFY out of the loop, ensuring that all threads got wait()ed upon. This can, in theory, wait for 20*30s = 10min now, but the test function will be killed by the watchdog after 300s = 5min, and that at least doesn't leave unreaped threads around, so is still preferable. As a half-way drive-by, port to chrono timeouts. Amends 253f34082f526ff1ffd9eaefac73cc9aa616ab2a. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Icdd36549ecf15fc77b97774aa2ef5b9384a2c67b Reviewed-by: David Faure <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index 8b6939483a6..309aa13e18d 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -14,6 +14,8 @@
#include <QWidget>
#endif
+using namespace std::chrono_literals;
+
class tst_QPointer : public QObject
{
Q_OBJECT
@@ -558,12 +560,14 @@ void tst_QPointer::raceCondition()
thread->start();
}
- QTest::qWait(100);
+ QTest::qWait(100ms);
startSemaphore.release(NUM_THREADS);
+ bool allJoined = true;
for (const auto &thread : threads) {
- QVERIFY(thread->wait(30000));
+ allJoined = thread->wait(30s) && allJoined;
}
+ QVERIFY(allJoined);
}
void tst_QPointer::qvariantCast()