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
=== modified file 'jenkins/jenkins.sh'
--- jenkins/jenkins.sh 2013-08-23 23:35:53 +0000
+++ jenkins/jenkins.sh 2013-08-27 15:42:49 +0000
@@ -4,6 +4,8 @@
4## Intersting environment variables that must be set:4## Intersting environment variables that must be set:
5## ANDROID_SERIAL - specify another android device5## ANDROID_SERIAL - specify another android device
6## APP - the name of the app to test, ie share_app_autopilot6## APP - the name of the app to test, ie share_app_autopilot
7## QUICK - if set, skips the reboot and wait-for-network logic
8## FROM_HOST - if set, runs the test from the host instead of the target
79
8set -e10set -e
911
@@ -23,6 +25,35 @@
23 set +e25 set +e
24}26}
2527
28test_from_target() {
29 # push the runlist over to the test
30 adb push ${BASEDIR} ${TESTSUITE_TARGET_BASE} &> /dev/null
31 ${UTAH_PHABLET_CMD} \
32 -s ${ANDROID_SERIAL} \
33 --results-dir ${RESDIR} \
34 --skip-install --skip-network --skip-utah \
35 --pull /var/crash \
36 -l ${TESTSUITE_TARGET}/master.run
37}
38
39test_from_host() {
40 export ANDROID_SERIAL # need for utils/hosts scripts
41
42 export PATH=${BASEDIR}/utils/host:${PATH}
43
44 # allow for certain commands to run from host/target
45 # see unity8-autopilot/ts_control for example
46 export TARGET_PREFIX=adb-shell
47
48 sudo TARGET_PREFIX=$TARGET_PREFIX PATH=$PATH ${UTAH_PHABLET_CMD} \
49 -s ${ANDROID_SERIAL} \
50 --from-host \
51 --results-dir ${RESDIR} \
52 --skip-install --skip-network --skip-utah \
53 --pull /var/crash \
54 -l ${TESTSUITE_HOST}/master.run
55}
56
26main() {57main() {
27 rm -rf clientlogs58 rm -rf clientlogs
28 mkdir clientlogs59 mkdir clientlogs
@@ -51,6 +82,7 @@
51 echo "SKIPPING phone reboot..."82 echo "SKIPPING phone reboot..."
52 fi83 fi
5384
85<<<<<<< TREE
54 # push the runlist over to the test:86 # push the runlist over to the test:
55 adb push ${BASEDIR} ${TESTSUITE_TARGET_BASE} &> /dev/null87 adb push ${BASEDIR} ${TESTSUITE_TARGET_BASE} &> /dev/null
56 ${UTAH_PHABLET_CMD} \88 ${UTAH_PHABLET_CMD} \
@@ -60,6 +92,16 @@
60 --pull /var/crash \92 --pull /var/crash \
61 -l ${TESTSUITE_TARGET}/master.run93 -l ${TESTSUITE_TARGET}/master.run
62 adb shell 'rm -f /var/crash/*'94 adb shell 'rm -f /var/crash/*'
95=======
96 if [ -z $FROM_HOST ] ; then
97 echo "launching test on the target...."
98 test_from_target
99 else
100 echo "launching test from the host...."
101 test_from_host
102 fi
103 adb shell 'rm -f /var/crash/*'
104>>>>>>> MERGE-SOURCE
63105
64 if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then106 if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then
65 echo "errors found"107 echo "errors found"
66108
=== added file 'memevent/setup.sh'
--- memevent/setup.sh 1970-01-01 00:00:00 +0000
+++ memevent/setup.sh 2013-08-27 15:42:49 +0000
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3set -e
4
5# copy the autopilot scripts over if needed
6[ -z $ANDROID_SERIAL ] || adb push ./ubuntu_test_cases /home/phablet/autopilot/ubuntu_test_cases
7
8PKGS="camera-app-autopilot gallery-app-autopilot mediaplayer-app-autopilot webbrowser-app-autopilot" prepare-autopilot-test.sh
09
=== modified file 'memevent/ts_control'
--- memevent/ts_control 2013-08-21 22:58:19 +0000
+++ memevent/ts_control 2013-08-27 15:42:49 +0000
@@ -1,1 +1,1 @@
1ts_setup: PKGS="camera-app-autopilot gallery-app-autopilot mediaplayer-app-autopilot webbrowser-app-autopilot" prepare-autopilot-test.sh1ts_setup: ./setup.sh
22
=== modified file 'phone-app-connected-autopilot/setup.sh'
--- phone-app-connected-autopilot/setup.sh 2013-08-21 22:58:19 +0000
+++ phone-app-connected-autopilot/setup.sh 2013-08-27 15:42:49 +0000
@@ -1,20 +1,36 @@
1#!/bin/sh1#!/bin/sh
22
3set -e3set -ex
44
5# we have issues with running the test too soon, this is a hack:5# we have issues with running the test too soon, this is a hack:
6echo "SLEEPING 60 TO HELP MAKE SURE PHONE IS READY"6echo "SLEEPING 60 TO HELP MAKE SURE PHONE IS READY"
7sleep 607sleep 60
88
9# remove old logs so the receive test will work9
10rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf10if [ -z $ANDROID_SERIAL ] ; then
1111 # set up the config file for the test
12# set up the config file for the test12 NUMBER=$(./sms_self.py --list)
13NUMBER=$(./sms_self.py --list)13 cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > /home/phablet/.testnumbers.cfg
14cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > /home/phablet/.testnumbers.cfg14
1515 # remove old logs so the receive test will work
16# now send an sms to ourself16 rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf
17./sms_self.py17
18 # now send an sms to ourself
19 ./sms_self.py
20else
21 echo "test running from host"
22 adb push ./sms_self.py /home/phablet/autopilot/
23
24 # set up the config file for the test
25 NUMBER=$(adb-shell /home/phablet/autopilot/sms_self.py --list | head -n1)
26 cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > .testnumbers.cfg
27 adb push .testnumbers.cfg /home/phablet/.testnumbers.cfg
28 rm .testnumbers.cfg
29
30 # remove old logs so the receive test will work
31 adb-shell rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf
32 adb-shell /home/phablet/autopilot/sms_self.py
33fi
34
18sleep 10s # try and let the message come through35sleep 10s # try and let the message come through
19
20PKGS="phone-app-connected-autopilot" prepare-autopilot-test.sh36PKGS="phone-app-connected-autopilot" prepare-autopilot-test.sh
2137
=== modified file 'systemsettle/systemsettle-after/tc_control'
--- systemsettle/systemsettle-after/tc_control 2013-08-20 22:53:20 +0000
+++ systemsettle/systemsettle-after/tc_control 2013-08-27 15:42:49 +0000
@@ -7,4 +7,3 @@
7type: userland7type: userland
8timeout: 1208timeout: 120
9command: ../systemsettle.sh -c5 -d2 -p 97.59command: ../systemsettle.sh -c5 -d2 -p 97.5
10run_as: root
1110
=== modified file 'systemsettle/systemsettle-before/tc_control'
--- systemsettle/systemsettle-before/tc_control 2013-08-20 22:53:20 +0000
+++ systemsettle/systemsettle-before/tc_control 2013-08-27 15:42:49 +0000
@@ -7,4 +7,3 @@
7type: userland7type: userland
8timeout: 1208timeout: 120
9command: ../systemsettle.sh -c5 -d2 -p 97.59command: ../systemsettle.sh -c5 -d2 -p 97.5
10run_as: root
1110
=== modified file 'systemsettle/systemsettle.sh'
--- systemsettle/systemsettle.sh 2013-08-19 18:56:07 +0000
+++ systemsettle/systemsettle.sh 2013-08-27 15:42:49 +0000
@@ -1,5 +1,9 @@
1#!/bin/bash1#!/bin/bash
22
3# Configuration variables:
4# TARGET_PREFIX - Allows this to be run from the host, by providings something
5# like TARGET_PREFIX="adb shell"
6
3set -e7set -e
48
5# default exit code storage9# default exit code storage
@@ -90,7 +94,7 @@
90 # get top94 # get top
91 echo "TOP DUMP (after settle run: $settle_count)" >> $top_log95 echo "TOP DUMP (after settle run: $settle_count)" >> $top_log
92 echo "========================" >> $top_log96 echo "========================" >> $top_log
93 top -b -d $top_wait -n $top_repeat >> $top_log97 ${TARGET_PREFIX} top -b -d $top_wait -n $top_repeat >> $top_log
94 cat $top_log | grep '.Cpu.*' | tail -n $top_tail > $top_log.reduced98 cat $top_log | grep '.Cpu.*' | tail -n $top_tail > $top_log.reduced
95 echo >> $top_log99 echo >> $top_log
96100
97101
=== modified file 'unity8-autopilot/setup.sh'
--- unity8-autopilot/setup.sh 2013-08-21 22:58:19 +0000
+++ unity8-autopilot/setup.sh 2013-08-27 15:42:49 +0000
@@ -3,4 +3,4 @@
3set -e3set -e
44
5NO_UNLOCK=1 PKGS="unity8-autopilot" prepare-autopilot-test.sh5NO_UNLOCK=1 PKGS="unity8-autopilot" prepare-autopilot-test.sh
6sudo -i -u phablet bash -ic "stop unity8"6$TARGET_PREFIX sudo -i -u phablet stop unity8
77
=== modified file 'unity8-autopilot/ts_control'
--- unity8-autopilot/ts_control 2013-08-01 16:39:36 +0000
+++ unity8-autopilot/ts_control 2013-08-27 15:42:49 +0000
@@ -1,2 +1,2 @@
1ts_setup: sh ./setup.sh1ts_setup: TARGET_PREFIX=$TARGET_PREFIX ./setup.sh
2ts_cleanup: 'sudo -i -u phablet bash -ic "start unity8"'2ts_cleanup: $TARGET_PREFIX sudo -i -u phablet start unity8
33
=== added directory 'utils/host'
=== added file 'utils/host/adb-shell'
--- utils/host/adb-shell 1970-01-01 00:00:00 +0000
+++ utils/host/adb-shell 2013-08-27 15:42:49 +0000
@@ -0,0 +1,20 @@
1#!/bin/bash
2
3# The "adb shell" command doesn't return an error if the command you execute
4# resulted in an error. This is a wrapper to return the command's true return code.
5
6# NOTE: This script uses some specific bash'isms to keep things short and simple
7
8set -eu
9
10pat='ADB_RC=([[:digit:]]+)'
11
12{
13 adb -s $ANDROID_SERIAL shell "$* ; echo ADB_RC=\$?"
14} | while read line; do
15 echo $line
16 if [[ $line =~ $pat ]] ; then
17 rc=${BASH_REMATCH[1]}
18 exit $rc
19 fi
20done
021
=== added file 'utils/host/autopilot-list'
--- utils/host/autopilot-list 1970-01-01 00:00:00 +0000
+++ utils/host/autopilot-list 2013-08-27 15:42:49 +0000
@@ -0,0 +1,18 @@
1#!/bin/sh
2
3set -e
4
5app=$1
6pat=$app
7rep=$app.tests.
8
9if [ -z "$app" ] ; then
10 echo "USAGE: $0 <app> [pattern] [replace]"
11 exit 1
12fi
13[ -z "$2" ] || pat=$2
14[ -z "$3" ] || rep=$3
15
16#NOTE we just use adb shell here, because we don't have to catch errors. the greps
17# will work around that
18adb shell sudo -i -u phablet bash -ic \"PYTHONPATH=/home/phablet/autopilot autopilot list $app\" | grep $pat | sed -e "s/^.*${rep}//"
019
=== added file 'utils/host/autopilot-run'
--- utils/host/autopilot-run 1970-01-01 00:00:00 +0000
+++ utils/host/autopilot-run 2013-08-27 15:42:49 +0000
@@ -0,0 +1,3 @@
1#!/bin/sh
2
3adb-shell sudo -i -u phablet bash -ic \"PYTHONPATH=/home/phablet/autopilot autopilot run -v $*\"
04
=== added file 'utils/host/prepare-autopilot-test.sh'
--- utils/host/prepare-autopilot-test.sh 1970-01-01 00:00:00 +0000
+++ utils/host/prepare-autopilot-test.sh 2013-08-27 15:42:49 +0000
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3set -e
4
5adb-shell PKGS=\"$PKGS\" prepare-autopilot-test.sh

Subscribers

People subscribed via source and target branches