diff -Nru phablet-tools-1.0+14.04.20140227.1/debian/changelog phablet-tools-1.0+14.04.20140310/debian/changelog --- phablet-tools-1.0+14.04.20140227.1/debian/changelog 2014-03-10 18:17:14.000000000 +0000 +++ phablet-tools-1.0+14.04.20140310/debian/changelog 2014-03-10 18:17:14.000000000 +0000 @@ -1,3 +1,24 @@ +phablet-tools (1.0+14.04.20140310-0ubuntu1) trusty; urgency=low + + [ Dmitrijs Ledkovs ] + * Support python2 and python3 based autopilot tests. + + [ Dimitri John Ledkov ] + * Support python2 and python3 based autopilot tests. + + [ Andy Doan ] + * phablet-test-run: support different result formats Autopilot + supports text, xml, and subunit result formats. This keeps the + default to xml, but allows users to choose the other formats as + well. I also took the chance to clean up some of the usage statement + line wrapping. + * phablet-test-run: add generic mechanism to pass arguments to + autopilot I was in need of changing autopilot's "--timeout-profile" + option. Rather than build another option to this command, I just + created a generic way to pass options directly to autopilot. + + -- Ubuntu daily release Mon, 10 Mar 2014 18:12:53 +0000 + phablet-tools (1.0+14.04.20140227.1-0ubuntu1) trusty; urgency=low [ Sergio Schvezov ] diff -Nru phablet-tools-1.0+14.04.20140227.1/phablet-click-test-setup phablet-tools-1.0+14.04.20140310/phablet-click-test-setup --- phablet-tools-1.0+14.04.20140227.1/phablet-click-test-setup 2014-02-27 15:28:00.000000000 +0000 +++ phablet-tools-1.0+14.04.20140310/phablet-click-test-setup 2014-03-10 18:12:30.000000000 +0000 @@ -58,13 +58,15 @@ lp = None +py2_subdir = 'legacy-py2' + basic_packages = ( {'source': 'unity8', 'binary': 'unity8'}, {'source': 'ubuntu-ui-toolkit', 'binary': 'qtdeclarative5-ubuntu-ui-toolkit-plugin'}) python_packages = ( - 'python-mock', 'python-dateutil' + 'python-mock', 'python-dateutil', 'python3-dateutil' ) @@ -111,6 +113,7 @@ def get_python_binary_package(package, target_dir): tmp_dir = tempfile.mkdtemp() atexit.register(cleanup, tmp_dir) + python2_target_dir = os.path.join(target_dir, py2_subdir) print('Fetching %s - into %s' % (package, tmp_dir)) bpph = lp.archive.getPublishedBinaries( binary_name=package, @@ -134,12 +137,22 @@ 'usr/lib/python2.7/dist-packages') python_modules_dir = pyshared_path if os.path.exists(pyshared_path) \ else python2_7_path - for f in os.listdir(python_modules_dir): - source = path.join(python_modules_dir, f) - if path.islink(source): - source = path.join(python_modules_dir, os.readlink(source)) - print('Moving %s to %s' % (source, target_dir)) - shutil.move(source, target_dir) + if os.path.exists(python_modules_dir): + for f in os.listdir(python_modules_dir): + source = path.join(python_modules_dir, f) + if path.islink(source): + source = path.join(python_modules_dir, os.readlink(source)) + print('Moving %s to %s' % (source, python2_target_dir)) + shutil.move(source, python2_target_dir) + python3_modules_dir = os.path.join(extract_dir, + 'usr/lib/python3/dist-packages') + if os.path.exists(python3_modules_dir): + for f in os.listdir(python3_modules_dir): + source = path.join(python3_modules_dir, f) + if path.islink(source): + source = path.join(python3_modules_dir, os.readlink(source)) + print('Moving %s to %s' % (source, target_dir)) + shutil.move(source, target_dir) def get_source_package_tests(package, version, target_dir): @@ -163,15 +176,17 @@ shutil.move(test_dir, target_dir) -def get_bzr_tests(branch, revision, target_dir): +def get_bzr_tests(branch, revision, autopilot_dir, target_dir, sub_dir): tmp_dir = tempfile.mkdtemp() atexit.register(cleanup, tmp_dir) print('Checking out %s to %s' % (branch, path.join(tmp_dir, 'work'))) check_call(['bzr', 'checkout', '--lightweight', branch, '-r', revision, 'work'], cwd=tmp_dir) - test_base_dir = path.join(tmp_dir, 'work', 'tests', 'autopilot') + test_base_dir = path.join(tmp_dir, 'work', autopilot_dir) test_dirs = filter((lambda x: path.isdir(path.join(test_base_dir, x))), os.listdir(test_base_dir)) + if sub_dir: + target_dir = os.path.join(target_dir, sub_dir) for test_dir in test_dirs: test_dir = path.join(test_base_dir, test_dir) print('Moving %s to %s' % (test_dir, target_dir)) @@ -194,9 +209,14 @@ print('Only keeping entries with x-source') manifest = [entry for entry in manifest if 'x-source' in entry] for entry in manifest: + subdir = py2_subdir + if 'x-test' in entry and 'autopilot' in entry['x-test']: + subdir = None get_bzr_tests(entry['x-source']['vcs-bzr'], entry['x-source']['vcs-bzr-revno'], - test_dir) + 'tests/autopilot', + test_dir, + subdir) def main(): @@ -208,6 +228,7 @@ series = adb.shell('lsb_release -c -s').strip() lp = LP(series, arch) test_dir = tempfile.mkdtemp() + os.mkdir(os.path.join(test_dir, py2_subdir)) atexit.register(cleanup, test_dir) fetch_test_base(adb, test_dir) fetch_click_tests(adb, test_dir, args.user, args.click) diff -Nru phablet-tools-1.0+14.04.20140227.1/phablet-test-run phablet-tools-1.0+14.04.20140310/phablet-test-run --- phablet-tools-1.0+14.04.20140227.1/phablet-test-run 2014-02-27 15:28:00.000000000 +0000 +++ phablet-tools-1.0+14.04.20140310/phablet-test-run 2014-03-10 18:12:43.000000000 +0000 @@ -19,6 +19,8 @@ LOCALPACKAGES="" RESULTDIR="" ARTIFACTS="" +APFORMAT="xml" +APEXTRA="" EXECUTE_COMMAND=0 USER=phablet @@ -29,16 +31,22 @@ print_usage() { cat << EOF -usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] testsuite +usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] [-f xml|subunit|text] [-A args] testsuite Run the specified testsuite on the device -s SERIAL Device serial number - -p PACKAGENAME Additional package to be installed, may be used multiple times - -c PACKAGE Copy and install local package to device, may be used multiple times + -p PACKAGENAME Additional package to be installed, may be used multiple + times + -c PACKAGE Copy and install local package to device, may be used + multiple times -n Stop the shell during the test run -o DIR Test report and artifacts output dir - -a ARTIFACT Artifact to fetch after the test, may be used multiple times (requires -o) + -f format Specifies the output format autopilot will use: + xml, subunit, or text. Default=$APFORMAT (requires -o) + -A Extra arguments to pass to autopilot. + -a ARTIFACT Artifact to fetch after the test, may be used multiple times + (requires -o) -x Execute command line, will not use autopilot by default -v Run autopilot with -v option for more verbose output EOF @@ -100,14 +108,24 @@ run_autopilot_test() { exec_with_adb chmod 666 /dev/uinput + + # First let's try python3, without python2 path + defaultpy="/usr/bin/python3" + import_error=$(adb shell "cd /home/phablet/autopilot; $defaultpy -c 'import $TESTSUITE'") + if [ -n "$import_error" ]; then + defaultpy="PYTHONPATH=/home/phablet/autopilot/legacy-py2:/home/phablet/autopilot /usr/bin/python" + fi + # adb shell always returns 0, so we have to do some hackery to get the # actual RC from the test { - apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; autopilot run $VERBOSE" + apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; $defaultpy -m autopilot.run run $VERBOSE $APEXTRA" if [ "$RESULTDIR" ]; then - adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?" - echo "***** Test summary *****" - exec_with_adb head -n 1 /tmp/test_results.xml + adb shell "$apbase -o /tmp/test_results.$APFORMAT -f $APFORMAT $TESTSUITE\"; echo ADB_RC=\$?" + if [ $APFORMAT = "xml" ]; then + echo "***** Test summary *****" + exec_with_adb head -n 1 /tmp/test_results.$APFORMAT + fi else adb shell "$apbase $TESTSUITE\"; echo ADB_RC=\$?" fi @@ -120,7 +138,7 @@ # actual RC from the test { if [ "$RESULTDIR" ]; then - result_output=/tmp/test_results.txt + result_output=/tmp/test_results.$APFORMAT adb shell 'rm -rf $result_output' adb shell "$apbase | tee $result_output\"; echo ADB_RC=\$?" adb pull $result_output $RESULTDIR @@ -137,7 +155,7 @@ echo "***** Artifacts ($RESULTDIR) *****" set +e if [ $EXECUTE_COMMAND -eq 0 ]; then - adb pull /tmp/test_results.xml $RESULTDIR + adb pull /tmp/test_results.$APFORMAT $RESULTDIR fi for artifact in $ARTIFACTS; do adb pull $artifact $RESULTDIR @@ -146,14 +164,20 @@ fi } -while getopts a:c:hnxo:p:s:v opt; do +while getopts A:a:c:f:hnxo:p:s:v opt; do case $opt in + A) + APEXTRA=$OPTARG + ;; a) ARTIFACTS="$ARTIFACTS $OPTARG" ;; c) LOCALPACKAGES="$LOCALPACKAGES $OPTARG" ;; + f) + APFORMAT=$OPTARG + ;; h) print_usage exit 0