Merge lp:~jibel/phablet-tools/run_tests_from_custom_location into lp:phablet-tools

Proposed by Jean-Baptiste Lallement
Status: Needs review
Proposed branch: lp:~jibel/phablet-tools/run_tests_from_custom_location
Merge into: lp:phablet-tools
Diff against target: 101 lines (+46/-3)
1 file modified
phablet-test-run (+46/-3)
To merge this branch: bzr merge lp:~jibel/phablet-tools/run_tests_from_custom_location
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Nicholas Skaggs Pending
Ubuntu Phablet Team Pending
Review via email: mp+205033@code.launchpad.net

Commit message

* phablet-test-run:
  - Add option -t LOCATION to pull the tests from a local directory or a bzr uri e.g lp:~user/.../test_app/. For bzr, the project is not branched, only the location passed in argument is exported

Description of the change

* phablet-test-run:
  - Add option -t LOCATION to pull the tests from a local directory or a bzr uri e.g lp:~user/.../test_app/. For bzr, the project is not branched, only the location passed in argument is exported

To post a comment you must log in.
237. By Jean-Baptiste Lallement

* phablet-test-run: Changed hardcoded phablet user to $USER

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

36 + wdir=/home/$USER
37 + if [ -n "$TESTS_LOCATION" ]; then
38 + wdir=${REMOTE_TESTBASE}
39 + fi

if you change this, you will also need to change phablet-click-test-setup (which is being renamed as well, and most of it obsolete as soon as py3 is ready).

Can you detail what this is going to be used for? Seems to be something similar to what balloons asked me to do.

238. By Jean-Baptiste Lallement

* phablet-test-run: Fixed working directory to the same value used in phablet-click-test-setup and create it if it doesn't exist to fix error in current builds

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This is similar, not quite the 1-click solution I was asking for with app developers. However, this will allow arbitrary (click or not) tests to be written and run against a device and iterated on. For the test writer, I will iterate on tests against apps that already are installed; thus I don't need to build them, merely update the tests and run them. This run functionality makes sense in phablet-test-run I believe.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

238. By Jean-Baptiste Lallement

* phablet-test-run: Fixed working directory to the same value used in phablet-click-test-setup and create it if it doesn't exist to fix error in current builds

237. By Jean-Baptiste Lallement

* phablet-test-run: Changed hardcoded phablet user to $USER

236. By Jean-Baptiste Lallement

phablet-test-run: Add option -t LOCATION to pull the tests from a local directory or a bzr uri e.g lp:~user/.../test_app/. For bzr, the project is not branched, only the location passed in argument is exported

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'phablet-test-run'
--- phablet-test-run 2014-01-20 19:59:53 +0000
+++ phablet-test-run 2014-02-05 22:09:22 +0000
@@ -19,6 +19,8 @@
19LOCALPACKAGES=""19LOCALPACKAGES=""
20RESULTDIR=""20RESULTDIR=""
21ARTIFACTS=""21ARTIFACTS=""
22TESTS_LOCATION=""
23REMOTE_TESTBASE="/tmp/autopilot_tests"
2224
23EXECUTE_COMMAND=025EXECUTE_COMMAND=0
24USER=phablet26USER=phablet
@@ -29,7 +31,7 @@
2931
30print_usage() {32print_usage() {
31 cat << EOF33 cat << EOF
32usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] testsuite34usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] [-t LOCATION] testsuite
3335
34 Run the specified testsuite on the device36 Run the specified testsuite on the device
3537
@@ -40,6 +42,8 @@
40 -o DIR Test report and artifacts output dir42 -o DIR Test report and artifacts output dir
41 -a ARTIFACT Artifact to fetch after the test, may be used multiple times (requires -o)43 -a ARTIFACT Artifact to fetch after the test, may be used multiple times (requires -o)
42 -x Execute command line, will not use autopilot by default44 -x Execute command line, will not use autopilot by default
45 -t LOCATION Test location. It can be a local directory or an uri to a
46 bzr location
43 -v Run autopilot with -v option for more verbose output47 -v Run autopilot with -v option for more verbose output
44EOF48EOF
45}49}
@@ -103,7 +107,11 @@
103 # adb shell always returns 0, so we have to do some hackery to get the107 # adb shell always returns 0, so we have to do some hackery to get the
104 # actual RC from the test108 # actual RC from the test
105 {109 {
106 apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; autopilot run $VERBOSE"110 wdir=/home/$USER/autopilot
111 if [ -n "$TESTS_LOCATION" ]; then
112 wdir=${REMOTE_TESTBASE}
113 fi
114 apbase="sudo -iu $USER bash -ic \"mkdir -p $wdir; cd $wdir; autopilot run $VERBOSE"
107 if [ "$RESULTDIR" ]; then115 if [ "$RESULTDIR" ]; then
108 adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?"116 adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?"
109 echo "***** Test summary *****"117 echo "***** Test summary *****"
@@ -146,7 +154,35 @@
146 fi154 fi
147}155}
148156
149while getopts a:c:hnxo:p:s:v opt; do157pull_tests() {
158 # Pull test from a local directory or launchpad branch to the device
159 #
160 # $1: Tests URI either path to a local autopilot tests directory or lp
161 # branch
162 testdir=$(mktemp -d /tmp/$(basename $0).XXXXXX)
163 location=""
164
165 if [ "$( echo $1 | cut -c-3)" = "lp:" ]; then
166 echo "Branching tests from $1"
167 ( cd $testdir; bzr export $(basename $1) $1 )
168 location=${testdir}/$(basename $1)
169 elif [ -d "$1" ]; then
170 echo "Using tests from local directory: $1"
171 location=$1
172 else
173 echo "Invalid test directory: $location"
174 exit 1
175 fi
176
177 remotedir=${REMOTE_TESTBASE}/$(basename $location)
178 if [ -d "$location" ]; then
179 exec_with_adb rm -Rf $REMOTE_TESTBASE
180 exec_with_adb mkdir -p $remotedir
181 adb push $location $remotedir
182 fi
183 rm -Rf $testdir
184}
185while getopts a:c:hnxo:p:s:t:v opt; do
150 case $opt in186 case $opt in
151 a)187 a)
152 ARTIFACTS="$ARTIFACTS $OPTARG"188 ARTIFACTS="$ARTIFACTS $OPTARG"
@@ -170,6 +206,9 @@
170 s)206 s)
171 ADBOPTS="-s $OPTARG"207 ADBOPTS="-s $OPTARG"
172 ;;208 ;;
209 t)
210 TESTS_LOCATION="$OPTARG"
211 ;;
173 x)212 x)
174 EXECUTE_COMMAND=1213 EXECUTE_COMMAND=1
175 ;;214 ;;
@@ -189,6 +228,10 @@
189228
190install_packages229install_packages
191230
231if [ ! -z "$TESTS_LOCATION" ]; then
232 pull_tests $TESTS_LOCATION
233fi
234
192if [ $NOSHELL -eq 1 ]; then235if [ $NOSHELL -eq 1 ]; then
193 echo "Disabling shell"236 echo "Disabling shell"
194 disable_shell237 disable_shell

Subscribers

People subscribed via source and target branches