author | Jeff Hammel <jhammel@mozilla.com> |
Mon, 17 Sep 2012 15:13:45 -0700 | |
changeset 107284 | 0fee6921199c578fa83ad050ee1ef178e9bc78ff |
parent 107283 | 27b51b9e9e838189ccd744062a0021ab1a090c12 |
child 107285 | 7c6024089dc360914c21fc1ae389b8778e18fd95 |
push id | 14956 |
push user | jhammel@mozilla.com |
push date | Mon, 17 Sep 2012 22:13:55 +0000 |
treeherder | mozilla-inbound@0fee6921199c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | wlach |
bugs | 791716 |
milestone | 18.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/testing/mozbase/README +++ b/testing/mozbase/README @@ -8,20 +8,18 @@ together to form the basis of a test har [mozprofile ](https://github.com/mozilla/mozbase/tree/master/mozprofile) ** and runs the application under test using [mozprocess](https://github.com/mozilla/mozbase/tree/master/mozprocess) * [mozInstall](https://github.com/mozilla/mozbase/tree/master/mozinstall) is used to install the test application * A test harness may direct Firefox to load web pages. These may be served using [mozhttpd](https://github.com/mozilla/mozbase/tree/master/mozhttpd) for testing * The machine environment is introspected by [mozinfo](https://github.com/mozilla/mozbase/tree/master/mozinfo) * A test manifest may be read to determine the tests to be run. These manifests are processed by [ManifestDestiny](https://github.com/mozilla/mozbase/tree/master/manifestdestiny) -* For mozbile testing, the test runner communicates to the test agent +* For mobile testing, the test runner communicates to the test agent using [mozdevice](https://github.com/mozilla/mozbase/tree/master/mozdevice) - (Note that the canonical location of mozdevice is - mozilla-central: http://mxr.mozilla.org/mozilla-central/source/build/mobile/) Learn more about mozbase here: https://wiki.mozilla.org/Auto-tools/Projects/MozBase Bugs live at https://bugzilla.mozilla.org/buglist.cgi?resolution=---&component=Mozbase&product=Testing and https://bugzilla.mozilla.org/buglist.cgi?resolution=---&status_whiteboard_type=allwordssubstr&query_format=advanced&status_whiteboard=mozbase To file a bug, go to
--- a/testing/mozbase/mozdevice/mozdevice/sutcli.py +++ b/testing/mozbase/mozdevice/mozdevice/sutcli.py @@ -33,16 +33,21 @@ class SUTCli(object): 'max_args': 4, 'help_args': '<appname> <activity name> <intent> <URL>', 'help': 'launches application on device' }, 'push': { 'function': self.push, 'min_args': 2, 'max_args': 2, 'help_args': '<local> <remote>', 'help': 'copy file/dir to device' }, + 'pull': { 'function': self.pull, + 'min_args': 1, + 'max_args': 2, + 'help_args': '<local> [remote]', + 'help': 'copy file/dir from device' }, 'shell': { 'function': self.shell, 'min_args': 1, 'max_args': None, 'help_args': '<command>', 'help': 'run shell command on device' }, 'info': { 'function': self.getinfo, 'min_args': None, 'max_args': 1, @@ -125,16 +130,34 @@ class SUTCli(object): self.dm.pushDir(src, dest) else: dest_is_dir = dest[-1] == '/' or self.dm.isDir(dest) dest = posixpath.normpath(dest) if dest_is_dir: dest = posixpath.join(dest, os.path.basename(src)) self.dm.pushFile(src, dest) + def pull(self, src, dest=None): + if not self.dm.fileExists(src): + print 'No such file or directory' + return + if not dest: + dest = posixpath.basename(src) + if self.dm.isDir(src): + result = self.dm.getDirectory(src, dest) + if result: + print '\n'.join([posixpath.join(dest, x) for x in result]) + return + else: + result = self.dm.getFile(src, dest) + if result: + print dest + return + print 'Pull failed.' + def install(self, apkfile): basename = os.path.basename(apkfile) app_path_on_device = posixpath.join(self.dm.getDeviceRoot(), basename) self.dm.pushFile(apkfile, app_path_on_device) self.dm.installApp(app_path_on_device) def launchapp(self, appname, activity, intent, url):
--- a/testing/mozbase/mozdevice/sut_tests/README.md +++ b/testing/mozbase/mozdevice/sut_tests/README.md @@ -2,14 +2,14 @@ * In order to run these tests you need to have a phone running SUT Agent connected. * Make sure you can reach the device's TCP 20700 and 20701 ports. Doing *adb forward tcp:20700 tcp:20700 && adb forward tcp:20701 tcp:20701* will forward your localhost 20700 and 20701 ports to the ones on the device. -* *You might need some common tools like cp. Use this script to install them: -http://pastebin.mozilla.org/1724898* +* You might need some common tools like cp. Use the `setup-tools.sh` script +to install them. It requires `$ADB` to point to the `adb` binary on the system. * Make sure the SUTAgent on the device is running. * Run: python runtests.py
new file mode 100755 --- /dev/null +++ b/testing/mozbase/mozdevice/sut_tests/setup-tools.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ ! -f busybox-armv6l ] +then + wget http://busybox.net/downloads/binaries/1.19.0/busybox-armv6l +fi +$ADB remount +$ADB push busybox-armv6l /system/bin/busybox + +$ADB shell 'cd /system/bin; chmod 555 busybox; for x in `./busybox --list`; do ln -s ./busybox $x; done'
new file mode 100644 --- /dev/null +++ b/testing/mozbase/mozdevice/sut_tests/test-files/test_script.sh @@ -0,0 +1,1 @@ +echo $THE_ANSWER
new file mode 100644 --- /dev/null +++ b/testing/mozbase/mozdevice/sut_tests/test_exec.py @@ -0,0 +1,23 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from StringIO import StringIO +import posixpath + +from dmunit import DeviceManagerTestCase + + +class ProcessListTestCase(DeviceManagerTestCase): + + def runTest(self): + """ simple exec test, does not use env vars """ + out = StringIO() + filename = posixpath.join(self.dm.getDeviceRoot(), 'test_exec_file') + # make sure the file was not already there + self.dm.removeFile(filename) + self.dm.shell(['touch', filename], out) + # check that the file has been created + self.assertTrue(self.dm.fileExists(filename)) + # clean up + self.dm.removeFile(filename)
new file mode 100644 --- /dev/null +++ b/testing/mozbase/mozdevice/sut_tests/test_exec_env.py @@ -0,0 +1,32 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from StringIO import StringIO +import os +import posixpath + +from dmunit import DeviceManagerTestCase + + +class ProcessListTestCase(DeviceManagerTestCase): + + def runTest(self): + """ simple exec test, does not use env vars """ + # push the file + localfile = os.path.join('test-files', 'test_script.sh') + remotefile = posixpath.join(self.dm.getDeviceRoot(), 'test_script.sh') + self.dm.pushFile(localfile, remotefile) + + # run the cmd + out = StringIO() + self.dm.shell(['sh', remotefile], out, env={'THE_ANSWER': 42}) + + # rewind the output file + out.seek(0) + # make sure first line is 42 + line = out.readline() + self.assertTrue(int(line) == 42) + + # clean up + self.dm.removeFile(remotefile)