diff --git a/cmake/QtWrapperScriptHelpers.cmake b/cmake/QtWrapperScriptHelpers.cmake index e87d0ad2e5..a71dee74ff 100644 --- a/cmake/QtWrapperScriptHelpers.cmake +++ b/cmake/QtWrapperScriptHelpers.cmake @@ -208,7 +208,6 @@ function(qt_internal_create_wrapper_scripts) DESTINATION "${INSTALL_LIBEXECDIR}") qt_internal_create_qt_configure_tests_wrapper_script() - qt_internal_install_android_helper_scripts() endfunction() function(qt_internal_create_qt_configure_tests_wrapper_script) @@ -256,9 +255,3 @@ function(qt_internal_create_qt_configure_tests_wrapper_script) DESTINATION "${INSTALL_BINDIR}") endif() endfunction() - -function(qt_internal_install_android_helper_scripts) - qt_path_join(destination "${QT_INSTALL_DIR}" "${INSTALL_LIBEXECDIR}") - qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/util/android/android_emulator_launcher.sh" - DESTINATION "${destination}") -endfunction() diff --git a/coin/instructions/cmake_run_ctest_enforce_exit_code.yaml b/coin/instructions/cmake_run_ctest_enforce_exit_code.yaml index 8a381992fd..e3017a4005 100644 --- a/coin/instructions/cmake_run_ctest_enforce_exit_code.yaml +++ b/coin/instructions/cmake_run_ctest_enforce_exit_code.yaml @@ -61,6 +61,7 @@ instructions: condition: property property: features contains_value: AbortTestingOnFirstFailure + - !include "{{qt/qtbase}}/coin_module_test_android_start_emulator.yaml" - type: ExecuteCommand command: "{{.Env.TESTS_ENV_PREFIX}} ctest {{.Env.CTEST_ARGS}}" executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution diff --git a/coin/instructions/coin_module_test_android_start_emulator.yaml b/coin/instructions/coin_module_test_android_start_emulator.yaml index 105b3f1038..eff28ff494 100644 --- a/coin/instructions/coin_module_test_android_start_emulator.yaml +++ b/coin/instructions/coin_module_test_android_start_emulator.yaml @@ -3,10 +3,10 @@ instructions: - type: Group instructions: - type: ExecuteCommand - command: "{{.Env.LIBEXEC_INSTALL_DIR}}/android_emulator_launcher.sh" + command: "{{.Env.ANDROID_EMULATOR_RUNNER}}" maxTimeInSeconds: 600 maxTimeBetweenOutput: 300 - userMessageOnFailure: "Failed to start emulator, check coin log and ~/emulator.log" + userMessageOnFailure: "Failed to start emulator, check coin log and testresults log files." enable_if: condition: property property: features diff --git a/coin/instructions/coin_module_test_template_common.yaml b/coin/instructions/coin_module_test_template_common.yaml index 16fac8dd5d..19c51e23c6 100644 --- a/coin/instructions/coin_module_test_template_common.yaml +++ b/coin/instructions/coin_module_test_template_common.yaml @@ -2,7 +2,6 @@ type: Group instructions: # The build env is needed on MSVC so that tst_qmake can properly build apps / libraries. - !include "{{qt/qtbase}}/prepare_building_env.yaml" - - !include "{{qt/qtbase}}/coin_module_test_android_start_emulator.yaml" - !include "{{qt/qtbase}}/coin_module_test_qnx_start_emulator.yaml" # The test env vars are needed to pick the proper prefix.bat file. - !include "{{qt/qtbase}}/cmake_setup_running_tests_env_vars.yaml" diff --git a/util/android/android_emulator_launcher.sh b/util/android/android_emulator_launcher.sh deleted file mode 100755 index fb58e86bef..0000000000 --- a/util/android/android_emulator_launcher.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# Copyright (C) 2021 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -# This util launches the Android emulator and ensures it doesn't stuck/freeze -# by detecting that and restarting it - -set -e - - -EMULATOR_MAX_RETRIES=5 -EMULATOR_EXEC="$ANDROID_SDK_ROOT/emulator/emulator" -ADB_EXEC="$ANDROID_SDK_ROOT/platform-tools/adb" -if [ -z "${ANDROID_EMULATOR}" ] -then - EMULATOR_NAME="@emulator_x86_api_23" -else - EMULATOR_NAME="$ANDROID_EMULATOR" -fi - - -function check_for_android_device -{ - $ADB_EXEC devices \ - | awk 'NR==2{print $2}' | grep -qE '^(online|device)$' -} - -# WARNING: On the very first boot of the emulator it happens that the device -# "finishes" booting and getprop shows bootanim=stopped and -# boot_completed=1. But sometimes not all packages have been installed (`pm -# list packages` shows only 16 packages installed), and after around half a -# minute the boot animation starts spinning (bootanim=running) again despite -# boot_completed=1 all the time. After some minutes the boot animation stops -# again and the list of packages contains 80 packages. Only then the device is -# fully booted, and only then is dev.bootcomplete=1. -# -# To reproduce the emulator booting as the first time, you have to delete the -# cached images found inside $HOME/.android especially the -# "userdata-qemu.img.qcow2" file. -function check_if_fully_booted -{ - # The "getprop" command separates lines with \r\n so we trim them - bootanim=` $ADB_EXEC shell getprop init.svc.bootanim | tr -d '\r\n'` - boot_completed=`$ADB_EXEC shell getprop sys.boot_completed | tr -d '\r\n'` - bootcomplete=` $ADB_EXEC shell getprop dev.bootcomplete | tr -d '\r\n'` - echo "bootanim=$bootanim boot_completed=$boot_completed bootcomplete=$bootcomplete" - [ "$bootanim" = stopped ] && [ "$boot_completed" = 1 ] && [ "$bootcomplete" = 1 ] -} - - - -for counter in `seq ${EMULATOR_MAX_RETRIES}` -do - $ADB_EXEC start-server - - if check_for_android_device - then - echo "Emulator is already running but it shouldn't be. Aborting\!" - exit 3 - fi - - echo "Starting emulator, try ${counter}/${EMULATOR_MAX_RETRIES}" - $EMULATOR_EXEC $EMULATOR_NAME \ - -gpu swiftshader_indirect -no-audio -partition-size 4096 \ - -cores 4 -memory 16000 -no-snapshot-load -no-snapshot-save \ - $HOME/emulator.log 2>&1 & - emulator_pid=$! - disown $emulator_pid - - echo "Waiting for emulated device to appear..." - $ADB_EXEC wait-for-device - - echo "Waiting a few minutes for the emulator to fully boot..." - emulator_status=down - for i in `seq 300` - do - sleep 1 - - if check_for_android_device && check_if_fully_booted - then - emulator_status=up - break - fi - done - - # If emulator status is still offline after timeout period, - # we can assume it's stuck, and we must restart it - if [ $emulator_status = up ] - then - echo "Emulator started successfully" - break - else - if [ $counter -lt $EMULATOR_MAX_RETRIES ] - then - echo "Emulator failed to start, forcefully killing current instance and re-starting emulator" - kill $emulator_pid || true - sleep 5 - elif [ $counter -eq $EMULATOR_MAX_RETRIES ] - then - echo "Emulator failed to start, reached maximum number of retries. Aborting\!" - exit 2 - fi - fi -done - - -exit 0