Last active
January 11, 2024 22:19
-
-
Save zach-klippenstein/1496b12b281119b68eb66ab7580a15a3 to your computer and use it in GitHub Desktop.
Shell script to trigger some jank in the Android emulator.
This file contains hidden or 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 | |
# Tells an Android emulator to take a snapshot of itself and then | |
# delete that snapshot immediately. The act of taking a snapshot | |
# forces the emulator to temporarily pause and trigger unexpected | |
# system behaviors. When it happens during a test run, it can | |
# trigger certain hard-to-reproduce flakes. | |
SNAPSHOT=__TEMPORARY_SNAPSHOT | |
AUTH="$(cat ~/.emulator_console_auth_token)" | |
PORT=$1 | |
if [[ -z $PORT ]]; then | |
echo "usage: $0 [emulator-port]" | |
adb devices | |
exit 1 | |
fi | |
echo "Taking temporary emulator snapshot then deleting it…" | |
set -e | |
set -x | |
nc localhost $1 <<EOF | |
avd name | |
auth $AUTH | |
avd snapshot save $SNAPSHOT | |
avd snapshot delete $SNAPSHOT | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment