Last active
August 24, 2018 08:23
-
-
Save blazsolar/5ab8f89bb4a8ace692395446789943fd to your computer and use it in GitHub Desktop.
Handling CI emulators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set device [lindex $argv 0] | |
set token [lindex $argv 1] | |
spawn telnet localhost $device | |
expect "OK" | |
send "auth $token\n" | |
expect "OK" | |
send "kill\n" | |
interact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir="$(cd "$(dirname "$0")" && pwd)" | |
token=$(head -n 1 ~/.emulator_console_auth_token) | |
for device in `adb devices -l | tail -n +2 | cut -d" " -f 1 | cut -d"-" -f 2`; do | |
echo "Killing $device" | |
expect $dir/kill-emulators.expect $device $token | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Start emulator" | |
emulator -avd $1 -no-window -no-audio -wipe-data -no-boot-anim -qemu -m 1024 -smp 4 & | |
emaulatorPid=$! | |
echo "Wait for device" | |
until timeout 2s adb wait-for-device | |
do | |
ps --pid $emaulatorPid &> /dev/null | |
if [ $? -eq 0 ]; then | |
echo "..." | |
else | |
exit 1 | |
fi | |
done | |
echo "Wait for boot" | |
# boot=$(adb shell getprop sys.boot_completed | tr -d '\r') | |
boot=$(adb shell getprop dev.bootcomplete | tr -d '\r') | |
while [ "$boot" != "1" ]; do | |
sleep 2 | |
boot=$(adb shell getprop sys.boot_completed | tr -d '\r') | |
done | |
echo "Unlock device" | |
adb shell input keyevent 82 | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
start-emulator.sh
will start emulator passed in as first parameter. It will wait for emulator to boot up and unlock it. If emulator process is killed during that process script will exit with code 1.kill-emulators.sh
will kill all running emulators by telnet-int to them, authenticating and then killing them.