Bug 791716 - mirror mozbase -> m-c for week of Sept 17, 2012;r=wlach

This commit is contained in:
Jeff Hammel 2012-09-17 15:13:45 -07:00
parent dd96f8006d
commit 7a40628ff5
7 changed files with 92 additions and 5 deletions

View File

@ -13,10 +13,8 @@ together to form the basis of a test harness.
* 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

View File

@ -38,6 +38,11 @@ class SUTCli(object):
'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,
@ -130,6 +135,24 @@ class SUTCli(object):
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(),

View File

@ -7,8 +7,8 @@ connected.
*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.

View File

@ -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'

View File

@ -0,0 +1 @@
echo $THE_ANSWER

View File

@ -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)

View File

@ -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)