Commit Graph

38 Commits

Author SHA1 Message Date
Kai Köhne
04cc705947 CMake: Fix typos
Found by codespell

Pick-to: 6.4
Change-Id: I4907e423b6b345acf82f2d7e0ed62479719d694e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-13 15:37:36 +02:00
David Skoland
1a0eb4fa01 Adjust installing and running wasm-testrunner
Added a small helper function that also installs the script to
prefix builds. Additionally, leveraging the cmake option
CROSSCOMPILING_EMULATOR for the testrunner fits neatly in the rest
of our cmake code.

Change-Id: I75288e97c81b250ac3997f2e7a22bc7bd82b7b69
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-27 14:50:17 +02:00
David Skoland
b01ee1d44c Add WASM testrunner
Add a python script that allows us to run wasm tests in CI, along with
the necessary cmake logic to install the script and execute tests
accordingly.

Change-Id: I93b95c115538c4e27b2b833405acab8162be2a8a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-31 16:50:25 +02:00
Joerg Bornemann
02e5b0ffda CMake: Fix handling of the CROSSCOMPILING_EMULATOR property
CROSSCOMPILING_EMULATOR is a target property, not a test property.

Fixes: QTBUG-87864
Pick-to: 6.2 6.3
Change-Id: Icb07e9ed71a6bcbfceb7aa2116bf56eaa0a545c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-25 22:43:49 +01:00
Pasi Petäjäjärvi
5c85b0c7a4 CI: QNX qemu need docker service ports explicitly defined for visibility
Network autotests cannot connect to services on docker containers from
QNX qemu without all ports explicitly defined (both host and container)
side.

Pick-to: 6.2 6.3
Task-number: QTQAINFRA-4684
Change-Id: Iba44cfa17d42d43ecec3e29985e404f75d5fc232
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2022-03-21 22:30:01 +02:00
Fabian Kosmale
57c1e8d533 build system: support module local definitions
This introduces a new helper function,
qt_internal_add_repo_local_defines and makes use of it in
qt_internal_add_{module,test,executable,benchmark,plugin}. That function
checks whether QT_EXTRA_INTERNAL_TARGET_DEFINES is set. If it is, the
defines listed in there will be aded to all targets passed to the
functions mentioned above.

The intended usage is that QT_EXTRA_INTERNAL_TARGET_DEFINES gets set
in the repository local .cmake.conf. This allows e.g. opting in to
source incompatible changes in leaf modules (as long as those are
guarded by some define).

Pick-to: 6.2 6.3
Fixes: QTBUG-101640
Change-Id: I06c3693ee69f46e95a48de724621f0c97e7cc3a8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-11 20:32:08 +01:00
Alexey Edelev
fdf5d11ff6 CMake: Add BUILTIN_TESTDATA option to qt_internal_add_test
Multiple tests use qt_internal_add_resource that copies the
functionality that is already implemented inside the
qt_internal_add_test function. Simplify these test by replacing
the qt_internal_add_resource call with the new BUILTIN_TESTDATA
option.

Change-Id: I18475b817d6f87264f0de53817d6c26c5ccab4e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-11 21:54:44 +01:00
Alexey Edelev
3bee7db419 Fix the run of _check targets in multi-config builds
With Ninja Multi-Config generator it's necessary to provide the
'-C' option matching the build configuration when running
ctest. This patchset adds the missing option to the command line
of the '_check' targets.

Pick-to: 6.2 6.3
Change-Id: I42acfba26a09877a6d3a5be9230860f15f95a0cd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-09 15:33:45 +01:00
Alexey Edelev
fd3341a74e Add qt_internal_undefine_global_definition function
qt_internal_undefine_global_definition disables an internal global
definition that is defined by the qt_internal_add_global_definition
function for a specific target.

Remove the ability to set the custom "undefine" flag for the
definitions since it's hard to control it using the introduced
function.

Pick-to: 6.2 6.3
Task-number: QTBUG-100334
Change-Id: Ic1637d97aa51bbdd06c5b191c57a941aa208d4dc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-02 16:45:37 +01:00
Alexey Edelev
e2b98627a8 Use builtin test data on Integrity
Looks like Integrity doesn't deal well with external test data either.

Pick-to: 6.3
Change-Id: I8beb5ac4d2440d40a7efdceae973e430a2354e9d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-02 09:18:25 +01:00
Alexey Edelev
1d28fd7a9c Restore missing Qt definitions
Restore the 'QT_NO_JAVA_STYLE_ITERATORS' and
'QT_NO_NARROWING_CONVERSIONS_IN_CONNECT' definitions for Qt
targets.

Add the function that adds global definitions for Qt targets according
to the provided scope and the target property-based switch to disable
the definition for a specific target.

Pick-to: 6.2 6.3
Task-number: QTBUG-100295
Change-Id: I28697e81f9aabc45c48d79aae1e5caea141e04e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-31 17:40:43 +01:00
Yuhang Zhao
bdaab71c68 CMake: Remove WinRT leftovers from build system
Qt's WinRT support was removed long time ago.

Change-Id: I60b220e970072c3450e3793862d6f68801d2b5b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-18 08:01:39 +08:00
Alexandru Croitor
340b2a1a47 CMake: Fix exit code to be shown properly on test failure
The result variable was expanded at configure time rather than at
script execution time due to missing escaping.

A tidbit of information, the result variable can contain not only an
exit code, but a string as well.
For example on arm macOS with a crashed test it contains
'SIGTRAP'.

Curiously if the crashing executable is executed directly without
CMake, 'Trace/BPT trap: 5' is shown instead, perhaps because of
the shell.

Amends 3ef6af024b

Pick-to: 6.2 6.3
Change-Id: I50e57922abfc6eccde205c6252eebfda510bad41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 17:24:36 +01:00
Fabian Kosmale
3ef6af024b QtTestHelpers: print exit code upon failure
This might give a few insights into why the process has failed, at least
if distinct return values are used for different errors.

Change-Id: I61fe0ede812c4dda3d0cf0f2c96a479d198d340d
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-12-15 13:07:10 +01:00
Alexey Edelev
aba1432dae Add missing dependency of ${target}_check to ${target}_make_apk
When building for and running the '_check' target in Android we need
to make sure that target apk is assembled and ready for deployment.

Pick-to: 6.2
Change-Id: Ifc63aac230f0bb8375d319ec443174c5a436485e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-26 18:28:50 +01:00
Pasi Petäjäjärvi
c91b5dae9a QNX: Generate empty string for WORKING_DIRECTORY test wrapper
Tests for QNX are run in qemu over ssh and setting WORKING_DIRECTORY
will cause created test wrapper to try change specified directory
which will fail (expects local directory) when test is invoked over
ssh.

Task-number: QTBUG-87628
Pick-to: 6.2
Change-Id: If991002398811cc9cb9cbac54da5d2cb0d8c3589
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-27 13:30:01 +03:00
Tor Arne Vestbø
7c14223b1e testlib: Update a few remaining instances of the deprecated -xunitxml format
The format was renamed in 27db9e458c.

Pick-to: 6.2
Change-Id: I53975c7467d8768dc9dc9ac2d89c42eefa12e22f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-29 18:46:39 +02:00
Tor Arne Vestbø
f2d26f95fe cmake: Add repository name to test labels for qt5 builds
Change-Id: Icb23f2ea885f6d21bef80c587a431f7e9349f21b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-18 21:07:51 +02:00
Cristian Adam
0a1256a52d CMake: Allow usage of QtStandaloneTestTemplateProject as package component
Currently in order to compile a Qt6 test standalone one needs to use
the qt-cmake-standalone-test script which will load the
Qt6BuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt project
with the current test source directory to create a complete CMake project.

This commit will allow a test to have these lines at top:

cmake_minimum_required(VERSION 3.16)

if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
    project(a_qt_test LANGUAGES C CXX ASM)
    find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
endif()

and be standalone and work with any IDE capable of loading CMake projects.

Fixes: QTCREATORBUG-25389
Pick-to: 6.1
Change-Id: If3f878b7e560a8bfbb604a8f1aa30b7962742e66
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-23 13:31:04 +02:00
Alexey Edelev
70464b355e Specify QT_TESTCASE_BUILDDIR for Qt::Test users implicitly
QT_TESTCASE_BUILDDIR was implicitly defined by Qt::Test target for
library users in Qt5. By default, this definition will point to
CMAKE_CURRENT_BINARY_DIR. This logic works similarly to qmake logic.

From user's perspective it might be useful to not rely on standard
search paths, but specify own. This can be done by setting the
QT_TESTCASE_BUILDDIR property for the user's target. CMake will
substute the value of the QT_TESTCASE_BUILDDIR property into the
QT_TESTCASE_BUILDDIR definition.

The implicit QT_TESTCASE_SOURCEDIR also seems to be useful. According
to the current logic, it points to CMAKE_CURRENT_SOURCE_DIR.

Fixes: QTBUG-92079
Change-Id: I8a9065f08e859c713b3c8cc08142a9ced0677770
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-08 13:16:41 +02:00
Mårten Nordheim
1d6a35c536 CMake: Don't attempt to add to a target that doesn't exist
When configuring a benchmark using the standalone-test script the
'benchmark' target is not available, causing a configure error.

Pick-to: 6.1 6.0
Change-Id: I8e480c9e72b47783c0910428187f0092049e89db
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-03-17 16:28:37 +01:00
Tor Arne Vestbø
f66482a4ab cmake: Do not hard-code test arguments
Tests should follow their default output of txt as when run directly,
and any output configuration should be handled by the CI system.

Change-Id: Id0d72318df5edad1c58ac637e827d6043884e829
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
2021-02-15 13:38:56 +01:00
Assam Boudjelthia
85c7a9d3a6 CMake: add Qt::Gui dependency by default for Android tests
Normal Android apps require Qt::Gui dependency and since tests don't
need to handle any special cases for an app without Qt::Gui, let's add
it by default.

This also will allow us to remove some workarounds done on CI side to
run tests for Android.

Fixes: QTBUG-90870
Pick-to: 6.0 6.1
Change-Id: I845650c17a1b73e4c4977043f863ec44e50f06c3
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2021-02-11 10:09:17 +02:00
Alexey Edelev
7582f7b03d Fix warning in generated test wrappers
Since test command variable may contain quotes, there is a warning
in generated test wrappers related to 'message(FATAL_ERROR', that
should display full command in log in case of error. To avoid any
complicated quoting of command to only display it, join command into
single string in wrapper script and pass resulting variable to
'message(FATAL_ERROR'.

Pick-to: 6.0
Change-Id: Ie990fc0b0bf2c19b119c7c4e2aeec092e5200103
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-13 18:00:06 +01:00
Sona Kurazyan
3729d37dd9 Fix the CMake feature for docker-testserver to use correct mkspecs path
Use the QT_MKSPECS_DIR instead of QT_SOURCE_TREE to find out the
location for the testserver feature's data. QT_SOURCE_TREE points to
qtbase source location, which may not be always available. This allows
to use this feature by projects outside of qtbase.

Task-number: QTBUG-85034
Change-Id: If7fa6ef95777be9acf35d36f8d99776bf9568a79
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-12-23 10:56:16 +01:00
Sona Kurazyan
701536b218 Allow other projects to use the CMake feature for docker-based tests
Introduce a new QT_TESTSERVER_COMPOSE_FILE variable for setting a custom
docker compose file path, which can be set by projects outside of qtbase
(e.g. QtCoap). If the variable is not set, fallback to the compose file
located in qtbase.

Task-number: QTBUG-85034
Change-Id: I4c0c9b161cad9787b089ef7e9da2aa00352a9159
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-12-22 17:28:39 +01:00
Alexey Edelev
cb43c7176b CMake: Wrap benchmarks with cmake script
Wrap benchmark executable target with cmake script to run it on windows
without necessity of environment variables set.
Move common logic related to test and benchmark environment to
'qt_internal_collect_command_environment' function.

Make error message of wrapper script a bit more verbose.

Amends 61d5b01972

Task-number: QTBUG-89076
Pick-to: 6.0
Change-Id: I6ad3a027dc071176070cf3af4cf306f20d652039
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-12-10 19:51:39 +01:00
Alexey Edelev
d5bafc80cd CMake: Use test wrapper to run android tests
Refactor test adding procedure. It's expected that for each new
platform we prepare test executable and arguments first and then
pass them to common test adding section.

Rename '_qt_internal_wrap_test' to 'qt_internal_create_command_script'
Rework paramerters handling of 'qt_internal_create_command_script',
make them named.

Add 'qt_internal_create_test_script' to add tests and wrap them using
'qt_internal_create_command_script'.

Amends f19266bd02

Fixes: QTBUG-88053
Pick-to: 6.0
Change-Id: I812f4a295005bf3a85cdcb5b8c41180f8249dc96
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-10 17:15:40 +01:00
Alexey Edelev
c0ebfb81de CMake: Improve tests wrapper arguments handling
Use 'separate_arguments' to explicitly split arguments from environment
that form 'COMMAND' for execute_process. Enclose using bracket syntax
arguments, that propagated to wrapper script as pure strings.

Amends f19266bd02

Pick-to: 6.0
Change-Id: I858ddff7efa281f9cecfda656a02e1fd12361758
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-08 16:29:28 +01:00
Alexey Edelev
4a9ed41075 CMake: Force crosscompiling_emulator to empty string if not found
In some case CROSSCOMPILING_EMULATOR property is not INHERITED and is
set to 'NOTFOUND' by get_test_property. Force it to empty string in
this case.
Add missed 'name' argument to '_qt_internal_wrap_test'. 'name'
previously was used from parent scope.

Pick-to: 6.0
Fixes: QTBUG-88053
Change-Id: I5286bcb9b11659f638e178ce52172dfee994fc34
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-07 16:59:18 +00:00
Alexey Edelev
61d5b01972 CMake: Add extra targets to run single benchmark using CMake generator
Add custom targets with '_benchmark' suffixes to make run of
benchmarks using generators possible, e.g.:

$ ninja tst_bench_qudpsocket_benchmark

Extend '-[no]make' option to pass benchmark. Rework
'-[no]make' processing to unify these options processing.
Also looks like it doesn't make sense to enable benchmarks without
having test enabled. So '-DQT_BUILD_BENCHMARKS' enables test as own
dependency automatically.

Task-number: QTBUG-89076
Pick-to: 6.0
Change-Id: Ieee9eadaf6d75a1efec120242d6eb786ace1b071
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-07 14:26:07 +00:00
Alexey Edelev
f19266bd02 CMake: Add handling of TESTRUNNER and TESTARGS by Qt tests
Wrap Qt tests to handle TESTRUNNER and TESTARGS environment variables.
Variables are handled according to qmake build procedure. All test
now are wrapped by generated CMake script.

Fixes: QTBUG-88053
Pick-to: 6.0
Change-Id: I339977ce6ce11ddd38a4bf0bd26eb8f2ae463ba3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-04 21:42:53 +01:00
Mårten Nordheim
f97d4732d4 CMake: Enable exceptions by default
Without breaking currently generated CMakeLists

Fixes: QTBUG-88549
Change-Id: Ibda643e1374d9024bf693c12de8ec0ac46e09b7b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 15:47:51 +00:00
Alexandru Croitor
e57ccd45ca CMake: Rename some additional functions that should be internal
Amends e0c62a48b8

Task-number: QTBUG-86815
Change-Id: Ic65d8dda1aed390c78408616fb22f38edd2e1dce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-12 13:35:55 +02:00
Alexandru Croitor
b7f1915bd2 CMake: Fix leftover usage of qt_add_executable
All usages should be replaced with qt_internal_add_executable instead.
This should fix configuration failure of benchmarks and manual tests.

Amends e0c62a48b8

Task-number: QTBUG-86815
Change-Id: I0791d849998ed9517e32f699d843367949b97cb9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-07 16:52:12 +02:00
Alexandru Croitor
e0c62a48b8 CMake: Rename internal functions to contain qt_internal
Offer compatibility wrapper functions until we update all of the Qt
repos to use the new names.

Task-number: QTBUG-86815
Change-Id: I5826a4116f52a8509db32601ef7c200f9bd331de
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-09-23 16:59:05 +02:00
Cristian Adam
0aa4b33b92 CMake Build: Add qtnetwork docker testserver support
qt_add_test supports now QT_TEST_SERVER_LIST, which will add the test
servers as docker test fixtures.

The docker server will be started before the test is run, and stopped
after the test is run.

Running the tests in parallel is not supported.
Docker tests are currently only supported on Linux hosts.

Task-number: QTBUG-85034
Change-Id: If3cefe05c5dec19c14b05d2fa8b01a0b6d95e259
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-17 00:11:04 +00:00
Alexandru Croitor
44cce1a2ea CMake: Split QtBuild.cmake into smaller files
QtBuild.cmake is huge. Split it.

Move module, plugin, tools, executables and test related functions out
of QtBuild.cmake into separate files.
Do the same for many other things too.

An additional requirement is that all the new Helpers files only
define functions and macros.
No global variable definitions are allowed, nor execution of commands
with side effects.

Some notes:
qt_install_qml_files is removed because it's dead code.

Some functions still need to be figured out, because they are
interspersed and depend on various global state assignments.

Task-number: QTBUG-86035
Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-14 13:17:11 +02:00