diff --git a/android/common.sh b/android/common.sh index 1fee30bdc38..c7c508e2c90 100644 --- a/android/common.sh +++ b/android/common.sh @@ -10,6 +10,10 @@ if [ -z "$PYTORCH_DIR" ]; then exit 1 fi +retry () { + "$@" || (sleep 10 && "$@") || (sleep 20 && "$@") || (sleep 40 && "$@") +} + check_android_sdk() { if [ -z "$ANDROID_HOME" ]; then echo "ANDROID_HOME not set; please set it to Android sdk directory" diff --git a/android/run_tests.sh b/android/run_tests.sh index 839ee209c7b..c8c89776149 100755 --- a/android/run_tests.sh +++ b/android/run_tests.sh @@ -49,7 +49,8 @@ echo "Waiting for emulator boot completed" $ADB_PATH wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' { - $GRADLE_PATH -PABI_FILTERS=x86 -p $PYTORCH_ANDROID_DIR connectedAndroidTest + # The test currently takes about 10 minutes + retry $GRADLE_PATH -PABI_FILTERS=x86 -p $PYTORCH_ANDROID_DIR connectedAndroidTest } || { echo "::error::Check https://github.com/pytorch/pytorch/tree/master/test/mobile/model_test to see how to fix the failed mobile test" exit 1