3
## This is the script jenkins should run to execute various touch applications
7
BASEDIR=$(dirname $(readlink -f $0))/..
9
RESDIR="${RESDIR-`pwd`/clientlogs}"
10
UTAHFILE=${RESDIR}/utah.yaml
11
UTAH_PHABLET_CMD="${UTAH_PHABLET_CMD-/usr/share/utah/examples/run_utah_phablet.py}"
16
usage: $0 -a APP [-s ANDROID_SERIAL] [-p FILE -p FILE ...] [-Q]
18
Provisions the given device with the latest build
22
-s Specify the serial of the device to install
23
-a The application under the "tests" directory to test
24
-p Extra file to pull from target (absolute path or relative to /home/phablet)
25
-Q "Quick" don't do a reboot of the device before running the test
34
echo "killing child pids: $PIDS"
41
export PATH=${BASEDIR}/utils/host:${PATH}
43
# allow for certain commands to run from host/target
44
# see unity8-autopilot/ts_control for example
45
export TARGET_PREFIX=adb-shell
47
[ -z $ANDROID_SERIAL ] || ADBOPTS="-s $ANDROID_SERIAL"
49
# If we are not in the utah group, then we don't have permissions
50
# for /var/lib/utah, so run under sudo
51
if ! groups |grep -q utah ; then
53
sudo TARGET_PREFIX="${TARGET_PREFIX}" PATH="${PATH}" \
58
--results-dir "${RESDIR}" \
59
--skip-install --skip-network --skip-utah \
61
--pull /home/phablet/.cache/upstart \
62
--pull /tmp/xmlresults \
63
--pull /var/log/syslog \
64
--pull /var/log/kern.log \
65
--pull /var/log/upstart/whoopsie.log \
67
-l "${TESTSUITE_HOST}/master.run"
69
TARGET_PREFIX="${TARGET_PREFIX}" PATH="${PATH}" \
74
--results-dir "${RESDIR}" \
75
--skip-install --skip-network --skip-utah \
77
--pull /home/phablet/.cache/upstart \
78
--pull /tmp/xmlresults \
79
--pull /var/log/syslog \
80
--pull /var/log/kern.log \
81
--pull /var/log/upstart/whoopsie.log \
83
-l "${TESTSUITE_HOST}/master.run"
86
# make sure the user running this script can remove its artifacts.
87
# only run this if we had to run under sudo
88
if [ "${SUDO}" = "sudo" ] ; then
89
sudo chown -R "${USER}" ${RESDIR}
94
[ -z $INSTALL_URL ] && return
95
echo "Ensuring target has proper image..."
96
REQUIRED_UUID=$(curl ${INSTALL_URL}/artifact/clientlogs/.ci-uuid)
97
ACTUAL_UUID=$(adb shell "cat /home/phablet/.ci-uuid | tr -d '\r\n'")
98
if [ "$REQUIRED_UUID" != "$ACTUAL_UUID" ] ; then
99
echo "UUIDs $REQUIRED_UUID != $ACTUAL_UUID, reprovisioning device..."
100
ARGS=$(curl ${INSTALL_URL}/artifact/clientlogs/.ci-utah-args | tr -d '\r\n')
101
UUID=$REQUIRED_UUID IMAGE_OPT=$ARGS ${BASEDIR}/scripts/provision.sh
113
# print the build date so the jenkins job can use it as the
115
adb pull /var/log/installer/media-info ${RESDIR}
116
BUILDID=$(adb shell cat /home/phablet/.ci-version)
117
echo "= TOUCH IMAGE VERSION:$BUILDID"
119
adb shell "top -n1 -b" > ${RESDIR}/top.log
122
adb shell 'sudo rm -f /var/crash/*'
123
if [ -z $QUICK ] ; then
124
# get the phone in sane place
126
# sometimes reboot doesn't happen fast enough, so add a little
127
# delay to help ensure its actually rebooted and we didn't just
128
# connect back to the device before it rebooted
132
phablet-network --skip-setup -t 90s
133
adb shell sudo powerd-cli active &
135
adb shell sudo powerd-cli display on &
138
echo "SKIPPING phone reboot..."
141
${BASEDIR}/utils/host/adb-shell "sudo aa-clickhook -f --include=/usr/share/autopilot-touch/apparmor/click.rules"
143
echo "launching test from the host...."
145
adb shell 'sudo rm -f /var/crash/*'
147
if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then
151
if ! `grep "^failures: [!0]" < $UTAHFILE >/dev/null` ; then
152
echo "failures found"
155
echo "Results Summary"
156
echo "---------------"
157
egrep '^(errors|failures|passes|fetch_errors):' $UTAHFILE
161
while getopts p:s:a:Qh opt; do
168
export ANDROID_SERIAL=$OPTARG
174
EXTRA_PULL_FILE=$OPTARG
176
if [ ! -z $EXTRA_PULL_FILE ]; then
177
# relative paths are assumed to be relative to /home/phablet
178
E_P_START=`echo $EXTRA_PULL_FILE | cut -c1`
180
if [ $E_P_START = '/' ]; then
181
EXTRA_PULL="$EXTRA_PULL --pull $EXTRA_PULL_FILE"
183
EXTRA_PULL="$EXTRA_PULL --pull /home/phablet/$EXTRA_PULL_FILE"
193
if [ -z $ANDROID_SERIAL ] ; then
194
# ensure we only have one device attached
195
lines=$(adb devices | wc -l)
196
if [ $lines -gt 3 ] ; then
197
echo "ERROR: More than one device attached, please use -s option"
203
if [ -z $APP ] ; then
204
echo "ERROR: No app specified"
209
TESTSUITE_HOST=$(readlink -f ${BASEDIR}/tests/${APP})
210
TESTSUITE_TARGET_BASE=/tmp/tests
211
TESTSUITE_TARGET=${TESTSUITE_TARGET_BASE}/$(basename ${TESTSUITE_HOST})
213
trap cleanup TERM INT EXIT