diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 2a75fb44d5..171e83a57a 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -57,6 +57,9 @@ if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS) endif() if(QT_BUILD_WASM_BATCHED_TESTS) + if(TARGET Qt::Concurrent) + add_subdirectory(corelib/io/qurl) + endif() add_subdirectory(corelib/io/qdiriterator) add_subdirectory(corelib/io/largefile) add_subdirectory(corelib/io/qdataurl) diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 81cd94e4ed..bd454fb695 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -4126,14 +4126,30 @@ void tst_QUrl::testThreadingHelper() void tst_QUrl::testThreading() { + enum { Count = 100 }; + if (QTestPrivate::isRunningArmOnX86()) QSKIP("This test fails in QEMU and looks like because of a data race, QTBUG-93176"); s_urlStorage = new UrlStorage; - QThreadPool::globalInstance()->setMaxThreadCount(100); - QFutureSynchronizer sync; - for (int i = 0; i < 100; ++i) - sync.addFuture(QtConcurrent::run(&tst_QUrl::testThreadingHelper, this)); - sync.waitForFinished(); + QThreadPool::globalInstance()->setMaxThreadCount(Count); + + // Written this way because wasm need the eventloop + QList> futures; + futures.reserve(Count); + + for (int i = 0; i < Count; ++i) + futures.push_back(QtConcurrent::run(&tst_QUrl::testThreadingHelper, this)); + + QEventLoop loop; + std::atomic remaining = Count; + for (int i = 0; i < Count; ++i) { + futures[i].then([&]() { + if (!--remaining) + loop.quit(); + }); + } + loop.exec(); + delete s_urlStorage; }