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

Proposed by Jean-Baptiste Lallement on 2014-02-05
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 on 2014-02-05
Nicholas Skaggs 2014-02-05 Pending
Ubuntu Phablet Team 2014-02-05 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 on 2014-02-05

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

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 on 2014-02-05

* 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

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.

Unmerged revisions

238. By Jean-Baptiste Lallement on 2014-02-05

* 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 on 2014-02-05

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

236. By Jean-Baptiste Lallement on 2014-02-05

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
1=== modified file 'phablet-test-run'
2--- phablet-test-run 2014-01-20 19:59:53 +0000
3+++ phablet-test-run 2014-02-05 22:09:22 +0000
4@@ -19,6 +19,8 @@
5 LOCALPACKAGES=""
6 RESULTDIR=""
7 ARTIFACTS=""
8+TESTS_LOCATION=""
9+REMOTE_TESTBASE="/tmp/autopilot_tests"
10
11 EXECUTE_COMMAND=0
12 USER=phablet
13@@ -29,7 +31,7 @@
14
15 print_usage() {
16 cat << EOF
17-usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] testsuite
18+usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] [-t LOCATION] testsuite
19
20 Run the specified testsuite on the device
21
22@@ -40,6 +42,8 @@
23 -o DIR Test report and artifacts output dir
24 -a ARTIFACT Artifact to fetch after the test, may be used multiple times (requires -o)
25 -x Execute command line, will not use autopilot by default
26+ -t LOCATION Test location. It can be a local directory or an uri to a
27+ bzr location
28 -v Run autopilot with -v option for more verbose output
29 EOF
30 }
31@@ -103,7 +107,11 @@
32 # adb shell always returns 0, so we have to do some hackery to get the
33 # actual RC from the test
34 {
35- apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; autopilot run $VERBOSE"
36+ wdir=/home/$USER/autopilot
37+ if [ -n "$TESTS_LOCATION" ]; then
38+ wdir=${REMOTE_TESTBASE}
39+ fi
40+ apbase="sudo -iu $USER bash -ic \"mkdir -p $wdir; cd $wdir; autopilot run $VERBOSE"
41 if [ "$RESULTDIR" ]; then
42 adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?"
43 echo "***** Test summary *****"
44@@ -146,7 +154,35 @@
45 fi
46 }
47
48-while getopts a:c:hnxo:p:s:v opt; do
49+pull_tests() {
50+ # Pull test from a local directory or launchpad branch to the device
51+ #
52+ # $1: Tests URI either path to a local autopilot tests directory or lp
53+ # branch
54+ testdir=$(mktemp -d /tmp/$(basename $0).XXXXXX)
55+ location=""
56+
57+ if [ "$( echo $1 | cut -c-3)" = "lp:" ]; then
58+ echo "Branching tests from $1"
59+ ( cd $testdir; bzr export $(basename $1) $1 )
60+ location=${testdir}/$(basename $1)
61+ elif [ -d "$1" ]; then
62+ echo "Using tests from local directory: $1"
63+ location=$1
64+ else
65+ echo "Invalid test directory: $location"
66+ exit 1
67+ fi
68+
69+ remotedir=${REMOTE_TESTBASE}/$(basename $location)
70+ if [ -d "$location" ]; then
71+ exec_with_adb rm -Rf $REMOTE_TESTBASE
72+ exec_with_adb mkdir -p $remotedir
73+ adb push $location $remotedir
74+ fi
75+ rm -Rf $testdir
76+}
77+while getopts a:c:hnxo:p:s:t:v opt; do
78 case $opt in
79 a)
80 ARTIFACTS="$ARTIFACTS $OPTARG"
81@@ -170,6 +206,9 @@
82 s)
83 ADBOPTS="-s $OPTARG"
84 ;;
85+ t)
86+ TESTS_LOCATION="$OPTARG"
87+ ;;
88 x)
89 EXECUTE_COMMAND=1
90 ;;
91@@ -189,6 +228,10 @@
92
93 install_packages
94
95+if [ ! -z "$TESTS_LOCATION" ]; then
96+ pull_tests $TESTS_LOCATION
97+fi
98+
99 if [ $NOSHELL -eq 1 ]; then
100 echo "Disabling shell"
101 disable_shell

Subscribers

People subscribed via source and target branches