diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-11-28 12:25:44 +0100 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2023-11-30 17:26:26 +0200 |
commit | d2c29aee41d06d59024ef72eb50bb9f25909e922 (patch) | |
tree | 634eb872013626d27fefd4d23559f3beb5985a76 /cmake/QtTestHelpers.cmake | |
parent | 0d5fe9c3d7a1af873e800453306b1a5116812966 (diff) |
CMake: Compute dynamic timeout for androidtestrunner
Pass a CMake test TIMEOUT argument to androidtestrunner, using
a value of 95% of that timeout to allow time for the test runner
to do any cleanup before being killed.
If no test argument is provided, use the value from CMake property
DART_TESTING_TIMEOUT or CTEST_TEST_TIMEOUT. If that's not provided
default to 25 minutes which is the default for DART_TESTING_TIMEOUT.
Along the way set the default androidtestrunner timeout to 10 minutes
and fix the wrong timeout in the help menu.
Fixes: QTBUG-106479
Pick-to: 6.6 6.5
Change-Id: I12cd531583dd94954caf8044c37c22382d53d43c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'cmake/QtTestHelpers.cmake')
-rw-r--r-- | cmake/QtTestHelpers.cmake | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index 991c38bc57..7ac7058131 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -606,6 +606,11 @@ function(qt_internal_add_test name) endif() endif() + # Pass 95% of the timeout to allow the test runner time to do any cleanup + # before being killed. + set(percentage "95") + qt_internal_get_android_test_timeout("${arg_TIMEOUT}" "${percentage}" android_timeout) + if (ANDROID) if(arg_BUNDLE_ANDROID_OPENSSL_LIBS) if(EXISTS "${OPENSSL_ROOT_DIR}/${CMAKE_ANDROID_ARCH_ABI}/libcrypto_3.so") @@ -637,7 +642,8 @@ function(qt_internal_add_test name) "This is fine if OpenSSL was built statically.") endif() endif() - qt_internal_android_test_arguments("${name}" test_executable extra_test_args) + qt_internal_android_test_arguments( + "${name}" "${android_timeout}" test_executable extra_test_args) set(test_working_dir "${CMAKE_CURRENT_BINARY_DIR}") elseif(QNX) set(test_working_dir "") @@ -842,6 +848,30 @@ function(qt_internal_add_test name) qt_internal_add_test_finalizers("${name}") endfunction() +# Given an optional test timeout value (specified via qt_internal_add_test's TIMEOUT option) +# returns a percentage of the final timeout to be passed to the androidtestrunner executable. +# +# When the optional timeout is empty, default to cmake's defaults for getting the timeout. +function(qt_internal_get_android_test_timeout input_timeout percentage output_timeout_var) + set(actual_timeout "${input_timeout}") + if(NOT actual_timeout) + # Related: https://gitlab.kitware.com/cmake/cmake/-/issues/20450 + if(DART_TESTING_TIMEOUT) + set(actual_timeout "${DART_TESTING_TIMEOUT}") + elseif(CTEST_TEST_TIMEOUT) + set(actual_timeout "${CTEST_TEST_TIMEOUT}") + else() + # Default DART_TESTING_TIMEOUT is 25 minutes, specified in seconds + # https://github.com/Kitware/CMake/blob/master/Modules/CTest.cmake#L167C16-L167C16 + set(actual_timeout "1500") + endif() + endif() + + math(EXPR calculated_timeout "${actual_timeout} * ${percentage} / 100") + + set(${output_timeout_var} "${calculated_timeout}" PARENT_SCOPE) +endfunction() + # This function adds test with specified NAME and wraps given test COMMAND with standalone cmake # script. # |