Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to make the usage of the Android emulator in CIs more robust #17903

Merged
merged 9 commits into from
Oct 14, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ jobs:
--build_dir build_qnn \
--android_sdk_path $ANDROID_HOME \
--android_ndk_path $ANDROID_NDK_HOME \
--android_abi=arm64-v8a \
--android_api=30 \
--android_abi=x86_64 \
--android_api=31 \
--parallel \
--use_qnn \
--qnn_home $(QNN_SDK_ROOT) \
Expand All @@ -85,48 +85,36 @@ jobs:

- script: |
mkdir -p build_qnn/Release/testdata/QNN/node_tests
cp -r cmake/external/onnx//onnx/backend/test/data/node/test_basic_conv_with_padding build_qnn/Release/testdata/QNN/node_tests
cp -r cmake/external/onnx/onnx/backend/test/data/node/test_basic_conv_with_padding build_qnn/Release/testdata/QNN/node_tests
displayName: Initialize test directories

- task: JavaToolInstaller@0
displayName: Use jdk 8
displayName: Use jdk 11
inputs:
versionSpec: '8'
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--create-avd --system-image "system-images;android-30;google_apis;arm64-v8a" \
--start --emulator-extra-args="-partition-size 4096" \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Start Android emulator
enabled: false
continueOnError: true
# This is commented out for now. The emulator runs correctly, onnx_test_runner is executable, and the test passes
# with the CPU EP but returns 139 when attempting to use the QNN EP. Maybe some QNN EP parameters need to be provided?
#
# - template: templates/use-android-emulator.yml
# parameters:
# create: true
# start: true

- script: |
$ANDROID_SDK_ROOT/emulator/emulator -list-avds
displayName: List emulators
# - task: CmdLine@2
# inputs:
# script: |
# set -e -x
# ${ANDROID_SDK_ROOT}/platform-tools/adb push onnx_test_runner /data/local/tmp/
# ${ANDROID_SDK_ROOT}/platform-tools/adb push testdata/QNN/node_tests/test_basic_conv_with_padding /data/local/tmp/
# ${ANDROID_SDK_ROOT}/platform-tools/adb shell "chmod +x /data/local/tmp/onnx_test_runner"
# ${ANDROID_SDK_ROOT}/platform-tools/adb shell "/data/local/tmp/onnx_test_runner -v /data/local/tmp/test_basic_conv_with_padding"
# ${ANDROID_SDK_ROOT}/platform-tools/adb shell "/data/local/tmp/onnx_test_runner -v -e qnn /data/local/tmp/test_basic_conv_with_padding"
# workingDirectory: build_qnn/Release
# displayName: Run test_basic_conv_with_padding on emulator

- task: CmdLine@2
inputs:
script: |
${ANDROID_SDK_ROOT}/platform-tools/adb shell "mkdir /data/local/tmp/qnn"
${ANDROID_SDK_ROOT}/platform-tools/adb push onnx_test_runner /data/local/tmp/qnn
${ANDROID_SDK_ROOT}/platform-tools/adb push testdata/QNN/node_tests/test_basic_conv_with_padding /data/local/tmp/qnn
${ANDROID_SDK_ROOT}/platform-tools/adb shell "/data/local/tmp/qnn/onnx_test_runner -e qnn /data/local/tmp/qnn/test_basic_conv_with_padding"
workingDirectory: build_qnn/Release
displayName: Run tests
enabled: false
continueOnError: true

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--stop \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Stop Android emulator
condition: always()
enabled: false
continueOnError: true
# - template: templates/use-android-emulator.yml
# parameters:
# stop: true
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,10 @@ stages:

- template: "templates/use-android-ndk.yml"

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--create-avd --system-image "system-images;android-31;default;x86_64" \
--start --emulator-extra-args="-partition-size 4096" \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Start Android emulator
- template: templates/use-android-emulator.yml
parameters:
create: true
start: true

- script: |
python3 tools/ci_build/build.py \
Expand All @@ -277,13 +274,9 @@ stages:
--test
displayName: CPU EP, Test on Android Emulator

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--stop \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Stop Android emulator
condition: always()
- template: templates/use-android-emulator.yml
parameters:
stop: true

- template: templates/clean-agent-build-directory-step.yml

Expand Down Expand Up @@ -329,13 +322,10 @@ stages:

- template: "templates/use-android-ndk.yml"

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--create-avd --system-image "system-images;android-31;default;x86_64" \
--start --emulator-extra-args="-partition-size 4096" \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Start Android emulator
- template: templates/use-android-emulator.yml
parameters:
create: true
start: true

- script: |
python3 tools/ci_build/build.py \
Expand All @@ -358,13 +348,10 @@ stages:
# Build Minimal ORT with NNAPI and reduced Ops, run unit tests on Android Emulator
displayName: Build Minimal ORT with NNAPI and run tests

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--stop \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Stop Android emulator
condition: always()
- template: templates/use-android-emulator.yml
parameters:
stop: true

- template: templates/clean-agent-build-directory-step.yml

- stage: MASTER_BUILD_STAGE
Expand Down Expand Up @@ -415,13 +402,10 @@ stages:
$(Build.SourcesDirectory)/protobuf_install
displayName: Build Host Protoc

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--create-avd --system-image "system-images;android-31;default;x86_64" \
--start --emulator-extra-args="-partition-size 4096" \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Start Android emulator
- template: templates/use-android-emulator.yml
parameters:
create: true
start: true

- script: |
python3 tools/ci_build/build.py \
Expand Down Expand Up @@ -460,13 +444,10 @@ stages:
# Build Minimal ORT with NNAPI and reduced Ops, run unit tests on Android Emulator
displayName: Build Minimal ORT with NNAPI and run tests

- script: |
python3 tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--stop \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Stop Android emulator
condition: always()
- template: templates/use-android-emulator.yml
parameters:
stop: true

- template: templates/clean-agent-build-directory-step.yml

- job: Update_Dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ jobs:

- template: install-appcenter.yml

- script: |
python3 $(Build.SourcesDirectory)/tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--create-avd --system-image "system-images;android-31;default;x86_64" \
--start --emulator-extra-args="-partition-size 4096" \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Start Android emulator
- template: use-android-emulator.yml
parameters:
create: true
start: true

- script: |
set -e -x
Expand All @@ -70,6 +67,10 @@ jobs:
displayName: Run E2E test using Emulator
workingDirectory: $(Build.BinariesDirectory)

- template: use-android-emulator.yml
parameters:
stop: true

- script: |
set -e -x
cd android_test/android
Expand All @@ -84,14 +85,6 @@ jobs:
displayName: Run E2E tests using App Center
workingDirectory: $(Build.BinariesDirectory)

- script: |
python3 $(Build.SourcesDirectory)/tools/python/run_android_emulator.py \
--android-sdk-root ${ANDROID_SDK_ROOT} \
--stop \
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
displayName: Stop Android emulator
condition: always()

- template: component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'
Expand Down
Loading
Loading