5
BASEDIR=$(dirname $(readlink -f $0))/..
6
RESDIR=`pwd`/clientlogs
8
export PATH=${BASEDIR}/utils/host:${PATH}
9
export TARGET_PREFIX=adb-shell
14
usage: $0 -a APP [-s ANDROID_SERIAL] [-Q] [-o results_dir] [-S]
16
Runs a set of autopilot tests on the target
20
-s Specify the serial of the device to test
21
-a The application to test (can be repeated)
22
-o Specify the directory to place results in.
24
-Q "Quick" don't do a reboot of the device before/between testsuites.
25
-S Skip the system-settle tests that run before/after each testsuite.
31
echo ERROR: $* >> ${RESDIR}/runner-errors.txt
39
pkgs=$(${BASEDIR}/jenkins/testconfig.py packages -a $app)
40
if [ "$label" = "setup" ] ; then
41
if [ -z "${SKIP_TESTCONFIG}" ]; then
42
adb-shell sudo apt-get install -yq --force-yes $pkgs
45
if [ -z "${SKIP_TESTCONFIG}" ]; then
46
#Always remove dbus-x11 because it causes
47
#problems when we leave it around
49
adb-shell sudo apt-get autoremove --purge -y $pkgs || /bin/true
52
echo $? > ${odir}/setup_${label}.rc
53
} 2>&1 | tee ${odir}/setup_${label}.log
57
[ -z $NOSETTLE ] || return 0
63
if [ "$label" = "before" ] ; then
67
settle=${BASEDIR}/tests/systemsettle/systemsettle.sh
69
export UTAH_PROBE_DIR=${odir} # needed for log file location
70
timeout $timeout $settle -c5 -d6 -p 97.5 -l $label || rc=1
71
echo $rc > ${odir}/settle_${label}.rc
72
} 2>&1 | tee ${odir}/settle_${label}.log
79
[ -d $odir ] && rm -rf $odir
80
mkdir -p $odir || return 1
82
system_settle before $odir
83
phablet-config autopilot --dbus-probe enable || \
84
(log_error "'autopilot dbus-probe enable' failed"; return 1)
85
adb-shell /home/phablet/bin/check-clickhook-rules || \
86
(log_error "some click profiles missing autopilot rules")
88
setup_test $app setup $odir
91
[ "$app" = "unity8" ] && NOSHELL="-n"
93
# Use --timeout-profile=long only if we are using the emulator
94
[ -z $USE_EMULATOR ] || EXTRA="-A '--timeout-profile=long'"
98
-o ${odir} -f subunit \
99
-a /var/crash -a /home/phablet/.cache/upstart \
101
-A --timeout-profile=long \
103
adb shell rm -rf /tmp/ci-logs
104
adb shell mkdir /tmp/ci-logs
105
adb shell sudo install -o phablet \
106
-m 666 /var/log/upstart/whoopsie.log /tmp/ci-logs
107
adb-shell "sudo system-image-cli --info > /tmp/ci-logs/system-image-cli.log"
108
adb-shell "dpkg -l > /tmp/ci-logs/dpkg-l.log"
109
adb pull /tmp/ci-logs ${odir}
111
system_settle after $odir
112
setup_test $app teardown $odir
113
if [ -f ${odir}/test_results.subunit ] ; then
114
cat ${odir}/test_results.subunit | subunit2junitxml > ${odir}/test_results.xml
116
${BASEDIR}/scripts/combine_results ${odir}
120
if [ -z $QUICK ] ; then
122
FILES="/var/crash/* /home/phablet/.cache/upstart/*.log*"
123
if ! adb shell "sudo rm -rf $FILES" ; then
124
log_error "unable to remove crash and log files, retrying"
126
adb shell "sudo rm -rf $FILES"
129
echo "SKIPPING phone reboot..."
133
if [ -z $USE_EMULATOR ] ; then
135
echo "grabbing powerd cli locks..."
136
adb shell sudo powerd-cli active &
138
adb shell sudo powerd-cli display on &
143
if [ -n "$PIDS" ] ; then
144
echo "killing child pids: $PIDS"
150
adb shell sudo pkill powerd-cli
155
#emulator does not use powerd, so this is noop
160
#emulator does not use powerd, so this is noop
166
# only try and update the dashboard if we are configured to
167
[ -z $DASHBOARD_KEY ] && return 0
168
[ -z $DASHBOARD_BUILD ] && return 0
169
[ -z $DASHBOARD_IMAGE ] && return 0
170
${BASEDIR}/scripts/dashboard.py $* \
171
--image $DASHBOARD_IMAGE \
172
--build $DASHBOARD_BUILD || true
175
dashboard_result_running() {
176
dashboard_update result-running --test $1
179
dashboard_result_syncing() {
180
xunit=${RESDIR}/${app}/test_results.xml
181
[ -f $xunit ] || return 0
183
# save a utah.yaml version of the results so the dashboard can process
184
cat $xunit | ${BASEDIR}/scripts/junit2utah.py > ${RESDIR}/${app}/utah.yaml
185
dashboard_update result-syncing --test $1 --results ${RESDIR}/${app}/utah.yaml
189
[ -d $RESDIR ] || mkdir -p $RESDIR
193
for app in $APPS ; do
195
echo "========================================================"
196
echo "= testing $app"
197
echo "========================================================"
199
dashboard_result_running $app
204
if ! test_app $app ; then
205
log_error "testing $app, retrying"
206
# we sometimes see sporatic adb failures that seem to
207
# related to MTP. This adds a retry for the test.
208
# test_app only fails on a device error (not a test
213
dashboard_result_syncing $app
219
while getopts s:a:o:QSh opt; do
226
export ANDROID_SERIAL=$OPTARG
243
if [ -z $ANDROID_SERIAL ] ; then
244
# ensure we only have one device attached
245
lines=$(adb devices | wc -l)
246
if [ $lines -gt 3 ] ; then
247
echo "ERROR: More than one device attached, please use -s option"
253
if [ -z "$APPS" ] ; then
254
echo "ERROR: No app specified"
259
trap release_powerd TERM INT EXIT
260
if [ -n "$USE_EMULATOR" ] ; then
261
echo "disabling system-settle testing for emulator"