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