CI: Enable some tests under corelib/thread for Wasm platform

This is part of our testing effort where we try enabling more tests for
Web Assembly platform on CI. Not all tests work out of box, so some of
them will require followup work.
This commmit also introduces a new mechanism of automatically renaming
files when they are added many times with the same filename to single
translation unit.

Change-Id: I620536494ea83aeb9b294c4a35ef72b51e85a38b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Piotr Wierciński 2023-09-07 15:13:01 +02:00
parent 5ac97a38e8
commit 9468ef2cfb
5 changed files with 52 additions and 12 deletions

View File

@ -315,6 +315,34 @@ function(qt_internal_add_test_to_batch batch_name name)
list(PREPEND batched_test_list ${name})
set_property(GLOBAL PROPERTY _qt_batched_test_list_property ${batched_test_list})
# Test batching produces single executable which can result in one source file being added
# multiple times (with different definitions) to one translation unit. This is not supported by
# CMake so instead we try to detect such situation and rename file every time it's added
# to the build more than once. This avoids filenames collisions in one translation unit.
get_property(batched_test_sources_list GLOBAL PROPERTY _qt_batched_test_sources_list_property)
if(NOT batched_test_sources_list)
set_property(GLOBAL PROPERTY _qt_batched_test_sources_list_property "")
set(batched_test_sources_list "")
endif()
foreach(source ${arg_SOURCES})
set(source_path ${source})
if(${source} IN_LIST batched_test_sources_list)
set(new_filename ${name}.cpp)
configure_file(${source} ${new_filename})
set(source_path ${CMAKE_CURRENT_BINARY_DIR}/${new_filename})
set(skip_automoc ON)
list(APPEND arg_SOURCES ${source_path})
else()
set(skip_automoc OFF)
list(APPEND batched_test_sources_list ${source})
endif()
set_source_files_properties(${source_path}
TARGET_DIRECTORY ${target} PROPERTIES
SKIP_AUTOMOC ${skip_automoc}
COMPILE_DEFINITIONS "BATCHED_TEST_NAME=\"${name}\";${arg_DEFINES}")
endforeach()
set_property(GLOBAL PROPERTY _qt_batched_test_sources_list_property ${batched_test_sources_list})
# Merge the current test with the rest of the batch
qt_internal_extend_target(${target}
INCLUDE_DIRECTORIES ${arg_INCLUDE_DIRECTORIES}
@ -330,15 +358,6 @@ function(qt_internal_add_test_to_batch batch_name name)
NO_UNITY_BUILD # Tests should not be built using UNITY_BUILD
)
foreach(source ${arg_SOURCES})
# We define the test name which is later used to launch this test using
# commandline parameters. Target directory is that of the target test_batch,
# otherwise the batch won't honor our choices of compile definitions.
set_source_files_properties(${source}
TARGET_DIRECTORY ${target}
PROPERTIES COMPILE_DEFINITIONS
"BATCHED_TEST_NAME=\"${name}\";${arg_DEFINES}" )
endforeach()
set(${batch_name} ${target} PARENT_SCOPE)
# Add a dummy target so that new tests don't have problems with a nonexistent
@ -616,7 +635,7 @@ function(qt_internal_add_test name)
# TODO: Add functionality to specify browser
list(APPEND extra_test_args "--browser=chrome")
list(APPEND extra_test_args "--browser_args=\"--password-store=basic\"")
list(APPEND extra_test_args "--kill_exit")
#list(APPEND extra_test_args "--kill_exit")
# Tests may require asyncify if they use exec(). Enable asyncify for
# batched tests since this is the configuration used on the CI system.

View File

@ -60,6 +60,7 @@ if(WASM)
add_subdirectory(corelib/io/qsettings)
add_subdirectory(corelib/serialization)
add_subdirectory(corelib/text)
add_subdirectory(corelib/thread)
add_subdirectory(wasm)
return()
endif()

View File

@ -1,6 +1,19 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(WASM) # not all tests currently work in WebAssembly
add_subdirectory(qatomicint)
add_subdirectory(qatomicinteger)
add_subdirectory(qatomicpointer)
add_subdirectory(qfuturesynchronizer)
add_subdirectory(qfuturewatcher)
add_subdirectory(qmutexlocker)
add_subdirectory(qreadlocker)
add_subdirectory(qresultstore)
add_subdirectory(qwritelocker)
return()
endif()
if(QT_FEATURE_thread)
add_subdirectory(qatomicint)
add_subdirectory(qatomicinteger)

View File

@ -75,6 +75,8 @@ template <> struct LargeIntTemplate<true> { typedef quint64 Type; };
template <> struct LargeIntTemplate<false> { typedef qint64 Type; };
typedef LargeIntTemplate<TypeIsUnsigned>::Type LargeInt;
namespace {
class tst_QAtomicIntegerXX : public QObject
{
Q_OBJECT
@ -672,8 +674,9 @@ void tst_QAtomicIntegerXX::fetchAndXor()
QCOMPARE(atomic ^= minusOne, T(~value));
QCOMPARE(atomic ^= minusOne, T(value));
}
#include "tst_qatomicinteger.moc"
}
QTEST_APPLESS_MAIN(tst_QAtomicIntegerXX)
#include "tst_qatomicinteger.moc"

View File

@ -574,10 +574,14 @@ static inline void testCancelWhenDestroyedWithFailureHandler()
void tst_QPromise::cancelWhenDestroyedWithFailureHandler()
{
#ifndef QT_NO_EXCEPTIONS
testCancelWhenDestroyedWithFailureHandler<void>();
testCancelWhenDestroyedWithFailureHandler<int>();
testCancelWhenDestroyedWithFailureHandler<CopyOnlyType>();
testCancelWhenDestroyedWithFailureHandler<MoveOnlyType>();
#else
QSKIP("Exceptions are disabled, skipping the test");
#endif
}
template <typename T>