Merge lp:~doanac/ubuntu-test-cases/target-host-testing into lp:ubuntu-test-cases/smoke-touch-apps

Proposed by Andy Doan
Status: Merged
Merged at revision: 82
Proposed branch: lp:~doanac/ubuntu-test-cases/target-host-testing
Merge into: lp:ubuntu-test-cases/smoke-touch-apps
Prerequisite: lp:~doanac/ubuntu-test-cases/simplify-touch-part2
Diff against target: 272 lines (+132/-18) (has conflicts)
13 files modified
jenkins/jenkins.sh (+42/-0)
memevent/setup.sh (+8/-0)
memevent/ts_control (+1/-1)
phone-app-connected-autopilot/setup.sh (+27/-11)
systemsettle/systemsettle-after/tc_control (+0/-1)
systemsettle/systemsettle-before/tc_control (+0/-1)
systemsettle/systemsettle.sh (+5/-1)
unity8-autopilot/setup.sh (+1/-1)
unity8-autopilot/ts_control (+2/-2)
utils/host/adb-shell (+20/-0)
utils/host/autopilot-list (+18/-0)
utils/host/autopilot-run (+3/-0)
utils/host/prepare-autopilot-test.sh (+5/-0)
Text conflict in jenkins/jenkins.sh
To merge this branch: bzr merge lp:~doanac/ubuntu-test-cases/target-host-testing
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+181697@code.launchpad.net

Description of the change

This is the last part of my set of changes. It provides host based scripts so that all tests can be run via the host.

To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) wrote :

When running from the host, utah expects to be run as root. I'm thinking that being run from root should be done in this MP that 'if FROM_HOST, sudo ....' type of thing

Revision history for this message
Paul Larson (pwlars) wrote :

Looks good, only comment I have is that the ${UTAH_PHABLET_CMD} ... bit is mostly the same between test_from_host() and test_from_target(). Might be nice to combine them a bit more, but not critical.

review: Approve
94. By Andy Doan

make from-host run utah as root

as per cjohnston's review

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jenkins/jenkins.sh'
2--- jenkins/jenkins.sh 2013-08-23 23:35:53 +0000
3+++ jenkins/jenkins.sh 2013-08-27 15:42:49 +0000
4@@ -4,6 +4,8 @@
5 ## Intersting environment variables that must be set:
6 ## ANDROID_SERIAL - specify another android device
7 ## APP - the name of the app to test, ie share_app_autopilot
8+## QUICK - if set, skips the reboot and wait-for-network logic
9+## FROM_HOST - if set, runs the test from the host instead of the target
10
11 set -e
12
13@@ -23,6 +25,35 @@
14 set +e
15 }
16
17+test_from_target() {
18+ # push the runlist over to the test
19+ adb push ${BASEDIR} ${TESTSUITE_TARGET_BASE} &> /dev/null
20+ ${UTAH_PHABLET_CMD} \
21+ -s ${ANDROID_SERIAL} \
22+ --results-dir ${RESDIR} \
23+ --skip-install --skip-network --skip-utah \
24+ --pull /var/crash \
25+ -l ${TESTSUITE_TARGET}/master.run
26+}
27+
28+test_from_host() {
29+ export ANDROID_SERIAL # need for utils/hosts scripts
30+
31+ export PATH=${BASEDIR}/utils/host:${PATH}
32+
33+ # allow for certain commands to run from host/target
34+ # see unity8-autopilot/ts_control for example
35+ export TARGET_PREFIX=adb-shell
36+
37+ sudo TARGET_PREFIX=$TARGET_PREFIX PATH=$PATH ${UTAH_PHABLET_CMD} \
38+ -s ${ANDROID_SERIAL} \
39+ --from-host \
40+ --results-dir ${RESDIR} \
41+ --skip-install --skip-network --skip-utah \
42+ --pull /var/crash \
43+ -l ${TESTSUITE_HOST}/master.run
44+}
45+
46 main() {
47 rm -rf clientlogs
48 mkdir clientlogs
49@@ -51,6 +82,7 @@
50 echo "SKIPPING phone reboot..."
51 fi
52
53+<<<<<<< TREE
54 # push the runlist over to the test:
55 adb push ${BASEDIR} ${TESTSUITE_TARGET_BASE} &> /dev/null
56 ${UTAH_PHABLET_CMD} \
57@@ -60,6 +92,16 @@
58 --pull /var/crash \
59 -l ${TESTSUITE_TARGET}/master.run
60 adb shell 'rm -f /var/crash/*'
61+=======
62+ if [ -z $FROM_HOST ] ; then
63+ echo "launching test on the target...."
64+ test_from_target
65+ else
66+ echo "launching test from the host...."
67+ test_from_host
68+ fi
69+ adb shell 'rm -f /var/crash/*'
70+>>>>>>> MERGE-SOURCE
71
72 if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then
73 echo "errors found"
74
75=== added file 'memevent/setup.sh'
76--- memevent/setup.sh 1970-01-01 00:00:00 +0000
77+++ memevent/setup.sh 2013-08-27 15:42:49 +0000
78@@ -0,0 +1,8 @@
79+#!/bin/sh
80+
81+set -e
82+
83+# copy the autopilot scripts over if needed
84+[ -z $ANDROID_SERIAL ] || adb push ./ubuntu_test_cases /home/phablet/autopilot/ubuntu_test_cases
85+
86+PKGS="camera-app-autopilot gallery-app-autopilot mediaplayer-app-autopilot webbrowser-app-autopilot" prepare-autopilot-test.sh
87
88=== modified file 'memevent/ts_control'
89--- memevent/ts_control 2013-08-21 22:58:19 +0000
90+++ memevent/ts_control 2013-08-27 15:42:49 +0000
91@@ -1,1 +1,1 @@
92-ts_setup: PKGS="camera-app-autopilot gallery-app-autopilot mediaplayer-app-autopilot webbrowser-app-autopilot" prepare-autopilot-test.sh
93+ts_setup: ./setup.sh
94
95=== modified file 'phone-app-connected-autopilot/setup.sh'
96--- phone-app-connected-autopilot/setup.sh 2013-08-21 22:58:19 +0000
97+++ phone-app-connected-autopilot/setup.sh 2013-08-27 15:42:49 +0000
98@@ -1,20 +1,36 @@
99 #!/bin/sh
100
101-set -e
102+set -ex
103
104 # we have issues with running the test too soon, this is a hack:
105 echo "SLEEPING 60 TO HELP MAKE SURE PHONE IS READY"
106 sleep 60
107
108-# remove old logs so the receive test will work
109-rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf
110-
111-# set up the config file for the test
112-NUMBER=$(./sms_self.py --list)
113-cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > /home/phablet/.testnumbers.cfg
114-
115-# now send an sms to ourself
116-./sms_self.py
117+
118+if [ -z $ANDROID_SERIAL ] ; then
119+ # set up the config file for the test
120+ NUMBER=$(./sms_self.py --list)
121+ cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > /home/phablet/.testnumbers.cfg
122+
123+ # remove old logs so the receive test will work
124+ rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf
125+
126+ # now send an sms to ourself
127+ ./sms_self.py
128+else
129+ echo "test running from host"
130+ adb push ./sms_self.py /home/phablet/autopilot/
131+
132+ # set up the config file for the test
133+ NUMBER=$(adb-shell /home/phablet/autopilot/sms_self.py --list | head -n1)
134+ cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > .testnumbers.cfg
135+ adb push .testnumbers.cfg /home/phablet/.testnumbers.cfg
136+ rm .testnumbers.cfg
137+
138+ # remove old logs so the receive test will work
139+ adb-shell rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf
140+ adb-shell /home/phablet/autopilot/sms_self.py
141+fi
142+
143 sleep 10s # try and let the message come through
144-
145 PKGS="phone-app-connected-autopilot" prepare-autopilot-test.sh
146
147=== modified file 'systemsettle/systemsettle-after/tc_control'
148--- systemsettle/systemsettle-after/tc_control 2013-08-20 22:53:20 +0000
149+++ systemsettle/systemsettle-after/tc_control 2013-08-27 15:42:49 +0000
150@@ -7,4 +7,3 @@
151 type: userland
152 timeout: 120
153 command: ../systemsettle.sh -c5 -d2 -p 97.5
154-run_as: root
155
156=== modified file 'systemsettle/systemsettle-before/tc_control'
157--- systemsettle/systemsettle-before/tc_control 2013-08-20 22:53:20 +0000
158+++ systemsettle/systemsettle-before/tc_control 2013-08-27 15:42:49 +0000
159@@ -7,4 +7,3 @@
160 type: userland
161 timeout: 120
162 command: ../systemsettle.sh -c5 -d2 -p 97.5
163-run_as: root
164
165=== modified file 'systemsettle/systemsettle.sh'
166--- systemsettle/systemsettle.sh 2013-08-19 18:56:07 +0000
167+++ systemsettle/systemsettle.sh 2013-08-27 15:42:49 +0000
168@@ -1,5 +1,9 @@
169 #!/bin/bash
170
171+# Configuration variables:
172+# TARGET_PREFIX - Allows this to be run from the host, by providings something
173+# like TARGET_PREFIX="adb shell"
174+
175 set -e
176
177 # default exit code storage
178@@ -90,7 +94,7 @@
179 # get top
180 echo "TOP DUMP (after settle run: $settle_count)" >> $top_log
181 echo "========================" >> $top_log
182- top -b -d $top_wait -n $top_repeat >> $top_log
183+ ${TARGET_PREFIX} top -b -d $top_wait -n $top_repeat >> $top_log
184 cat $top_log | grep '.Cpu.*' | tail -n $top_tail > $top_log.reduced
185 echo >> $top_log
186
187
188=== modified file 'unity8-autopilot/setup.sh'
189--- unity8-autopilot/setup.sh 2013-08-21 22:58:19 +0000
190+++ unity8-autopilot/setup.sh 2013-08-27 15:42:49 +0000
191@@ -3,4 +3,4 @@
192 set -e
193
194 NO_UNLOCK=1 PKGS="unity8-autopilot" prepare-autopilot-test.sh
195-sudo -i -u phablet bash -ic "stop unity8"
196+$TARGET_PREFIX sudo -i -u phablet stop unity8
197
198=== modified file 'unity8-autopilot/ts_control'
199--- unity8-autopilot/ts_control 2013-08-01 16:39:36 +0000
200+++ unity8-autopilot/ts_control 2013-08-27 15:42:49 +0000
201@@ -1,2 +1,2 @@
202-ts_setup: sh ./setup.sh
203-ts_cleanup: 'sudo -i -u phablet bash -ic "start unity8"'
204+ts_setup: TARGET_PREFIX=$TARGET_PREFIX ./setup.sh
205+ts_cleanup: $TARGET_PREFIX sudo -i -u phablet start unity8
206
207=== added directory 'utils/host'
208=== added file 'utils/host/adb-shell'
209--- utils/host/adb-shell 1970-01-01 00:00:00 +0000
210+++ utils/host/adb-shell 2013-08-27 15:42:49 +0000
211@@ -0,0 +1,20 @@
212+#!/bin/bash
213+
214+# The "adb shell" command doesn't return an error if the command you execute
215+# resulted in an error. This is a wrapper to return the command's true return code.
216+
217+# NOTE: This script uses some specific bash'isms to keep things short and simple
218+
219+set -eu
220+
221+pat='ADB_RC=([[:digit:]]+)'
222+
223+{
224+ adb -s $ANDROID_SERIAL shell "$* ; echo ADB_RC=\$?"
225+} | while read line; do
226+ echo $line
227+ if [[ $line =~ $pat ]] ; then
228+ rc=${BASH_REMATCH[1]}
229+ exit $rc
230+ fi
231+done
232
233=== added file 'utils/host/autopilot-list'
234--- utils/host/autopilot-list 1970-01-01 00:00:00 +0000
235+++ utils/host/autopilot-list 2013-08-27 15:42:49 +0000
236@@ -0,0 +1,18 @@
237+#!/bin/sh
238+
239+set -e
240+
241+app=$1
242+pat=$app
243+rep=$app.tests.
244+
245+if [ -z "$app" ] ; then
246+ echo "USAGE: $0 <app> [pattern] [replace]"
247+ exit 1
248+fi
249+[ -z "$2" ] || pat=$2
250+[ -z "$3" ] || rep=$3
251+
252+#NOTE we just use adb shell here, because we don't have to catch errors. the greps
253+# will work around that
254+adb shell sudo -i -u phablet bash -ic \"PYTHONPATH=/home/phablet/autopilot autopilot list $app\" | grep $pat | sed -e "s/^.*${rep}//"
255
256=== added file 'utils/host/autopilot-run'
257--- utils/host/autopilot-run 1970-01-01 00:00:00 +0000
258+++ utils/host/autopilot-run 2013-08-27 15:42:49 +0000
259@@ -0,0 +1,3 @@
260+#!/bin/sh
261+
262+adb-shell sudo -i -u phablet bash -ic \"PYTHONPATH=/home/phablet/autopilot autopilot run -v $*\"
263
264=== added file 'utils/host/prepare-autopilot-test.sh'
265--- utils/host/prepare-autopilot-test.sh 1970-01-01 00:00:00 +0000
266+++ utils/host/prepare-autopilot-test.sh 2013-08-27 15:42:49 +0000
267@@ -0,0 +1,5 @@
268+#!/bin/sh
269+
270+set -e
271+
272+adb-shell PKGS=\"$PKGS\" prepare-autopilot-test.sh

Subscribers

People subscribed via source and target branches