xref: /aosp_15_r20/external/executorch/build/run_android_emulator.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1#!/bin/bash
2# Copyright (c) Meta Platforms, Inc. and affiliates.
3# All rights reserved.
4#
5# This source code is licensed under the BSD-style license found in the
6# LICENSE file in the root directory of this source tree.
7
8set -ex
9
10# This script is originally adopted from https://github.com/pytorch/pytorch/blob/main/android/run_tests.sh
11ADB_PATH=$ANDROID_HOME/platform-tools/adb
12
13echo "Waiting for emulator boot to complete"
14# shellcheck disable=SC2016
15$ADB_PATH wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 5; done;'
16
17# The device will be created by ReactiveCircus/android-emulator-runner GHA
18echo "List all running emulators"
19$ADB_PATH devices
20
21adb install -t app-debug.apk
22adb install -t app-debug-androidTest.apk
23
24adb shell mkdir -p /data/local/tmp/llama
25adb push model.pte /data/local/tmp/llama
26adb push tokenizer.bin /data/local/tmp/llama
27adb shell am instrument -w -r com.example.executorchllamademo.test/androidx.test.runner.AndroidJUnitRunner
28
29adb install -t android-test-debug.apk
30adb install -t android-test-debug-androidTest.apk
31
32adb shell am instrument -w -r org.pytorch.executorch.test/androidx.test.runner.AndroidJUnitRunner
33