3 # android_run_skia: starts the correct skia program on the device, prints the
4 # output, and kills the app if interrupted.
6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7 source $SCRIPT_DIR/utils/android_setup.sh
8 source $SCRIPT_DIR/utils/setup_adb.sh
10 if [ ! -f "${SKIA_OUT}/${APP_ARGS[0]}" ];
12 echo "Unable to find ${APP_ARGS[0]} executable"
16 verbose "pushing binaries onto the device..."
17 adb_push_if_needed "${SKIA_OUT}/${APP_ARGS[0]}" /data/local/tmp
18 if [[ -n $RESOURCE_PATH ]]; then
19 verbose "pushing resources onto the device..."
20 adb_push_if_needed "${SCRIPT_DIR}/../../../resources" $RESOURCE_PATH
24 verbose "clearing the device logs..."
25 $ADB $DEVICE_SERIAL logcat -c;
27 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)"
28 CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)"
29 echo "/data/local/tmp/${APP_ARGS[*]}; \
30 echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME}
31 chmod +x ${CMD_FILENAME}
32 verbose "======== To reproduce this run: ========"
33 verbose "android_run_skia ${APP_ARGS[*]}"
34 verbose "========================================"
35 verbose "pushing command file onto the device..."
36 $ADB ${DEVICE_SERIAL} push ${CMD_FILENAME} /data/local/tmp
38 verbose "preparing to run ${APP_ARGS[0]} on the device..."
39 $ADB ${DEVICE_SERIAL} shell sh /data/local/tmp/${CMD_FILENAME}
41 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exists; fi')" ]; then
42 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi
43 echo "***********************************************************************"
44 echo "The application terminated unexpectedly and did not produce an exit code"
45 echo "***********************************************************************"
49 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}`
50 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} ${CMD_FILENAME}
52 # check to see if the 'cat' command failed and print errors accordingly
53 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then
54 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi
55 echo "***********************************************************************"
56 echo "ADB failed to retrieve the application's exit code"
57 echo "***********************************************************************"
61 echo "EXIT_CODE is ${EXIT_CODE}"
62 if [[ "${EXIT_CODE}" != 0* ]]; then
63 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi