wasm: Add qurl autotest

The testThreading test was deadlocking due to waiting for
threads to start. Rewritten the wait to use a QEventLoop

Change-Id: If1a864c054c1de1239694b201a4cf0e8186fc1d0
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
bb10
Even Oscar Andersen 2024-04-24 09:32:34 +02:00
parent 108caf0797
commit f9a994b86a
2 changed files with 24 additions and 5 deletions

View File

@ -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)

View File

@ -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<void> 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<QFuture<void>> futures;
futures.reserve(Count);
for (int i = 0; i < Count; ++i)
futures.push_back(QtConcurrent::run(&tst_QUrl::testThreadingHelper, this));
QEventLoop loop;
std::atomic<int> remaining = Count;
for (int i = 0; i < Count; ++i) {
futures[i].then([&]() {
if (!--remaining)
loop.quit();
});
}
loop.exec();
delete s_urlStorage;
}