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>
This commit is contained in:
parent
0d5fe9c3d7
commit
d2c29aee41
@ -185,7 +185,7 @@ define_property(TARGET
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Returns test execution arguments for Android targets
|
# Returns test execution arguments for Android targets
|
||||||
function(qt_internal_android_test_arguments target out_test_runner out_test_arguments)
|
function(qt_internal_android_test_arguments target timeout out_test_runner out_test_arguments)
|
||||||
set(${out_test_runner} "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androidtestrunner" PARENT_SCOPE)
|
set(${out_test_runner} "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androidtestrunner" PARENT_SCOPE)
|
||||||
set(deployment_tool "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androiddeployqt")
|
set(deployment_tool "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androiddeployqt")
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ function(qt_internal_android_test_arguments target out_test_runner out_test_argu
|
|||||||
"--skip-install-root"
|
"--skip-install-root"
|
||||||
"--make" "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target}_make_apk"
|
"--make" "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target}_make_apk"
|
||||||
"--apk" "${apk_dir}/${target}.apk"
|
"--apk" "${apk_dir}/${target}.apk"
|
||||||
"--timeout" "-1"
|
"--timeout" "${timeout}"
|
||||||
"--verbose"
|
"--verbose"
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
@ -606,6 +606,11 @@ function(qt_internal_add_test name)
|
|||||||
endif()
|
endif()
|
||||||
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 (ANDROID)
|
||||||
if(arg_BUNDLE_ANDROID_OPENSSL_LIBS)
|
if(arg_BUNDLE_ANDROID_OPENSSL_LIBS)
|
||||||
if(EXISTS "${OPENSSL_ROOT_DIR}/${CMAKE_ANDROID_ARCH_ABI}/libcrypto_3.so")
|
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.")
|
"This is fine if OpenSSL was built statically.")
|
||||||
endif()
|
endif()
|
||||||
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}")
|
set(test_working_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
elseif(QNX)
|
elseif(QNX)
|
||||||
set(test_working_dir "")
|
set(test_working_dir "")
|
||||||
@ -842,6 +848,30 @@ function(qt_internal_add_test name)
|
|||||||
qt_internal_add_test_finalizers("${name}")
|
qt_internal_add_test_finalizers("${name}")
|
||||||
endfunction()
|
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
|
# This function adds test with specified NAME and wraps given test COMMAND with standalone cmake
|
||||||
# script.
|
# script.
|
||||||
#
|
#
|
||||||
|
@ -118,7 +118,7 @@ struct Options
|
|||||||
bool helpRequested = false;
|
bool helpRequested = false;
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool skipAddInstallRoot = false;
|
bool skipAddInstallRoot = false;
|
||||||
int timeoutSecs = 480; // 8 minutes
|
int timeoutSecs = 600; // 10 minutes
|
||||||
QString buildPath;
|
QString buildPath;
|
||||||
QString adbCommand{QStringLiteral("adb")};
|
QString adbCommand{QStringLiteral("adb")};
|
||||||
QString makeCommand;
|
QString makeCommand;
|
||||||
@ -270,7 +270,7 @@ static void printHelp()
|
|||||||
" --activity <acitvity>: The Activity to run. If missing the first\n"
|
" --activity <acitvity>: The Activity to run. If missing the first\n"
|
||||||
" activity from AndroidManifest.qml file will be used.\n"
|
" activity from AndroidManifest.qml file will be used.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --timeout <seconds>: Timeout to run the test. Default is 5 minutes.\n"
|
" --timeout <seconds>: Timeout to run the test. Default is 10 minutes.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --skip-install-root: Do not append INSTALL_ROOT=... to the make command.\n"
|
" --skip-install-root: Do not append INSTALL_ROOT=... to the make command.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user