Bug 723107 - Re-add mozdevice to testing/mozbase, remove duplicate files in build/mobile;r=jmaher
authorWilliam Lachance <wlachance@mozilla.com>
Fri, 07 Sep 2012 16:00:31 -0400
changeset 110904 3b8756765ff570a1bfc9908364d0fd4d73f3a2d6
parent 110903 f1628e236a1aad277fbc931f241c33eb86517738
child 110905 73005397cea1e916a6caee26aec0f668ba5f6cd4
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs723107
milestone18.0a1
Bug 723107 - Re-add mozdevice to testing/mozbase, remove duplicate files in build/mobile;r=jmaher
build/mobile/b2gemulator.py
build/mobile/devicemanager-utils.py
build/mobile/devicemanager.py
build/mobile/devicemanagerADB.py
build/mobile/devicemanagerSUT.py
build/mobile/droid.py
build/mobile/emulator.py
build/mobile/emulator_battery.py
layout/tools/reftest/Makefile.in
testing/mochitest/Makefile.in
testing/mozbase/mozdevice/README.md
testing/mozbase/mozdevice/mozdevice/__init__.py
testing/mozbase/mozdevice/mozdevice/b2gemulator.py
testing/mozbase/mozdevice/mozdevice/devicemanager.py
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
testing/mozbase/mozdevice/mozdevice/droid.py
testing/mozbase/mozdevice/mozdevice/emulator.py
testing/mozbase/mozdevice/mozdevice/emulator_battery.py
testing/mozbase/mozdevice/mozdevice/sutcli.py
testing/mozbase/mozdevice/setup.py
testing/mozbase/mozdevice/sut_tests/README.md
testing/mozbase/mozdevice/sut_tests/dmunit.py
testing/mozbase/mozdevice/sut_tests/genfiles.py
testing/mozbase/mozdevice/sut_tests/runtests.py
testing/mozbase/mozdevice/sut_tests/test-files/mytext.txt
testing/mozbase/mozdevice/sut_tests/test-files/smalltext.txt
testing/mozbase/mozdevice/sut_tests/test_cat2.py
testing/mozbase/mozdevice/sut_tests/test_datachannel.py
testing/mozbase/mozdevice/sut_tests/test_getdir.py
testing/mozbase/mozdevice/sut_tests/test_info.py
testing/mozbase/mozdevice/sut_tests/test_isdir.py
testing/mozbase/mozdevice/sut_tests/test_prompt.py
testing/mozbase/mozdevice/sut_tests/test_ps.py
testing/mozbase/mozdevice/sut_tests/test_pull.py
testing/mozbase/mozdevice/sut_tests/test_push1.py
testing/mozbase/mozdevice/sut_tests/test_push2.py
testing/mozbase/mozdevice/sut_tests/test_pushbinary.py
testing/mozbase/mozdevice/sut_tests/test_pushsmalltext.py
testing/mozbase/mozdevice/sut_tests/test_unzip.py
testing/mozbase/mozdevice/tests/manifest.ini
testing/mozbase/mozdevice/tests/sut.py
deleted file mode 100644
--- a/build/mobile/b2gemulator.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# 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/.
-
-
-import os
-import platform
-
-from emulator import Emulator
-
-
-class B2GEmulator(Emulator):
-
-    def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86",
-                 emulatorBinary=None, res='480x800', userdata=None,
-                 memory='512', partition_size='512'):
-        super(B2GEmulator, self).__init__(noWindow=noWindow, logcat_dir=logcat_dir,
-                                          arch=arch, emulatorBinary=emulatorBinary,
-                                          res=res, userdata=userdata,
-                                          memory=memory, partition_size=partition_size)
-        self.homedir = homedir
-        if self.homedir is not None:
-            self.homedir = os.path.expanduser(homedir)
-
-    def _check_file(self, filePath):
-        if not os.path.exists(filePath):
-            raise Exception(('File not found: %s; did you pass the B2G home '
-                             'directory as the homedir parameter, or set '
-                             'B2G_HOME correctly?') % filePath)
-
-    def _check_for_adb(self, host_dir):
-        if self._default_adb() == 0:
-            return
-        adb_paths = [os.path.join(self.homedir,'glue','gonk','out','host',
-                      host_dir ,'bin','adb'),os.path.join(self.homedir, 'out',
-                      'host', host_dir,'bin','adb'),os.path.join(self.homedir,
-                      'bin','adb')]
-        for option in adb_paths:
-            if os.path.exists(option):
-                self.adb = option
-                return
-        raise Exception('adb not found!')
-
-    def _locate_files(self):
-        if self.homedir is None:
-            self.homedir = os.getenv('B2G_HOME')
-        if self.homedir is None:
-            raise Exception('Must define B2G_HOME or pass the homedir parameter')
-        self._check_file(self.homedir)
-
-        if self.arch not in ("x86", "arm"):
-            raise Exception("Emulator architecture must be one of x86, arm, got: %s" %
-                            self.arch)
-
-        host_dir = "linux-x86"
-        if platform.system() == "Darwin":
-            host_dir = "darwin-x86"
-
-        host_bin_dir = os.path.join("out", "host", host_dir, "bin")
-
-        if self.arch == "x86":
-            binary = os.path.join(host_bin_dir, "emulator-x86")
-            kernel = "prebuilts/qemu-kernel/x86/kernel-qemu"
-            sysdir = "out/target/product/generic_x86"
-            self.tail_args = []
-        else:
-            binary = os.path.join(host_bin_dir, "emulator")
-            kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7"
-            sysdir = "out/target/product/generic"
-            self.tail_args = ["-cpu", "cortex-a8"]
-
-        self._check_for_adb(host_dir)
-
-        if not self.binary:
-            self.binary = os.path.join(self.homedir, binary)
-
-        self._check_file(self.binary)
-
-        self.kernelImg = os.path.join(self.homedir, kernel)
-        self._check_file(self.kernelImg)
-
-        self.sysDir = os.path.join(self.homedir, sysdir)
-        self._check_file(self.sysDir)
-
-        if not self.dataImg:
-            self.dataImg = os.path.join(self.sysDir, 'userdata.img')
-        self._check_file(self.dataImg)
deleted file mode 100644
--- a/build/mobile/devicemanager-utils.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# 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/.
-
-import devicemanager
-import sys
-import os
-
-def copy(dm, gre_path):
-    file = sys.argv[2]
-    if len(sys.argv) >= 4:
-        path = sys.argv[3]
-    else:
-        path = gre_path
-    if os.path.isdir(file):
-        dm.pushDir(file, path.replace('\\','/'))
-    else:
-        dm.pushFile(file, path.replace('\\','/'))
-
-def delete(dm, gre_path):
-    file = sys.argv[2]
-    dm.removeFile(file)
-
-def main():
-    ip_addr = os.environ.get("DEVICE_IP")
-    port = os.environ.get("DEVICE_PORT")
-    gre_path = os.environ.get("REMOTE_GRE_PATH").replace('\\','/')
-
-    if ip_addr == None:
-        print "Error: please define the environment variable DEVICE_IP before running this test"
-        sys.exit(1)
-
-    if port == None:
-        print "Error: please define the environment variable DEVICE_PORT before running this test"
-        sys.exit(1)
-
-    if gre_path == None:
-        print "Error: please define the environment variable REMOTE_GRE_PATH before running this test"
-        sys.exit(1)
-
-    dm = devicemanager.DeviceManager(ip_addr, int(port))
-    dm.sendCMD(['cd '+ gre_path], sleep = 1)
-    dm.debug = 0
-
-    if len(sys.argv) < 3:
-        print "usage: python devicemanager-utils.py <cmd> <path> [arg]"
-    cmd = sys.argv[1]
-    if (cmd == 'copy'):
-        sys.exit(copy(dm, gre_path))
-    if (cmd == 'delete'):
-        sys.exit(delete(dm, gre_path))
-    print "unrecognized command. supported commands are copy and delete"
-    sys.exit(-1)
-
-if __name__ == '__main__':
-    main()
deleted file mode 100755
--- a/build/mobile/devicemanager.py
+++ /dev/null
@@ -1,637 +0,0 @@
-# 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/.
-
-import hashlib
-import socket
-import os
-import re
-import StringIO
-
-class FileError(Exception):
-  " Signifies an error which occurs while doing a file operation."
-
-  def __init__(self, msg = ''):
-    self.msg = msg
-
-  def __str__(self):
-    return self.msg
-
-class DMError(Exception):
-  "generic devicemanager exception."
-
-  def __init__(self, msg= ''):
-    self.msg = msg
-
-  def __str__(self):
-    return self.msg
-
-def abstractmethod(method):
-  line = method.func_code.co_firstlineno
-  filename = method.func_code.co_filename
-  def not_implemented(*args, **kwargs):
-    raise NotImplementedError('Abstract method %s at File "%s", line %s '
-                              'should be implemented by a concrete class' %
-                              (repr(method), filename,line))
-  return not_implemented
-
-class DeviceManager:
-
-  @abstractmethod
-  def shell(self, cmd, outputfile, env=None, cwd=None, timeout=None):
-    """
-    executes shell command on device
-
-    timeout is specified in seconds, and if no timeout is given, 
-    we will run until the script returns
-    returns:
-    success: Return code from command
-    failure: None
-    """
-
-  @abstractmethod
-  def pushFile(self, localname, destname):
-    """
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-  @abstractmethod
-  def mkDir(self, name):
-    """
-    external function
-    returns:
-    success: directory name
-    failure: None
-    """
-
-  def mkDirs(self, filename):
-    """
-    make directory structure on the device
-    WARNING: does not create last part of the path
-    external function
-    returns:
-    success: directory structure that we created
-    failure: None
-    """
-    parts = filename.split('/')
-    name = ""
-    for part in parts:
-        if (part == parts[-1]): break
-        if (part != ""):
-            name += '/' + part
-            if (not self.dirExists(name)):
-                if (self.mkDir(name) == None):
-                    print "failed making directory: " + str(name)
-                    return None
-    return name
-
-  @abstractmethod
-  def pushDir(self, localDir, remoteDir):
-    """
-    push localDir from host to remoteDir on the device
-    external function
-    returns:
-    success: remoteDir
-    failure: None
-    """
-
-  @abstractmethod
-  def dirExists(self, dirname):
-    """
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-  @abstractmethod
-  def fileExists(self, filepath):
-    """
-    Because we always have / style paths we make this a lot easier with some
-    assumptions
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-  @abstractmethod
-  def listFiles(self, rootdir):
-    """
-    list files on the device, requires cd to directory first
-    external function
-    returns:
-    success: array of filenames, ['file1', 'file2', ...]
-    failure: None
-    """
-
-  @abstractmethod
-  def removeFile(self, filename):
-    """
-    external function
-    returns:
-    success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
-    failure: None
-    """
-
-  @abstractmethod
-  def removeDir(self, remoteDir):
-    """
-    does a recursive delete of directory on the device: rm -Rf remoteDir
-    external function
-    returns:
-    success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
-    failure: None
-    """
-
-  @abstractmethod
-  def getProcessList(self):
-    """
-    external function
-    returns:
-    success: array of process tuples
-    failure: None
-    """
-
-  @abstractmethod
-  def fireProcess(self, appname, failIfRunning=False):
-    """
-    external function
-    DEPRECATED: Use shell() or launchApplication() for new code
-    returns:
-    success: pid
-    failure: None
-    """
-
-  @abstractmethod
-  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
-    """
-    external function
-    DEPRECATED: Use shell() or launchApplication() for new code
-    returns:
-    success: output filename
-    failure: None
-    """
-
-  def processExist(self, appname):
-    """
-    iterates process list and returns pid if exists, otherwise None
-    external function
-    returns:
-    success: pid
-    failure: None
-    """
-
-    pid = None
-
-    #filter out extra spaces
-    parts = filter(lambda x: x != '', appname.split(' '))
-    appname = ' '.join(parts)
-
-    #filter out the quoted env string if it exists
-    #ex: '"name=value;name2=value2;etc=..." process args' -> 'process args'
-    parts = appname.split('"')
-    if (len(parts) > 2):
-      appname = ' '.join(parts[2:]).strip()
-
-    pieces = appname.split(' ')
-    parts = pieces[0].split('/')
-    app = parts[-1]
-
-    procList = self.getProcessList()
-    if (procList == []):
-      return None
-
-    for proc in procList:
-      procName = proc[1].split('/')[-1]
-      if (procName == app):
-        pid = proc[0]
-        break
-    return pid
-
-
-  @abstractmethod
-  def killProcess(self, appname, forceKill=False):
-    """
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-  @abstractmethod
-  def catFile(self, remoteFile):
-    """
-    external function
-    returns:
-    success: filecontents
-    failure: None
-    """
-
-  @abstractmethod
-  def pullFile(self, remoteFile):
-    """
-    external function
-    returns:
-    success: output of pullfile, string
-    failure: None
-    """
-
-  @abstractmethod
-  def getFile(self, remoteFile, localFile = ''):
-    """
-    copy file from device (remoteFile) to host (localFile)
-    external function
-    returns:
-    success: output of pullfile, string
-    failure: None
-    """
-
-  @abstractmethod
-  def getDirectory(self, remoteDir, localDir, checkDir=True):
-    """
-    copy directory structure from device (remoteDir) to host (localDir)
-    external function
-    checkDir exists so that we don't create local directories if the
-    remote directory doesn't exist but also so that we don't call isDir
-    twice when recursing.
-    returns:
-    success: list of files, string
-    failure: None
-    """
-
-  @abstractmethod
-  def isDir(self, remotePath):
-    """
-    external function
-    returns:
-    success: True
-    failure: False
-    Throws a FileError exception when null (invalid dir/filename)
-    """
-
-  @abstractmethod
-  def validateFile(self, remoteFile, localFile):
-    """
-    true/false check if the two files have the same md5 sum
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-  @abstractmethod
-  def getRemoteHash(self, filename):
-    """
-    return the md5 sum of a remote file
-    internal function
-    returns:
-    success: MD5 hash for given filename
-    failure: None
-    """
-
-  def getLocalHash(self, filename):
-    """
-    return the md5 sum of a file on the host
-    internal function
-    returns:
-    success: MD5 hash for given filename
-    failure: None
-    """
-
-    file = open(filename, 'rb')
-    if (file == None):
-      return None
-
-    try:
-      mdsum = hashlib.md5()
-    except:
-      return None
-
-    while 1:
-      data = file.read(1024)
-      if not data:
-        break
-      mdsum.update(data)
-
-    file.close()
-    hexval = mdsum.hexdigest()
-    if (self.debug >= 3): print "local hash returned: '" + hexval + "'"
-    return hexval
-
-  @abstractmethod
-  def getDeviceRoot(self):
-    """
-    Gets the device root for the testing area on the device
-    For all devices we will use / type slashes and depend on the device-agent
-    to sort those out.  The agent will return us the device location where we
-    should store things, we will then create our /tests structure relative to
-    that returned path.
-    Structure on the device is as follows:
-    /tests
-          /<fennec>|<firefox>  --> approot
-          /profile
-          /xpcshell
-          /reftest
-          /mochitest
-    external
-    returns:
-    success: path for device root
-    failure: None
-    """
-
-  @abstractmethod
-  def getAppRoot(self):
-    """
-    Either we will have /tests/fennec or /tests/firefox but we will never have
-    both.  Return the one that exists
-    TODO: ensure we can support org.mozilla.firefox
-    external function
-    returns:
-    success: path for app root
-    failure: None
-    """
-
-  def getTestRoot(self, type):
-    """
-    Gets the directory location on the device for a specific test type
-    Type is one of: xpcshell|reftest|mochitest
-    external function
-    returns:
-    success: path for test root
-    failure: None
-    """
-
-    devroot = self.getDeviceRoot()
-    if (devroot == None):
-      return None
-
-    if (re.search('xpcshell', type, re.I)):
-      self.testRoot = devroot + '/xpcshell'
-    elif (re.search('?(i)reftest', type)):
-      self.testRoot = devroot + '/reftest'
-    elif (re.search('?(i)mochitest', type)):
-      self.testRoot = devroot + '/mochitest'
-    return self.testRoot
-
-  def signal(self, processID, signalType, signalAction):
-    """
-    Sends a specific process ID a signal code and action.
-    For Example: SIGINT and SIGDFL to process x
-    """
-    #currently not implemented in device agent - todo
-
-    pass
-
-  def getReturnCode(self, processID):
-    """Get a return code from process ending -- needs support on device-agent"""
-    # TODO: make this real
-
-    return 0
-
-  @abstractmethod
-  def unpackFile(self, file_path, dest_dir=None):
-    """
-    external function
-    returns:
-    success: output of unzip command
-    failure: None
-    """
-
-  @abstractmethod
-  def reboot(self, ipAddr=None, port=30000):
-    """
-    external function
-    returns:
-    success: status from test agent
-    failure: None
-    """
-
-  def validateDir(self, localDir, remoteDir):
-    """
-    validate localDir from host to remoteDir on the device
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-    if (self.debug >= 2): print "validating directory: " + localDir + " to " + remoteDir
-    for root, dirs, files in os.walk(localDir):
-      parts = root.split(localDir)
-      for file in files:
-        remoteRoot = remoteDir + '/' + parts[1]
-        remoteRoot = remoteRoot.replace('/', '/')
-        if (parts[1] == ""): remoteRoot = remoteDir
-        remoteName = remoteRoot + '/' + file
-        if (self.validateFile(remoteName, os.path.join(root, file)) <> True):
-            return False
-    return True
-
-  @abstractmethod
-  def getInfo(self, directive=None):
-    """
-    Returns information about the device:
-    Directive indicates the information you want to get, your choices are:
-    os - name of the os
-    id - unique id of the device
-    uptime - uptime of the device
-    uptimemillis - uptime of the device in milliseconds (NOT supported on all
-                   implementations)
-    systime - system time of the device
-    screen - screen resolution
-    memory - memory stats
-    process - list of running processes (same as ps)
-    disk - total, free, available bytes on disk
-    power - power status (charge, battery temp)
-    all - all of them - or call it with no parameters to get all the information
-    returns:
-    success: dict of info strings by directive name
-    failure: None
-    """
-
-  @abstractmethod
-  def installApp(self, appBundlePath, destPath=None):
-    """
-    external function
-    returns:
-    success: output from agent for inst command
-    failure: None
-    """
-
-  @abstractmethod
-  def uninstallAppAndReboot(self, appName, installPath=None):
-    """
-    external function
-    returns:
-    success: True
-    failure: None
-    """
-
-  @abstractmethod
-  def updateApp(self, appBundlePath, processName=None,
-                destPath=None, ipAddr=None, port=30000):
-    """
-    external function
-    returns:
-    success: text status from command or callback server
-    failure: None
-    """
-
-  @abstractmethod
-  def getCurrentTime(self):
-    """
-    external function
-    returns:
-    success: time in ms
-    failure: None
-    """
-
-  def recordLogcat(self):
-    """
-    external function
-    returns:
-    success: file is created in <testroot>/logcat.log
-    failure:
-    """
-    #TODO: spawn this off in a separate thread/process so we can collect all the logcat information
-
-    # Right now this is just clearing the logcat so we can only see what happens after this call.
-    buf = StringIO.StringIO()
-    self.shell(['/system/bin/logcat', '-c'], buf, root=True)
-
-  def getLogcat(self):
-    """
-    external function
-    returns: data from the local file
-    success: file is in 'filename'
-    failure: None
-    """
-    buf = StringIO.StringIO()
-    if self.shell(["/system/bin/logcat", "-d", "dalvikvm:S", "ConnectivityService:S", "WifiMonitor:S", "WifiStateTracker:S", "wpa_supplicant:S", "NetworkStateTracker:S"], buf, root=True) != 0:
-      return None
-
-    return str(buf.getvalue()[0:-1]).rstrip().split('\r')
-
-  @abstractmethod
-  def chmodDir(self, remoteDir):
-    """
-    external function
-    returns:
-    success: True
-    failure: False
-    """
-
-  @staticmethod
-  def _escapedCommandLine(cmd):
-    """ Utility function to return escaped and quoted version of command line """
-    quotedCmd = []
-
-    for arg in cmd:
-      arg.replace('&', '\&')
-
-      needsQuoting = False
-      for char in [ ' ', '(', ')', '"', '&' ]:
-        if arg.find(char) >= 0:
-          needsQuoting = True
-          break
-      if needsQuoting:
-        arg = '\'%s\'' % arg
-
-      quotedCmd.append(arg)
-
-    return " ".join(quotedCmd)
-
-
-class NetworkTools:
-  def __init__(self):
-    pass
-
-  # Utilities to get the local ip address
-  def getInterfaceIp(self, ifname):
-    if os.name != "nt":
-      import fcntl
-      import struct
-      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-      return socket.inet_ntoa(fcntl.ioctl(
-                              s.fileno(),
-                              0x8915,  # SIOCGIFADDR
-                              struct.pack('256s', ifname[:15])
-                              )[20:24])
-    else:
-      return None
-
-  def getLanIp(self):
-    try:
-      ip = socket.gethostbyname(socket.gethostname())
-    except socket.gaierror:
-      ip = socket.gethostbyname(socket.gethostname() + ".local") # for Mac OS X
-    if ip.startswith("127.") and os.name != "nt":
-      interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
-      for ifname in interfaces:
-        try:
-          ip = self.getInterfaceIp(ifname)
-          break;
-        except IOError:
-          pass
-    return ip
-
-  # Gets an open port starting with the seed by incrementing by 1 each time
-  def findOpenPort(self, ip, seed):
-    try:
-      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-      s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-      connected = False
-      if isinstance(seed, basestring):
-        seed = int(seed)
-      maxportnum = seed + 5000 # We will try at most 5000 ports to find an open one
-      while not connected:
-        try:
-          s.bind((ip, seed))
-          connected = True
-          s.close()
-          break
-        except:
-          if seed > maxportnum:
-            print "Could not find open port after checking 5000 ports"
-          raise
-        seed += 1
-    except:
-      print "Socket error trying to find open port"
-
-    return seed
-
-def _pop_last_line(file):
-  '''
-  Utility function to get the last line from a file (shared between ADB and
-  SUT device managers). Function also removes it from the file. Intended to
-  strip off the return code from a shell command.
-  '''
-  bytes_from_end = 1
-  file.seek(0, 2)
-  length = file.tell() + 1
-  while bytes_from_end < length:
-    file.seek((-1)*bytes_from_end, 2)
-    data = file.read()
-
-    if bytes_from_end == length-1 and len(data) == 0: # no data, return None
-      return None
-
-    if data[0] == '\n' or bytes_from_end == length-1:
-      # found the last line, which should have the return value
-      if data[0] == '\n':
-        data = data[1:]
-
-      # truncate off the return code line
-      file.truncate(length - bytes_from_end)
-      file.seek(0,2)
-      file.write('\0')
-
-      return data
-
-    bytes_from_end += 1
-
-  return None
deleted file mode 100644
--- a/build/mobile/devicemanagerADB.py
+++ /dev/null
@@ -1,900 +0,0 @@
-# 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/.
-
-import subprocess
-from devicemanager import DeviceManager, DMError, _pop_last_line
-import re
-import os
-import tempfile
-import time
-
-class DeviceManagerADB(DeviceManager):
-
-  def __init__(self, host=None, port=20701, retrylimit=5, packageName='fennec',
-               adbPath='adb', deviceSerial=None, deviceRoot=None):
-    self.host = host
-    self.port = port
-    self.retrylimit = retrylimit
-    self.retries = 0
-    self._sock = None
-    self.useRunAs = False
-    self.haveRoot = False
-    self.useDDCopy = False
-    self.useZip = False
-    self.packageName = None
-    self.tempDir = None
-    self.deviceRoot = deviceRoot
-
-    # the path to adb, or 'adb' to assume that it's on the PATH
-    self.adbPath = adbPath
-
-    # The serial number of the device to use with adb, used in cases
-    # where multiple devices are being managed by the same adb instance.
-    self.deviceSerial = deviceSerial
-
-    if packageName == 'fennec':
-      if os.getenv('USER'):
-        self.packageName = 'org.mozilla.fennec_' + os.getenv('USER')
-      else:
-        self.packageName = 'org.mozilla.fennec_'
-    elif packageName:
-      self.packageName = packageName
-
-    # verify that we can run the adb command. can't continue otherwise
-    self.verifyADB()
-
-    # try to connect to the device over tcp/ip if we have a hostname
-    if self.host:
-      self.connectRemoteADB()
-
-    # verify that we can connect to the device. can't continue
-    self.verifyDevice()
-
-    # set up device root
-    self.setupDeviceRoot()
-
-    # Can we use run-as? (currently not required)
-    try:
-      self.verifyRunAs()
-    except DMError:
-      pass
-
-    # Can we run things as root? (currently not required)
-    useRunAsTmp = self.useRunAs
-    self.useRunAs = False
-    try:
-      self.verifyRoot()
-    except DMError:
-      try:
-        self.checkCmd(["root"])
-        # The root command does not fail even if ADB cannot get
-        # root rights (e.g. due to production builds), so we have
-        # to check again ourselves that we have root now.
-        self.verifyRoot()
-      except DMError:
-        if useRunAsTmp:
-          print "restarting as root failed, but run-as available"
-        else:
-          print "restarting as root failed"
-    self.useRunAs = useRunAsTmp
-
-    # can we use zip to speed up some file operations? (currently not
-    # required)
-    try:
-      self.verifyZip()
-    except DMError:
-      pass
-
-  def __del__(self):
-    if self.host:
-      self.disconnectRemoteADB()
-
-  # external function: executes shell command on device.
-  # timeout is specified in seconds, and if no timeout is given, 
-  # we will run until the script returns
-  # returns:
-  # success: <return code>
-  # failure: None
-  def shell(self, cmd, outputfile, env=None, cwd=None, timeout=None, root=False):
-    # FIXME: this function buffers all output of the command into memory,
-    # always. :(
-
-    # Getting the return code is more complex than you'd think because adb
-    # doesn't actually return the return code from a process, so we have to
-    # capture the output to get it
-    if root:
-      cmdline = "su -c \"%s\"" % self._escapedCommandLine(cmd)
-    else:
-      cmdline = self._escapedCommandLine(cmd)
-    cmdline += "; echo $?"
-
-    # prepend cwd and env to command if necessary
-    if cwd:
-      cmdline = "cd %s; %s" % (cwd, cmdline)
-    if env:
-      envstr = '; '.join(map(lambda x: 'export %s=%s' % (x[0], x[1]), env.iteritems()))
-      cmdline = envstr + "; " + cmdline
-
-    # all output should be in stdout
-    args=[self.adbPath]
-    if self.deviceSerial:
-        args.extend(['-s', self.deviceSerial])
-    args.extend(["shell", cmdline])
-    proc = subprocess.Popen(args,
-                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    if timeout:
-        timeout = int(timeout)
-        start_time = time.time()
-        ret_code = proc.poll()
-        while ((time.time() - start_time) <= timeout) and ret_code == None:
-            time.sleep(1)
-            ret_code = proc.poll()
-        if ret_code == None:
-            proc.kill()
-            raise DMError("Timeout exceeded for shell call")
-    (stdout, stderr) = proc.communicate()
-    outputfile.write(stdout.rstrip('\n'))
-
-    lastline = _pop_last_line(outputfile)
-    if lastline:
-      m = re.search('([0-9]+)', lastline)
-      if m:
-        return_code = m.group(1)
-        outputfile.seek(-2, 2)
-        outputfile.truncate() # truncate off the return code
-        return int(return_code)
-
-    return None
-
-  def connectRemoteADB(self):
-    self.checkCmd(["connect", self.host + ":" + str(self.port)])
-
-  def disconnectRemoteADB(self):
-    self.checkCmd(["disconnect", self.host + ":" + str(self.port)])
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def pushFile(self, localname, destname):
-    try:
-      if (os.name == "nt"):
-        destname = destname.replace('\\', '/')
-      if (self.useRunAs):
-        remoteTmpFile = self.getTempDir() + "/" + os.path.basename(localname)
-        self.checkCmd(["push", os.path.realpath(localname), remoteTmpFile])
-        if self.useDDCopy:
-          self.checkCmdAs(["shell", "dd", "if=" + remoteTmpFile, "of=" + destname])
-        else:
-          self.checkCmdAs(["shell", "cp", remoteTmpFile, destname])
-        self.checkCmd(["shell", "rm", remoteTmpFile])
-      else:
-        self.checkCmd(["push", os.path.realpath(localname), destname])
-      if (self.isDir(destname)):
-        destname = destname + "/" + os.path.basename(localname)
-      return True
-    except:
-      return False
-
-  # external function
-  # returns:
-  #  success: directory name
-  #  failure: None
-  def mkDir(self, name):
-    try:
-      result = self.runCmdAs(["shell", "mkdir", name]).stdout.read()
-      if 'read-only file system' in result.lower():
-        return None
-      if 'file exists' in result.lower():
-        return name
-      return name
-    except:
-      return None
-
-  # push localDir from host to remoteDir on the device
-  # external function
-  # returns:
-  #  success: remoteDir
-  #  failure: None
-  def pushDir(self, localDir, remoteDir):
-    # adb "push" accepts a directory as an argument, but if the directory
-    # contains symbolic links, the links are pushed, rather than the linked
-    # files; we either zip/unzip or push file-by-file to get around this 
-    # limitation
-    try:
-      if (not self.dirExists(remoteDir)):
-        self.mkDirs(remoteDir+"/x")
-      if (self.useZip):
-        try:
-          localZip = tempfile.mktemp()+".zip"
-          remoteZip = remoteDir + "/adbdmtmp.zip"
-          subprocess.check_output(["zip", "-r", localZip, '.'], cwd=localDir)
-          self.pushFile(localZip, remoteZip)
-          os.remove(localZip)
-          data = self.runCmdAs(["shell", "unzip", "-o", remoteZip, "-d", remoteDir]).stdout.read()
-          self.checkCmdAs(["shell", "rm", remoteZip])
-          if (re.search("unzip: exiting", data) or re.search("Operation not permitted", data)):
-            raise Exception("unzip failed, or permissions error")
-        except:
-          print "zip/unzip failure: falling back to normal push"
-          self.useZip = False
-          self.pushDir(localDir, remoteDir)
-      else:
-        for root, dirs, files in os.walk(localDir, followlinks=True):
-          relRoot = os.path.relpath(root, localDir)
-          for file in files:
-            localFile = os.path.join(root, file)
-            remoteFile = remoteDir + "/"
-            if (relRoot!="."):
-              remoteFile = remoteFile + relRoot + "/"
-            remoteFile = remoteFile + file
-            self.pushFile(localFile, remoteFile)
-          for dir in dirs:
-            targetDir = remoteDir + "/"
-            if (relRoot!="."):
-              targetDir = targetDir + relRoot + "/"
-            targetDir = targetDir + dir
-            if (not self.dirExists(targetDir)):
-              self.mkDir(targetDir)
-      return remoteDir
-    except:
-      print "pushing " + localDir + " to " + remoteDir + " failed"
-      return None
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def dirExists(self, dirname):
-    return self.isDir(dirname)
-
-  # Because we always have / style paths we make this a lot easier with some
-  # assumptions
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def fileExists(self, filepath):
-    p = self.runCmd(["shell", "ls", "-a", filepath])
-    data = p.stdout.readlines()
-    if (len(data) == 1):
-      if (data[0].rstrip() == filepath):
-        return True
-    return False
-
-  def removeFile(self, filename):
-    return self.runCmd(["shell", "rm", filename]).stdout.read()
-
-  # does a recursive delete of directory on the device: rm -Rf remoteDir
-  # external function
-  # returns:
-  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
-  #  failure: None
-  def removeSingleDir(self, remoteDir):
-    return self.runCmd(["shell", "rmdir", remoteDir]).stdout.read()
-
-  # does a recursive delete of directory on the device: rm -Rf remoteDir
-  # external function
-  # returns:
-  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
-  #  failure: None
-  def removeDir(self, remoteDir):
-      out = ""
-      if (self.isDir(remoteDir)):
-          files = self.listFiles(remoteDir.strip())
-          for f in files:
-              if (self.isDir(remoteDir.strip() + "/" + f.strip())):
-                  out += self.removeDir(remoteDir.strip() + "/" + f.strip())
-              else:
-                  out += self.removeFile(remoteDir.strip() + "/" + f.strip())
-          out += self.removeSingleDir(remoteDir.strip())
-      else:
-          out += self.removeFile(remoteDir.strip())
-      return out
-
-  def isDir(self, remotePath):
-      p = self.runCmd(["shell", "ls", "-a", remotePath + '/'])
-
-      data = p.stdout.readlines()
-      if len(data) == 1:
-          res = data[0]
-          if "Not a directory" in res or "No such file or directory" in res:
-              return False
-
-      return True
-
-  def listFiles(self, rootdir):
-      p = self.runCmd(["shell", "ls", "-a", rootdir])
-      data = p.stdout.readlines()
-      data[:] = [item.rstrip('\r\n') for item in data]
-      if (len(data) == 1):
-          if (data[0] == rootdir):
-              return []
-          if (data[0].find("No such file or directory") != -1):
-              return []
-          if (data[0].find("Not a directory") != -1):
-              return []
-          if (data[0].find("Permission denied") != -1):
-              return []
-          if (data[0].find("opendir failed") != -1):
-              return []
-      return data
-
-  # external function
-  # returns:
-  #  success: array of process tuples
-  #  failure: []
-  def getProcessList(self):
-    p = self.runCmd(["shell", "ps"])
-      # first line is the headers
-    p.stdout.readline()
-    proc = p.stdout.readline()
-    ret = []
-    while (proc):
-      els = proc.split()
-      ret.append(list([els[1], els[len(els) - 1], els[0]]))
-      proc =  p.stdout.readline()
-    return ret
-
-  # external function
-  # DEPRECATED: Use shell() or launchApplication() for new code
-  # returns:
-  #  success: pid
-  #  failure: None
-  def fireProcess(self, appname, failIfRunning=False):
-    #strip out env vars
-    parts = appname.split('"');
-    if (len(parts) > 2):
-      parts = parts[2:]
-    return self.launchProcess(parts, failIfRunning)
-
-  # external function
-  # DEPRECATED: Use shell() or launchApplication() for new code
-  # returns:
-  #  success: output filename
-  #  failure: None
-  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
-    if cmd[0] == "am":
-      self.checkCmd(["shell"] + cmd)
-      return outputFile
-
-    acmd = ["shell", "am", "start", "-W"]
-    cmd = ' '.join(cmd).strip()
-    i = cmd.find(" ")
-    # SUT identifies the URL by looking for :\\ -- another strategy to consider
-    re_url = re.compile('^[http|file|chrome|about].*')
-    last = cmd.rfind(" ")
-    uri = ""
-    args = ""
-    if re_url.match(cmd[last:].strip()):
-      args = cmd[i:last].strip()
-      uri = cmd[last:].strip()
-    else:
-      args = cmd[i:].strip()
-    acmd.append("-n")
-    acmd.append(cmd[0:i] + "/.App")
-    if args != "":
-      acmd.append("--es")
-      acmd.append("args")
-      acmd.append(args)
-    if env != '' and env != None:
-      envCnt = 0
-      # env is expected to be a dict of environment variables
-      for envkey, envval in env.iteritems():
-        acmd.append("--es")
-        acmd.append("env" + str(envCnt))
-        acmd.append(envkey + "=" + envval);
-        envCnt += 1
-    if uri != "":
-      acmd.append("-d")
-      acmd.append(''.join(['\'',uri, '\'']));
-    print acmd
-    self.checkCmd(acmd)
-    return outputFile
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def killProcess(self, appname, forceKill=False):
-    procs = self.getProcessList()
-    didKillProcess = False
-    for (pid, name, user) in procs:
-      if name == appname:
-         args = ["shell", "kill"]
-         if forceKill:
-           args.append("-9")
-         args.append(pid)
-         p = self.runCmdAs(args)
-         p.communicate()
-         if p.returncode == 0:
-             didKillProcess = True
-
-    return didKillProcess
-
-  # external function
-  # returns:
-  #  success: filecontents
-  #  failure: None
-  def catFile(self, remoteFile):
-    #p = self.runCmd(["shell", "cat", remoteFile])
-    #return p.stdout.read()
-    return self.getFile(remoteFile)
-
-  # external function
-  # returns:
-  #  success: output of pullfile, string
-  #  failure: None
-  def pullFile(self, remoteFile):
-    #return self.catFile(remoteFile)
-    return self.getFile(remoteFile)
-
-  # copy file from device (remoteFile) to host (localFile)
-  # external function
-  # returns:
-  #  success: output of pullfile, string
-  #  failure: None
-  def getFile(self, remoteFile, localFile = 'tmpfile_dm_adb'):
-    # TODO: add debug flags and allow for printing stdout
-    # self.runCmd(["pull", remoteFile, localFile])
-    try:
-
-      # First attempt to pull file regularly
-      outerr = self.runCmd(["pull",  remoteFile, localFile]).communicate()
-
-      # Now check stderr for errors
-      if outerr[1]:
-        errl = outerr[1].splitlines()
-        if (len(errl) == 1):
-          if (((errl[0].find("Permission denied") != -1)
-            or (errl[0].find("does not exist") != -1))
-            and self.useRunAs):
-            # If we lack permissions to read but have run-as, then we should try
-            # to copy the file to a world-readable location first before attempting
-            # to pull it again.
-            remoteTmpFile = self.getTempDir() + "/" + os.path.basename(remoteFile)
-            self.checkCmdAs(["shell", "dd", "if=" + remoteFile, "of=" + remoteTmpFile])
-            self.checkCmdAs(["shell", "chmod", "777", remoteTmpFile])
-            self.runCmd(["pull",  remoteTmpFile, localFile]).stdout.read()
-            # Clean up temporary file
-            self.checkCmdAs(["shell", "rm", remoteTmpFile])
-
-      f = open(localFile)
-      ret = f.read()
-      f.close()
-      return ret
-    except:
-      return None
-
-  # copy directory structure from device (remoteDir) to host (localDir)
-  # external function
-  # checkDir exists so that we don't create local directories if the
-  # remote directory doesn't exist but also so that we don't call isDir
-  # twice when recursing.
-  # returns:
-  #  success: list of files, string
-  #  failure: None
-  def getDirectory(self, remoteDir, localDir, checkDir=True):
-    ret = []
-    p = self.runCmd(["pull", remoteDir, localDir])
-    p.stdout.readline()
-    line = p.stdout.readline()
-    while (line):
-      els = line.split()
-      f = els[len(els) - 1]
-      i = f.find(localDir)
-      if (i != -1):
-        if (localDir[len(localDir) - 1] != '/'):
-          i = i + 1
-        f = f[i + len(localDir):]
-      i = f.find("/")
-      if (i > 0):
-        f = f[0:i]
-      ret.append(f)
-      line =  p.stdout.readline()
-    #the last line is a summary
-    if (len(ret) > 0):
-      ret.pop()
-    return ret
-
-
-
-  # true/false check if the two files have the same md5 sum
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def validateFile(self, remoteFile, localFile):
-    return self.getRemoteHash(remoteFile) == self.getLocalHash(localFile)
-
-  # return the md5 sum of a remote file
-  # internal function
-  # returns:
-  #  success: MD5 hash for given filename
-  #  failure: None
-  def getRemoteHash(self, filename):
-    data = self.runCmd(["shell", "ls", "-l", filename]).stdout.read()
-    return data.split()[3]
-
-  def getLocalHash(self, filename):
-    data = subprocess.Popen(["ls", "-l", filename], stdout=subprocess.PIPE).stdout.read()
-    return data.split()[4]
-
-  # Internal method to setup the device root and cache its value
-  def setupDeviceRoot(self):
-    # if self.deviceRoot is already set, create it if necessary, and use it
-    if self.deviceRoot:
-      if not self.dirExists(self.deviceRoot):
-        if not self.mkDir(self.deviceRoot):
-          raise DMError("Unable to create device root %s" % self.deviceRoot)
-      return
-
-    # /mnt/sdcard/tests is preferred to /data/local/tests, but this can be
-    # over-ridden by creating /data/local/tests
-    testRoot = "/data/local/tests"
-    if (self.dirExists(testRoot)):
-      self.deviceRoot = testRoot
-      return
-
-    for (basePath, subPath) in [('/mnt/sdcard', 'tests'),
-                                ('/data/local', 'tests')]:
-      if self.dirExists(basePath):
-        testRoot = os.path.join(basePath, subPath)
-        if self.mkDir(testRoot):
-          self.deviceRoot = testRoot
-          return
-
-    raise DMError("Unable to set up device root as /mnt/sdcard/tests "
-                  "or /data/local/tests")
-
-  # Gets the device root for the testing area on the device
-  # For all devices we will use / type slashes and depend on the device-agent
-  # to sort those out.  The agent will return us the device location where we
-  # should store things, we will then create our /tests structure relative to
-  # that returned path.
-  # Structure on the device is as follows:
-  # /tests
-  #       /<fennec>|<firefox>  --> approot
-  #       /profile
-  #       /xpcshell
-  #       /reftest
-  #       /mochitest
-  #
-  # external function
-  # returns:
-  #  success: path for device root
-  #  failure: None
-  def getDeviceRoot(self):
-    return self.deviceRoot
-
-  # Gets the temporary directory we are using on this device
-  # base on our device root, ensuring also that it exists.
-  #
-  # internal function
-  # returns:
-  #  success: path for temporary directory
-  #  failure: None
-  def getTempDir(self):
-    # Cache result to speed up operations depending
-    # on the temporary directory.
-    if self.tempDir == None:
-      self.tempDir = self.getDeviceRoot() + "/tmp"
-      if (not self.dirExists(self.tempDir)):
-        return self.mkDir(self.tempDir)
-
-    return self.tempDir
-
-  # Either we will have /tests/fennec or /tests/firefox but we will never have
-  # both.  Return the one that exists
-  # TODO: ensure we can support org.mozilla.firefox
-  # external function
-  # returns:
-  #  success: path for app root
-  #  failure: None
-  def getAppRoot(self, packageName):
-    devroot = self.getDeviceRoot()
-    if (devroot == None):
-      return None
-
-    if (packageName and self.dirExists('/data/data/' + packageName)):
-      self.packageName = packageName
-      return '/data/data/' + packageName
-    elif (self.packageName and self.dirExists('/data/data/' + self.packageName)):
-      return '/data/data/' + self.packageName
-
-    # Failure (either not installed or not a recognized platform)
-    print "devicemanagerADB: getAppRoot failed"
-    return None
-
-  # Gets the directory location on the device for a specific test type
-  # Type is one of: xpcshell|reftest|mochitest
-  # external function
-  # returns:
-  #  success: path for test root
-  #  failure: None
-  def getTestRoot(self, type):
-    devroot = self.getDeviceRoot()
-    if (devroot == None):
-      return None
-
-    if (re.search('xpcshell', type, re.I)):
-      self.testRoot = devroot + '/xpcshell'
-    elif (re.search('?(i)reftest', type)):
-      self.testRoot = devroot + '/reftest'
-    elif (re.search('?(i)mochitest', type)):
-      self.testRoot = devroot + '/mochitest'
-    return self.testRoot
-
-
-  # external function
-  # returns:
-  #  success: status from test agent
-  #  failure: None
-  def reboot(self, wait = False):
-    ret = self.runCmd(["reboot"]).stdout.read()
-    if (not wait):
-      return "Success"
-    countdown = 40
-    while (countdown > 0):
-      countdown
-      try:
-        self.checkCmd(["wait-for-device", "shell", "ls", "/sbin"])
-        return ret
-      except:
-        try:
-          self.checkCmd(["root"])
-        except:
-          time.sleep(1)
-          print "couldn't get root"
-    return "Success"
-
-  # external function
-  # returns:
-  #  success: text status from command or callback server
-  #  failure: None
-  def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000):
-    return self.runCmd(["install", "-r", appBundlePath]).stdout.read()
-
-  # external function
-  # returns:
-  #  success: time in ms
-  #  failure: None
-  def getCurrentTime(self):
-    timestr = self.runCmd(["shell", "date", "+%s"]).stdout.read().strip()
-    if (not timestr or not timestr.isdigit()):
-        return None
-    return str(int(timestr)*1000)
-
-  # Returns information about the device:
-  # Directive indicates the information you want to get, your choices are:
-  # os - name of the os
-  # id - unique id of the device
-  # uptime - uptime of the device
-  # systime - system time of the device
-  # screen - screen resolution
-  # memory - memory stats
-  # process - list of running processes (same as ps)
-  # disk - total, free, available bytes on disk
-  # power - power status (charge, battery temp)
-  # all - all of them - or call it with no parameters to get all the information
-  ### Note that uptimemillis is NOT supported, as there is no way to get this
-  ### data from the shell.
-  # returns:
-  #   success: dict of info strings by directive name
-  #   failure: {}
-  def getInfo(self, directive="all"):
-    ret = {}
-    if (directive == "id" or directive == "all"):
-      ret["id"] = self.runCmd(["get-serialno"]).stdout.read()
-    if (directive == "os" or directive == "all"):
-      ret["os"] = self.runCmd(["shell", "getprop", "ro.build.display.id"]).stdout.read()
-    if (directive == "uptime" or directive == "all"):
-      utime = self.runCmd(["shell", "uptime"]).stdout.read()
-      if (not utime):
-        raise DMError("error getting uptime")
-      utime = utime[9:]
-      hours = utime[0:utime.find(":")]
-      utime = utime[utime[1:].find(":") + 2:]
-      minutes = utime[0:utime.find(":")]
-      utime = utime[utime[1:].find(":") +  2:]
-      seconds = utime[0:utime.find(",")]
-      ret["uptime"] = ["0 days " + hours + " hours " + minutes + " minutes " + seconds + " seconds"]
-    if (directive == "process" or directive == "all"):
-      ret["process"] = self.runCmd(["shell", "ps"]).stdout.read()
-    if (directive == "systime" or directive == "all"):
-      ret["systime"] = self.runCmd(["shell", "date"]).stdout.read()
-    print ret
-    return ret
-
-  def runCmd(self, args):
-    # If we are not root but have run-as, and we're trying to execute
-    # a shell command then using run-as is the best we can do
-    finalArgs = [self.adbPath]
-    if self.deviceSerial:
-      finalArgs.extend(['-s', self.deviceSerial])
-    if (not self.haveRoot and self.useRunAs and args[0] == "shell" and args[1] != "run-as"):
-      args.insert(1, "run-as")
-      args.insert(2, self.packageName)
-    finalArgs.extend(args)
-    return subprocess.Popen(finalArgs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
-  def runCmdAs(self, args):
-    if self.useRunAs:
-      args.insert(1, "run-as")
-      args.insert(2, self.packageName)
-    return self.runCmd(args)
-
-  # timeout is specified in seconds, and if no timeout is given, 
-  # we will run until the script returns
-  def checkCmd(self, args, timeout=None):
-    # If we are not root but have run-as, and we're trying to execute
-    # a shell command then using run-as is the best we can do
-    finalArgs = [self.adbPath]
-    if self.deviceSerial:
-      finalArgs.extend(['-s', self.deviceSerial])
-    if (not self.haveRoot and self.useRunAs and args[0] == "shell" and args[1] != "run-as"):
-      args.insert(1, "run-as")
-      args.insert(2, self.packageName)
-    finalArgs.extend(args)
-    if timeout:
-        timeout = int(timeout)
-        proc = subprocess.Popen(finalArgs)
-        start_time = time.time()
-        ret_code = proc.poll()
-        while ((time.time() - start_time) <= timeout) and ret_code == None:
-            time.sleep(1)
-            ret_code = proc.poll()
-        if ret_code == None:
-            proc.kill()
-            raise DMError("Timeout exceeded for checkCmd call")
-        return ret_code
-    return subprocess.check_call(finalArgs)
-
-  def checkCmdAs(self, args, timeout=None):
-    if (self.useRunAs):
-      args.insert(1, "run-as")
-      args.insert(2, self.packageName)
-    return self.checkCmd(args, timeout)
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def chmodDir(self, remoteDir):
-    if (self.isDir(remoteDir)):
-      files = self.listFiles(remoteDir.strip())
-      for f in files:
-        remoteEntry = remoteDir.strip() + "/" + f.strip()
-        if (self.isDir(remoteEntry)):
-          self.chmodDir(remoteEntry)
-        else:
-          self.checkCmdAs(["shell", "chmod", "777", remoteEntry])
-          print "chmod " + remoteEntry
-      self.checkCmdAs(["shell", "chmod", "777", remoteDir])
-      print "chmod " + remoteDir
-    else:
-      self.checkCmdAs(["shell", "chmod", "777", remoteDir.strip()])
-      print "chmod " + remoteDir.strip()
-    return True
-
-  def verifyADB(self):
-    # Check to see if adb itself can be executed.
-    if self.adbPath != 'adb':
-      if not os.access(self.adbPath, os.X_OK):
-        raise DMError("invalid adb path, or adb not executable: %s", self.adbPath)
-
-    try:
-      self.checkCmd(["version"])
-    except os.error, err:
-      raise DMError("unable to execute ADB (%s): ensure Android SDK is installed and adb is in your $PATH" % err)
-    except subprocess.CalledProcessError:
-      raise DMError("unable to execute ADB: ensure Android SDK is installed and adb is in your $PATH")
-
-  def verifyDevice(self):
-    # If there is a device serial number, see if adb is connected to it
-    if self.deviceSerial:
-      deviceStatus = None
-      proc = subprocess.Popen([self.adbPath, "devices"],
-                              stdout=subprocess.PIPE,
-                              stderr=subprocess.STDOUT)
-      for line in proc.stdout:
-        m = re.match('(.+)?\s+(.+)$', line)
-        if m:
-          if self.deviceSerial == m.group(1):
-            deviceStatus = m.group(2)
-      if deviceStatus == None:
-        raise DMError("device not found: %s" % self.deviceSerial)
-      elif deviceStatus != "device":
-        raise DMError("bad status for device %s: %s" % (self.deviceSerial,
-                                                        deviceStatus))
-
-    # Check to see if we can connect to device and run a simple command
-    try:
-      self.checkCmd(["shell", "echo"])
-    except subprocess.CalledProcessError:
-      raise DMError("unable to connect to device: is it plugged in?")
-
-  def verifyRoot(self):
-    # a test to see if we have root privs
-    p = self.runCmd(["shell", "id"])
-    response = p.stdout.readline()
-    response = response.rstrip()
-    response = response.split(' ')
-    if (response[0].find('uid=0') < 0 or response[1].find('gid=0') < 0):
-      print "NOT running as root ", response[0].find('uid=0')
-      raise DMError("not running as root")
-
-    self.haveRoot = True
-
-  def isCpAvailable(self):
-    # Some Android systems may not have a cp command installed,
-    # or it may not be executable by the user.
-    data = self.runCmd(["shell", "cp"]).stdout.read()
-    if (re.search('Usage', data)):
-      return True
-    else:
-      data = self.runCmd(["shell", "dd", "-"]).stdout.read()
-      if (re.search('unknown operand', data)):
-        print "'cp' not found, but 'dd' was found as a replacement"
-        self.useDDCopy = True
-        return True
-      print "unable to execute 'cp' on device; consider installing busybox from Android Market"
-      return False
-
-  def verifyRunAs(self):
-    # If a valid package name is available, and certain other
-    # conditions are met, devicemanagerADB can execute file operations
-    # via the "run-as" command, so that pushed files and directories 
-    # are created by the uid associated with the package, more closely
-    # echoing conditions encountered by Fennec at run time.
-    # Check to see if run-as can be used here, by verifying a 
-    # file copy via run-as.
-    self.useRunAs = False
-    devroot = self.getDeviceRoot()
-    if (self.packageName and self.isCpAvailable() and devroot):
-      tmpDir = self.getTempDir()
-
-      # The problem here is that run-as doesn't cause a non-zero exit code
-      # when failing because of a non-existent or non-debuggable package :(
-      runAsOut = self.runCmd(["shell", "run-as", self.packageName, "mkdir", devroot + "/sanity"]).communicate()[0]
-      if runAsOut.startswith("run-as:") and ("not debuggable" in runAsOut or
-                                             "is unknown" in runAsOut):
-        raise DMError("run-as failed sanity check")
-
-      tmpfile = tempfile.NamedTemporaryFile()
-      self.checkCmd(["push", tmpfile.name, tmpDir + "/tmpfile"])
-      if self.useDDCopy:
-        self.checkCmd(["shell", "run-as", self.packageName, "dd", "if=" + tmpDir + "/tmpfile", "of=" + devroot + "/sanity/tmpfile"])
-      else:
-        self.checkCmd(["shell", "run-as", self.packageName, "cp", tmpDir + "/tmpfile", devroot + "/sanity"])
-      if (self.fileExists(devroot + "/sanity/tmpfile")):
-        print "will execute commands via run-as " + self.packageName
-        self.useRunAs = True
-      self.checkCmd(["shell", "rm", devroot + "/tmp/tmpfile"])
-      self.checkCmd(["shell", "run-as", self.packageName, "rm", "-r", devroot + "/sanity"])
-
-  def isUnzipAvailable(self):
-    data = self.runCmdAs(["shell", "unzip"]).stdout.read()
-    if (re.search('Usage', data)):
-      return True
-    else:
-      return False
-
-  def isLocalZipAvailable(self):
-    try:
-      subprocess.check_call(["zip", "-?"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    except:
-      return False
-    return True
-
-  def verifyZip(self):
-    # If "zip" can be run locally, and "unzip" can be run remotely, then pushDir
-    # can use these to push just one file per directory -- a significant
-    # optimization for large directories.
-    self.useZip = False
-    if (self.isUnzipAvailable() and self.isLocalZipAvailable()):
-      print "will use zip to push directories"
-      self.useZip = True
-    else:
-      raise DMError("zip not available")
deleted file mode 100644
--- a/build/mobile/devicemanagerSUT.py
+++ /dev/null
@@ -1,1240 +0,0 @@
-# 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/.
-
-import select
-import socket
-import SocketServer
-import time
-import os
-import re
-import posixpath
-import subprocess
-from threading import Thread
-import StringIO
-from devicemanager import DeviceManager, FileError, NetworkTools, _pop_last_line
-import errno
-from distutils.version import StrictVersion
-
-class AgentError(Exception):
-  "SUTAgent-specific exception."
-
-  def __init__(self, msg= '', fatal = False):
-    self.msg = msg
-    self.fatal = fatal
-
-  def __str__(self):
-    return self.msg
-
-class DeviceManagerSUT(DeviceManager):
-  host = ''
-  port = 0
-  debug = 2
-  retries = 0
-  tempRoot = os.getcwd()
-  base_prompt = '$>'
-  base_prompt_re = '\$\>'
-  prompt_sep = '\x00'
-  prompt_regex = '.*(' + base_prompt_re + prompt_sep + ')'
-  agentErrorRE = re.compile('^##AGENT-WARNING##\ ?(.*)')
-
-  # TODO: member variable to indicate error conditions.
-  # This should be set to a standard error from the errno module.
-  # So, for example, when an error occurs because of a missing file/directory,
-  # before returning, the function would do something like 'self.error = errno.ENOENT'.
-  # The error would be set where appropriate--so sendCMD() could set socket errors,
-  # pushFile() and other file-related commands could set filesystem errors, etc.
-
-  def __init__(self, host, port = 20701, retrylimit = 5, deviceRoot = None):
-    self.host = host
-    self.port = port
-    self.retrylimit = retrylimit
-    self.retries = 0
-    self._sock = None
-    self.deviceRoot = deviceRoot
-    if self.getDeviceRoot() == None:
-      raise BaseException("Failed to connect to SUT Agent and retrieve the device root.")
-    try:
-      verstring = self.runCmds([{ 'cmd': 'ver' }])
-      self.agentVersion = re.sub('SUTAgentAndroid Version ', '', verstring)
-    except AgentError, err:
-      raise BaseException("Failed to get SUTAgent version")
-
-  def _cmdNeedsResponse(self, cmd):
-    """ Not all commands need a response from the agent:
-        * rebt obviously doesn't get a response
-        * uninstall performs a reboot to ensure starting in a clean state and
-          so also doesn't look for a response
-    """
-    noResponseCmds = [re.compile('^rebt'),
-                      re.compile('^uninst .*$'),
-                      re.compile('^pull .*$')]
-
-    for c in noResponseCmds:
-      if (c.match(cmd)):
-        return False
-
-    # If the command is not in our list, then it gets a response
-    return True
-
-  def _stripPrompt(self, data):
-    '''
-    internal function
-    take a data blob and strip instances of the prompt '$>\x00'
-    '''
-    promptre = re.compile(self.prompt_regex + '.*')
-    retVal = []
-    lines = data.split('\n')
-    for line in lines:
-      foundPrompt = False
-      try:
-        while (promptre.match(line)):
-          foundPrompt = True
-          pieces = line.split(self.prompt_sep)
-          index = pieces.index('$>')
-          pieces.pop(index)
-          line = self.prompt_sep.join(pieces)
-      except(ValueError):
-        pass
-
-      # we don't want to append lines that are blank after stripping the
-      # prompt (those are basically "prompts")
-      if not foundPrompt or line:
-        retVal.append(line)
-
-    return '\n'.join(retVal)
-
-  def _shouldCmdCloseSocket(self, cmd):
-    """ Some commands need to close the socket after they are sent:
-    * rebt
-    * uninst
-    * quit
-    """
-    socketClosingCmds = [re.compile('^quit.*'),
-                         re.compile('^rebt.*'),
-                         re.compile('^uninst .*$')]
-
-    for c in socketClosingCmds:
-      if (c.match(cmd)):
-        return True
-
-    return False
-
-  def sendCmds(self, cmdlist, outputfile, timeout = None):
-    '''
-    a wrapper for _doCmds that loops up to self.retrylimit iterations.
-    this allows us to move the retry logic outside of the _doCmds() to make it
-    easier for debugging in the future.
-    note that since cmdlist is a list of commands, they will all be retried if
-    one fails.  this is necessary in particular for pushFile(), where we don't want
-    to accidentally send extra data if a failure occurs during data transmission.
-    '''
-    if timeout:
-      raise NotImplementedError("'timeout' parameter is not yet supported")
-    while self.retries < self.retrylimit:
-      try:
-        self._doCmds(cmdlist, outputfile, timeout)
-        return
-      except AgentError, err:
-        # re-raise error if it's fatal (i.e. the device got the command but
-        # couldn't execute it). retry otherwise
-        if err.fatal:
-          raise err
-        if self.debug >= 2:
-          print err
-        self.retries += 1
-
-    raise AgentError("unable to connect to %s after %s attempts" % (self.host, self.retrylimit))
-
-  def runCmds(self, cmdlist, timeout = None):
-    '''
-    similar to sendCmds, but just returns any output as a string instead of
-    writing to a file. this is normally what you want to call to send a set
-    of commands to the agent
-    '''
-    outputfile = StringIO.StringIO()
-    self.sendCmds(cmdlist, outputfile, timeout)
-    outputfile.seek(0)
-    return outputfile.read()
-
-  def _doCmds(self, cmdlist, outputfile, timeout):
-    promptre = re.compile(self.prompt_regex + '$')
-    shouldCloseSocket = False
-    recvGuard = 1000
-
-    if not self._sock:
-      try:
-        if self.debug >= 1:
-          print "reconnecting socket"
-        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-      except socket.error, msg:
-        self._sock = None
-        raise AgentError("unable to create socket: "+str(msg))
-
-      try:
-        self._sock.connect((self.host, int(self.port)))
-        self._sock.recv(1024)
-      except socket.error, msg:
-        self._sock.close()
-        self._sock = None
-        raise AgentError("unable to connect socket: "+str(msg))
-
-    for cmd in cmdlist:
-      cmdline = '%s\r\n' % cmd['cmd']
-
-      try:
-        sent = self._sock.send(cmdline)
-        if sent != len(cmdline):
-          raise AgentError("ERROR: our cmd was %s bytes and we "
-                           "only sent %s" % (len(cmdline), sent))
-        if cmd.get('data'):
-          sent = self._sock.send(cmd['data'])
-          if sent != len(cmd['data']):
-              raise AgentError("ERROR: we had %s bytes of data to send, but "
-                               "only sent %s" % (len(cmd['data']), sent))
-
-        if (self.debug >= 4): print "sent cmd: " + str(cmd['cmd'])
-      except socket.error, msg:
-        self._sock.close()
-        self._sock = None
-        if self.debug >= 1:
-          print "Error sending data to socket. cmd="+str(cmd['cmd'])+"; err="+str(msg)
-        return False
-
-      # Check if the command should close the socket
-      shouldCloseSocket = self._shouldCmdCloseSocket(cmd['cmd'])
-
-      # Handle responses from commands
-      if (self._cmdNeedsResponse(cmd['cmd'])):
-        found = False
-        loopguard = 0
-        data = ""
-
-        while (found == False and (loopguard < recvGuard)):
-          temp = ''
-          if (self.debug >= 4): print "recv'ing..."
-
-          # Get our response
-          try:
-             # Wait up to a second for socket to become ready for reading...
-            if select.select([self._sock], [], [], 1)[0]:
-                temp = self._sock.recv(1024)
-            if (self.debug >= 4): print "response: " + str(temp)
-          except socket.error, err:
-            self._sock.close()
-            self._sock = None
-            # This error shows up with we have our tegra rebooted.
-            if err[0] == errno.ECONNRESET:
-              raise AgentError("Automation error: Error receiving data from socket (possible reboot). cmd=%s; err=%s" % (cmd, err))
-            raise AgentError("Error receiving data from socket. cmd=%s; err=%s" % (cmd, err))
-
-          data += temp
-
-          # If something goes wrong in the agent it will send back a string that
-          # starts with '##AGENT-WARNING##'
-          errorMatch = self.agentErrorRE.match(data)
-          if errorMatch:
-            raise AgentError("Agent Error processing command '%s'; err='%s'" %
-                             (cmd['cmd'], errorMatch.group(1)), fatal=True)
-
-          for line in data.splitlines():
-            if promptre.match(line):
-              found = True
-              data = self._stripPrompt(data)
-              break
-
-          # periodically flush data to output file to make sure it doesn't get
-          # too big/unwieldly
-          if len(data) > 1024:
-              outputfile.write(data[0:1024])
-              data = data[1024:]
-
-          # If we violently lose the connection to the device, this loop tends to spin,
-          # this guard prevents that
-          if (temp == ''):
-            loopguard += 1
-
-        # Write any remaining data to outputfile
-        outputfile.write(data)
-
-    if shouldCloseSocket:
-      try:
-        self._sock.close()
-        self._sock = None
-      except:
-        self._sock = None
-        raise AgentError("Error closing socket")
-
-  # external function: executes shell command on device
-  # returns:
-  # success: <return code>
-  # failure: None
-  def shell(self, cmd, outputfile, env=None, cwd=None, timeout=None, root=False):
-    cmdline = self._escapedCommandLine(cmd)
-    if env:
-      cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
-
-    haveExecSu = (StrictVersion(self.agentVersion) >= StrictVersion('1.13'))
-
-    # Depending on agent version we send one of the following commands here:
-    # * exec (run as normal user)
-    # * execsu (run as privileged user)
-    # * execcwd (run as normal user from specified directory)
-    # * execcwdsu (run as privileged user from specified directory)
-
-    cmd = "exec"
-    if cwd:
-      cmd += "cwd"
-    if root and haveExecSu:
-      cmd += "su"
-
-    try:
-      if cwd:
-        self.sendCmds([{ 'cmd': '%s %s %s' % (cmd, cwd, cmdline) }], outputfile, timeout)
-      else:
-        if (not root) or haveExecSu:
-          self.sendCmds([{ 'cmd': '%s %s' % (cmd, cmdline) }], outputfile, timeout)
-        else:
-          # need to manually inject su -c for backwards compatibility (this may
-          # not work on ICS or above!!)
-          # (FIXME: this backwards compatibility code is really ugly and should
-          # be deprecated at some point in the future)
-          self.sendCmds([ { 'cmd': '%s su -c "%s"' % (cmd, cmdline) }], outputfile,
-                          timeout)
-    except AgentError:
-      return None
-
-    # dig through the output to get the return code
-    lastline = _pop_last_line(outputfile)
-    if lastline:
-      m = re.search('return code \[([0-9]+)\]', lastline)
-      if m:
-        return int(m.group(1))
-
-    # woops, we couldn't find an end of line/return value
-    return None
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def pushFile(self, localname, destname):
-    if (os.name == "nt"):
-      destname = destname.replace('\\', '/')
-
-    if (self.debug >= 3): print "in push file with: " + localname + ", and: " + destname
-    if (self.dirExists(destname)):
-      if (not destname.endswith('/')):
-        destname = destname + '/'
-      destname = destname + os.path.basename(localname)
-    if (self.validateFile(destname, localname) == True):
-      if (self.debug >= 3): print "files are validated"
-      return True
-
-    if self.mkDirs(destname) == None:
-      print "unable to make dirs: " + destname
-      return False
-
-    if (self.debug >= 3): print "sending: push " + destname
-
-    filesize = os.path.getsize(localname)
-    f = open(localname, 'rb')
-    data = f.read()
-    f.close()
-
-    try:
-      retVal = self.runCmds([{ 'cmd': 'push ' + destname + ' ' + str(filesize),
-                               'data': data }])
-    except AgentError, e:
-      print "error pushing file: %s" % e.msg
-      return False
-
-    if (self.debug >= 3): print "push returned: " + str(retVal)
-
-    validated = False
-    if (retVal):
-      retline = retVal.strip()
-      if (retline == None):
-        # Then we failed to get back a hash from agent, try manual validation
-        validated = self.validateFile(destname, localname)
-      else:
-        # Then we obtained a hash from push
-        localHash = self.getLocalHash(localname)
-        if (str(localHash) == str(retline)):
-          validated = True
-    else:
-      # We got nothing back from sendCMD, try manual validation
-      validated = self.validateFile(destname, localname)
-
-    if (validated):
-      if (self.debug >= 3): print "Push File Validated!"
-      return True
-    else:
-      if (self.debug >= 2): print "Push File Failed to Validate!"
-      return False
-
-  # external function
-  # returns:
-  #  success: directory name
-  #  failure: None
-  def mkDir(self, name):
-    if (self.dirExists(name)):
-      return name
-    else:
-      try:
-        retVal = self.runCmds([{ 'cmd': 'mkdr ' + name }])
-      except AgentError:
-        retVal = None
-      return retVal
-
-  # push localDir from host to remoteDir on the device
-  # external function
-  # returns:
-  #  success: remoteDir
-  #  failure: None
-  def pushDir(self, localDir, remoteDir):
-    if (self.debug >= 2): print "pushing directory: %s to %s" % (localDir, remoteDir)
-    for root, dirs, files in os.walk(localDir, followlinks=True):
-      parts = root.split(localDir)
-      for file in files:
-        remoteRoot = remoteDir + '/' + parts[1]
-        if (remoteRoot.endswith('/')):
-          remoteName = remoteRoot + file
-        else:
-          remoteName = remoteRoot + '/' + file
-        if (parts[1] == ""): remoteRoot = remoteDir
-        if (self.pushFile(os.path.join(root, file), remoteName) == False):
-          # retry once
-          self.removeFile(remoteName)
-          if (self.pushFile(os.path.join(root, file), remoteName) == False):
-            return None
-    return remoteDir
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def dirExists(self, dirname):
-    match = ".*" + dirname.replace('^', '\^') + "$"
-    dirre = re.compile(match)
-    try:
-      data = self.runCmds([ { 'cmd': 'cd ' + dirname }, { 'cmd': 'cwd' }])
-    except AgentError:
-      return False
-
-    found = False
-    for d in data.splitlines():
-      if (dirre.match(d)):
-        found = True
-
-    return found
-
-  # Because we always have / style paths we make this a lot easier with some
-  # assumptions
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def fileExists(self, filepath):
-    s = filepath.split('/')
-    containingpath = '/'.join(s[:-1])
-    listfiles = self.listFiles(containingpath)
-    for f in listfiles:
-      if (f == s[-1]):
-        return True
-    return False
-
-  # list files on the device, requires cd to directory first
-  # external function
-  # returns:
-  #  success: array of filenames, ['file1', 'file2', ...]
-  #  failure: []
-  def listFiles(self, rootdir):
-    rootdir = rootdir.rstrip('/')
-    if (self.dirExists(rootdir) == False):
-      return []
-    try:
-      data = self.runCmds([{ 'cmd': 'cd ' + rootdir }, { 'cmd': 'ls' }])
-    except AgentError:
-      return []
-
-    files = filter(lambda x: x, data.splitlines())
-    if len(files) == 1 and files[0] == '<empty>':
-      # special case on the agent: empty directories return just the string "<empty>"
-      return []
-    return files
-
-  # external function
-  # returns:
-  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
-  #  failure: None
-  def removeFile(self, filename):
-    if (self.debug>= 2): print "removing file: " + filename
-    try:
-      retVal = self.runCmds([{ 'cmd': 'rm ' + filename }])
-    except AgentError:
-      return None
-
-    return retVal
-
-  # does a recursive delete of directory on the device: rm -Rf remoteDir
-  # external function
-  # returns:
-  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
-  #  failure: None
-  def removeDir(self, remoteDir):
-    try:
-      retVal = self.runCmds([{ 'cmd': 'rmdr ' + remoteDir }])
-    except AgentError:
-      return None
-
-    return retVal
-
-  # external function
-  # returns:
-  #  success: array of process tuples
-  #  failure: []
-  def getProcessList(self):
-    try:
-      data = self.runCmds([{ 'cmd': 'ps' }])
-    except AgentError:
-      return []
-
-    files = []
-    for line in data.splitlines():
-      if line:
-        pidproc = line.strip().split()
-        if (len(pidproc) == 2):
-          files += [[pidproc[0], pidproc[1]]]
-        elif (len(pidproc) == 3):
-          #android returns <userID> <procID> <procName>
-          files += [[pidproc[1], pidproc[2], pidproc[0]]]
-    return files
-
-  # external function
-  # DEPRECATED: Use shell() or launchApplication() for new code
-  # returns:
-  #  success: pid
-  #  failure: None
-  def fireProcess(self, appname, failIfRunning=False):
-    if (not appname):
-      if (self.debug >= 1): print "WARNING: fireProcess called with no command to run"
-      return None
-
-    if (self.debug >= 2): print "FIRE PROC: '" + appname + "'"
-
-    if (self.processExist(appname) != None):
-      print "WARNING: process %s appears to be running already\n" % appname
-      if (failIfRunning):
-        return None
-
-    try:
-      self.runCmds([{ 'cmd': 'exec ' + appname }])
-    except AgentError:
-      return None
-
-    # The 'exec' command may wait for the process to start and end, so checking
-    # for the process here may result in process = None.
-    process = self.processExist(appname)
-    if (self.debug >= 4): print "got pid: %s for process: %s" % (process, appname)
-
-    return process
-
-  # external function
-  # DEPRECATED: Use shell() or launchApplication() for new code
-  # returns:
-  #  success: output filename
-  #  failure: None
-  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
-    if not cmd:
-      if (self.debug >= 1): print "WARNING: launchProcess called without command to run"
-      return None
-
-    cmdline = subprocess.list2cmdline(cmd)
-    if (outputFile == "process.txt" or outputFile == None):
-      outputFile = self.getDeviceRoot();
-      if outputFile is None:
-        return None
-      outputFile += "/process.txt"
-      cmdline += " > " + outputFile
-
-    # Prepend our env to the command
-    cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
-
-    if self.fireProcess(cmdline, failIfRunning) is None:
-      return None
-    return outputFile
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def killProcess(self, appname, forceKill=False):
-    if forceKill:
-      print "WARNING: killProcess(): forceKill parameter unsupported on SUT"
-    try:
-      self.runCmds([{ 'cmd': 'kill ' + appname }])
-    except AgentError:
-      return False
-
-    return True
-
-  # external function
-  # returns:
-  #  success: tmpdir, string
-  #  failure: None
-  def getTempDir(self):
-    try:
-      data = self.runCmds([{ 'cmd': 'tmpd' }])
-    except AgentError:
-      return None
-
-    return data.strip()
-
-  # external function
-  # returns:
-  #  success: filecontents
-  #  failure: None
-  def catFile(self, remoteFile):
-    try:
-      data = self.runCmds([{ 'cmd': 'cat ' + remoteFile }])
-    except AgentError:
-      return None
-
-    return data
-
-  # external function
-  # returns:
-  #  success: output of pullfile, string
-  #  failure: None
-  def pullFile(self, remoteFile):
-    """Returns contents of remoteFile using the "pull" command.
-    The "pull" command is different from other commands in that DeviceManager
-    has to read a certain number of bytes instead of just reading to the
-    next prompt.  This is more robust than the "cat" command, which will be
-    confused if the prompt string exists within the file being catted.
-    However it means we can't use the response-handling logic in sendCMD().
-    """
-
-    def err(error_msg):
-        err_str = 'error returned from pull: %s' % error_msg
-        print err_str
-        self._sock = None
-        raise FileError(err_str)
-
-    # FIXME: We could possibly move these socket-reading functions up to
-    # the class level if we wanted to refactor sendCMD().  For now they are
-    # only used to pull files.
-
-    def uread(to_recv, error_msg):
-      """ unbuffered read """
-      try:
-        data = self._sock.recv(to_recv)
-        if not data:
-          err(error_msg)
-          return None
-        return data
-      except:
-        err(error_msg)
-        return None
-
-    def read_until_char(c, buffer, error_msg):
-      """ read until 'c' is found; buffer rest """
-      while not '\n' in buffer:
-        data = uread(1024, error_msg)
-        if data == None:
-          err(error_msg)
-          return ('', '', '')
-        buffer += data
-      return buffer.partition(c)
-
-    def read_exact(total_to_recv, buffer, error_msg):
-      """ read exact number of 'total_to_recv' bytes """
-      while len(buffer) < total_to_recv:
-        to_recv = min(total_to_recv - len(buffer), 1024)
-        data = uread(to_recv, error_msg)
-        if data == None:
-          return None
-        buffer += data
-      return buffer
-
-    prompt = self.base_prompt + self.prompt_sep
-    buffer = ''
-
-    # expected return value:
-    # <filename>,<filesize>\n<filedata>
-    # or, if error,
-    # <filename>,-1\n<error message>
-    try:
-      # just send the command first, we read the response inline below
-      self.runCmds([{ 'cmd': 'pull ' + remoteFile }])
-    except AgentError:
-      return None
-
-    # read metadata; buffer the rest
-    metadata, sep, buffer = read_until_char('\n', buffer, 'could not find metadata')
-    if not metadata:
-      return None
-    if self.debug >= 3:
-      print 'metadata: %s' % metadata
-
-    filename, sep, filesizestr = metadata.partition(',')
-    if sep == '':
-      err('could not find file size in returned metadata')
-      return None
-    try:
-        filesize = int(filesizestr)
-    except ValueError:
-      err('invalid file size in returned metadata')
-      return None
-
-    if filesize == -1:
-      # read error message
-      error_str, sep, buffer = read_until_char('\n', buffer, 'could not find error message')
-      if not error_str:
-        return None
-      # prompt should follow
-      read_exact(len(prompt), buffer, 'could not find prompt')
-      print "DeviceManager: error pulling file '%s': %s" % (remoteFile, error_str)
-      return None
-
-    # read file data
-    total_to_recv = filesize + len(prompt)
-    buffer = read_exact(total_to_recv, buffer, 'could not get all file data')
-    if buffer == None:
-      return None
-    if buffer[-len(prompt):] != prompt:
-      err('no prompt found after file data--DeviceManager may be out of sync with agent')
-      return buffer
-    return buffer[:-len(prompt)]
-
-  # copy file from device (remoteFile) to host (localFile)
-  # external function
-  # returns:
-  #  success: output of pullfile, string
-  #  failure: None
-  def getFile(self, remoteFile, localFile = ''):
-    if localFile == '':
-      localFile = os.path.join(self.tempRoot, "temp.txt")
-
-    try:
-      retVal = self.pullFile(remoteFile)
-    except:
-      return None
-
-    if (retVal is None):
-      return None
-
-    fhandle = open(localFile, 'wb')
-    fhandle.write(retVal)
-    fhandle.close()
-    if not self.validateFile(remoteFile, localFile):
-      print 'failed to validate file when downloading %s!' % remoteFile
-      return None
-    return retVal
-
-  # copy directory structure from device (remoteDir) to host (localDir)
-  # external function
-  # checkDir exists so that we don't create local directories if the
-  # remote directory doesn't exist but also so that we don't call isDir
-  # twice when recursing.
-  # returns:
-  #  success: list of files, string
-  #  failure: None
-  def getDirectory(self, remoteDir, localDir, checkDir=True):
-    if (self.debug >= 2): print "getting files in '" + remoteDir + "'"
-    if checkDir:
-      try:
-        is_dir = self.isDir(remoteDir)
-      except FileError:
-        return None
-      if not is_dir:
-        return None
-
-    filelist = self.listFiles(remoteDir)
-    if (self.debug >= 3): print filelist
-    if not os.path.exists(localDir):
-      os.makedirs(localDir)
-
-    for f in filelist:
-      if f == '.' or f == '..':
-        continue
-      remotePath = remoteDir + '/' + f
-      localPath = os.path.join(localDir, f)
-      try:
-        is_dir = self.isDir(remotePath)
-      except FileError:
-        print 'isdir failed on file "%s"; continuing anyway...' % remotePath
-        continue
-      if is_dir:
-        if (self.getDirectory(remotePath, localPath, False) == None):
-          print 'failed to get directory "%s"' % remotePath
-          return None
-      else:
-        # It's sometimes acceptable to have getFile() return None, such as
-        # when the agent encounters broken symlinks.
-        # FIXME: This should be improved so we know when a file transfer really
-        # failed.
-        if self.getFile(remotePath, localPath) == None:
-          print 'failed to get file "%s"; continuing anyway...' % remotePath
-    return filelist
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  #  Throws a FileError exception when null (invalid dir/filename)
-  def isDir(self, remotePath):
-    try:
-      data = self.runCmds([{ 'cmd': 'isdir ' + remotePath }])
-    except AgentError:
-      # normally there should be no error here; a nonexistent file/directory will
-      # return the string "<filename>: No such file or directory".
-      # However, I've seen AGENT-WARNING returned before.
-      return False
-
-    retVal = data.strip()
-    if not retVal:
-      raise FileError('isdir returned null')
-    return retVal == 'TRUE'
-
-  # true/false check if the two files have the same md5 sum
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def validateFile(self, remoteFile, localFile):
-    remoteHash = self.getRemoteHash(remoteFile)
-    localHash = self.getLocalHash(localFile)
-
-    if (remoteHash == None):
-      return False
-
-    if (remoteHash == localHash):
-      return True
-
-    return False
-
-  # return the md5 sum of a remote file
-  # internal function
-  # returns:
-  #  success: MD5 hash for given filename
-  #  failure: None
-  def getRemoteHash(self, filename):
-    try:
-      data = self.runCmds([{ 'cmd': 'hash ' + filename }])
-    except AgentError:
-      return None
-
-    retVal = None
-    if data:
-      retVal = data.strip()
-    if self.debug >= 3:
-      print "remote hash returned: '%s'" % retVal
-    return retVal
-
-  # Gets the device root for the testing area on the device
-  # For all devices we will use / type slashes and depend on the device-agent
-  # to sort those out.  The agent will return us the device location where we
-  # should store things, we will then create our /tests structure relative to
-  # that returned path.
-  # Structure on the device is as follows:
-  # /tests
-  #       /<fennec>|<firefox>  --> approot
-  #       /profile
-  #       /xpcshell
-  #       /reftest
-  #       /mochitest
-  #
-  # external function
-  # returns:
-  #  success: path for device root
-  #  failure: None
-  def getDeviceRoot(self):
-    if self.deviceRoot:
-      deviceRoot = self.deviceRoot
-    else:
-      try:
-        data = self.runCmds([{ 'cmd': 'testroot' }])
-      except:
-        return None
-
-      deviceRoot = data.strip() + '/tests'
-
-    if (not self.dirExists(deviceRoot)):
-      if (self.mkDir(deviceRoot) == None):
-        return None
-
-    self.deviceRoot = deviceRoot
-    return self.deviceRoot
-
-  def getAppRoot(self, packageName):
-    try:
-      data = self.runCmds([{ 'cmd': 'getapproot '+packageName }])
-    except:
-      return None
-
-    return data.strip()
-
-  # external function
-  # returns:
-  #  success: output of unzip command
-  #  failure: None
-  def unpackFile(self, file_path, dest_dir=None):
-    devroot = self.getDeviceRoot()
-    if (devroot == None):
-      return None
-
-    # if no dest_dir is passed in just set it to file_path's folder
-    if not dest_dir:
-      dest_dir = posixpath.dirname(file_path)
-
-    if dest_dir[-1] != '/':
-      dest_dir += '/'
-
-    try:
-      data = self.runCmds([{ 'cmd': 'unzp %s %s' % (file_path, dest_dir)}])
-    except AgentError:
-      return None
-
-    return data
-
-  # external function
-  # returns:
-  #  success: status from test agent
-  #  failure: None
-  def reboot(self, ipAddr=None, port=30000):
-    cmd = 'rebt'
-
-    if (self.debug > 3): print "INFO: sending rebt command"
-
-    if (ipAddr is not None):
-    #create update.info file:
-      try:
-        destname = '/data/data/com.mozilla.SUTAgentAndroid/files/update.info'
-        data = "%s,%s\rrebooting\r" % (ipAddr, port)
-        self.runCmds([{ 'cmd': 'push %s %s' % (destname, len(data)),
-                        'data': data }])
-      except AgentError:
-        return None
-
-      ip, port = self.getCallbackIpAndPort(ipAddr, port)
-      cmd += " %s %s" % (ip, port)
-      # Set up our callback server
-      callbacksvr = callbackServer(ip, port, self.debug)
-
-    try:
-      status = self.runCmds([{ 'cmd': cmd }])
-    except AgentError:
-      return None
-
-    if (ipAddr is not None):
-      status = callbacksvr.disconnect()
-
-    if (self.debug > 3): print "INFO: rebt- got status back: " + str(status)
-    return status
-
-  # Returns information about the device:
-  # Directive indicates the information you want to get, your choices are:
-  # os - name of the os
-  # id - unique id of the device
-  # uptime - uptime of the device
-  # uptimemillis - uptime of the device in milliseconds (SUTAgent 1.11+)
-  # systime - system time of the device
-  # screen - screen resolution
-  # rotation - rotation of the device (in degrees)
-  # memory - memory stats
-  # process - list of running processes (same as ps)
-  # disk - total, free, available bytes on disk
-  # power - power status (charge, battery temp)
-  # all - all of them - or call it with no parameters to get all the information
-  # returns:
-  #   success: dict of info strings by directive name
-  #   failure: {}
-  def getInfo(self, directive=None):
-    data = None
-    result = {}
-    collapseSpaces = re.compile('  +')
-
-    directives = ['os','id','uptime','uptimemillis','systime','screen',
-                  'rotation','memory','process','disk','power']
-    if (directive in directives):
-      directives = [directive]
-
-    for d in directives:
-      try:
-        data = self.runCmds([{ 'cmd': 'info ' + d }])
-      except AgentError:
-        return result
-
-      if (data is None):
-        continue
-      data = collapseSpaces.sub(' ', data)
-      result[d] = data.split('\n')
-
-    # Get rid of any 0 length members of the arrays
-    for k, v in result.iteritems():
-      result[k] = filter(lambda x: x != '', result[k])
-
-    # Format the process output
-    if 'process' in result:
-      proclist = []
-      for l in result['process']:
-        if l:
-          proclist.append(l.split('\t'))
-      result['process'] = proclist
-
-    if (self.debug >= 3): print "results: " + str(result)
-    return result
-
-  """
-  Installs the application onto the device
-  Application bundle - path to the application bundle on the device
-  Destination - destination directory of where application should be
-                installed to (optional)
-  Returns None for success, or output if known failure
-  """
-  # external function
-  # returns:
-  #  success: output from agent for inst command
-  #  failure: None
-  def installApp(self, appBundlePath, destPath=None):
-    cmd = 'inst ' + appBundlePath
-    if destPath:
-      cmd += ' ' + destPath
-    try:
-      data = self.runCmds([{ 'cmd': cmd }])
-    except AgentError:
-      return None
-
-    f = re.compile('Failure')
-    for line in data.split():
-      if (f.match(line)):
-        return data
-    return None
-
-  """
-  Uninstalls the named application from device and causes a reboot.
-  Takes an optional argument of installation path - the path to where the application
-  was installed.
-  Returns True, but it doesn't mean anything other than the command was sent,
-  the reboot happens and we don't know if this succeeds or not.
-  """
-  # external function
-  # returns:
-  #  success: True
-  #  failure: None
-  def uninstallAppAndReboot(self, appName, installPath=None):
-    cmd = 'uninst ' + appName
-    if installPath:
-      cmd += ' ' + installPath
-    try:
-      data = self.runCmds([{ 'cmd': cmd }])
-    except AgentError:
-      return None
-
-    if (self.debug > 3): print "uninstallAppAndReboot: " + str(data)
-    return True
-
-  """
-  Updates the application on the device.
-  Application bundle - path to the application bundle on the device
-  Process name of application - used to end the process if the applicaiton is
-                                currently running
-  Destination - Destination directory to where the application should be
-                installed (optional)
-  ipAddr - IP address to await a callback ping to let us know that the device has updated
-           properly - defaults to current IP.
-  port - port to await a callback ping to let us know that the device has updated properly
-         defaults to 30000, and counts up from there if it finds a conflict
-  Returns True if succeeds, False if not
-  """
-  # external function
-  # returns:
-  #  success: text status from command or callback server
-  #  failure: None
-  def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000):
-    status = None
-    cmd = 'updt '
-    if (processName == None):
-      # Then we pass '' for processName
-      cmd += "'' " + appBundlePath
-    else:
-      cmd += processName + ' ' + appBundlePath
-
-    if (destPath):
-      cmd += " " + destPath
-
-    if (ipAddr is not None):
-      ip, port = self.getCallbackIpAndPort(ipAddr, port)
-      cmd += " %s %s" % (ip, port)
-      # Set up our callback server
-      callbacksvr = callbackServer(ip, port, self.debug)
-
-    if (self.debug >= 3): print "INFO: updateApp using command: " + str(cmd)
-
-    try:
-      status = self.runCmds([{ 'cmd': cmd }])
-    except AgentError:
-      return None
-
-    if ipAddr is not None:
-      status = callbacksvr.disconnect()
-
-    if (self.debug >= 3): print "INFO: updateApp: got status back: " + str(status)
-
-    return status
-
-  """
-    return the current time on the device
-  """
-  # external function
-  # returns:
-  #  success: time in ms
-  #  failure: None
-  def getCurrentTime(self):
-    try:
-      data = self.runCmds([{ 'cmd': 'clok' }])
-    except AgentError:
-      return None
-
-    return data.strip()
-
-  """
-    Connect the ipaddress and port for a callback ping.  Defaults to current IP address
-    And ports starting at 30000.
-    NOTE: the detection for current IP address only works on Linux!
-  """
-  def getCallbackIpAndPort(self, aIp, aPort):
-    ip = aIp
-    nettools = NetworkTools()
-    if (ip == None):
-      ip = nettools.getLanIp()
-    if (aPort != None):
-      port = nettools.findOpenPort(ip, aPort)
-    else:
-      port = nettools.findOpenPort(ip, 30000)
-    return ip, port
-
-  """
-    Returns a properly formatted env string for the agent.
-    Input - env, which is either None, '', or a dict
-    Output - a quoted string of the form: '"envvar1=val1,envvar2=val2..."'
-    If env is None or '' return '' (empty quoted string)
-  """
-  def formatEnvString(self, env):
-    if (env == None or env == ''):
-      return ''
-
-    retVal = '"%s"' % ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems()))
-    if (retVal == '""'):
-      return ''
-
-    return retVal
-
-  """
-    adjust the screen resolution on the device, REBOOT REQUIRED
-    NOTE: this only works on a tegra ATM
-    success: True
-    failure: False
-
-    supported resolutions: 640x480, 800x600, 1024x768, 1152x864, 1200x1024, 1440x900, 1680x1050, 1920x1080
-  """
-  def adjustResolution(self, width=1680, height=1050, type='hdmi'):
-    if self.getInfo('os')['os'][0].split()[0] != 'harmony-eng':
-      if (self.debug >= 2): print "WARNING: unable to adjust screen resolution on non Tegra device"
-      return False
-
-    results = self.getInfo('screen')
-    parts = results['screen'][0].split(':')
-    if (self.debug >= 3): print "INFO: we have a current resolution of %s, %s" % (parts[1].split()[0], parts[2].split()[0])
-
-    #verify screen type is valid, and set it to the proper value (https://bugzilla.mozilla.org/show_bug.cgi?id=632895#c4)
-    screentype = -1
-    if (type == 'hdmi'):
-      screentype = 5
-    elif (type == 'vga' or type == 'crt'):
-      screentype = 3
-    else:
-      return False
-
-    #verify we have numbers
-    if not (isinstance(width, int) and isinstance(height, int)):
-      return False
-
-    if (width < 100 or width > 9999):
-      return False
-
-    if (height < 100 or height > 9999):
-      return False
-
-    if (self.debug >= 3): print "INFO: adjusting screen resolution to %s, %s and rebooting" % (width, height)
-    try:
-      self.runCmds([{ 'cmd': "exec setprop persist.tegra.dpy%s.mode.width %s" % (screentype, width) }])
-      self.runCmds([{ 'cmd': "exec setprop persist.tegra.dpy%s.mode.height %s" % (screentype, height) }])
-    except AgentError:
-      return False
-
-    return True
-
-  # external function
-  # returns:
-  #  success: True
-  #  failure: False
-  def chmodDir(self, remoteDir):
-    try:
-      self.runCmds([{ 'cmd': "chmod "+remoteDir }])
-    except AgentError:
-      return False
-    return True
-
-gCallbackData = ''
-
-class myServer(SocketServer.TCPServer):
-  allow_reuse_address = True
-
-class callbackServer():
-  def __init__(self, ip, port, debuglevel):
-    global gCallbackData
-    if (debuglevel >= 1): print "DEBUG: gCallbackData is: %s on port: %s" % (gCallbackData, port)
-    gCallbackData = ''
-    self.ip = ip
-    self.port = port
-    self.connected = False
-    self.debug = debuglevel
-    if (self.debug >= 3): print "Creating server with " + str(ip) + ":" + str(port)
-    self.server = myServer((ip, port), self.myhandler)
-    self.server_thread = Thread(target=self.server.serve_forever)
-    self.server_thread.setDaemon(True)
-    self.server_thread.start()
-
-  def disconnect(self, step = 60, timeout = 600):
-    t = 0
-    if (self.debug >= 3): print "Calling disconnect on callback server"
-    while t < timeout:
-      if (gCallbackData):
-        # Got the data back
-        if (self.debug >= 3): print "Got data back from agent: " + str(gCallbackData)
-        break
-      else:
-        if (self.debug >= 0): print '.',
-      time.sleep(step)
-      t += step
-
-    try:
-      if (self.debug >= 3): print "Shutting down server now"
-      self.server.shutdown()
-    except:
-      if (self.debug >= 1): print "Unable to shutdown callback server - check for a connection on port: " + str(self.port)
-
-    #sleep 1 additional step to ensure not only we are online, but all our services are online
-    time.sleep(step)
-    return gCallbackData
-
-  class myhandler(SocketServer.BaseRequestHandler):
-    def handle(self):
-      global gCallbackData
-      gCallbackData = self.request.recv(1024)
-      #print "Callback Handler got data: " + str(gCallbackData)
-      self.request.send("OK")
-
deleted file mode 100644
--- a/build/mobile/droid.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# 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 devicemanagerADB import DeviceManagerADB
-from devicemanagerSUT import DeviceManagerSUT
-import StringIO
-
-class DroidMixin(object):
-  """Mixin to extend DeviceManager with Android-specific functionality"""
-
-  def launchApplication(self, appName, activityName, intent, url=None,
-                        extras=None):
-    """
-    Launches an Android application
-    returns:
-    success: True
-    failure: False
-    """
-    # only one instance of an application may be running at once
-    if self.processExist(appName):
-      return False
-
-    acmd = [ "am", "start", "-W", "-n", "%s/%s" % (appName, activityName)]
-
-    if intent:
-      acmd.extend(["-a", intent])
-
-    if extras:
-      for (key, val) in extras.iteritems():
-        if type(val) is int:
-          extraTypeParam = "--ei"
-        elif type(val) is bool:
-          extraTypeParam = "--ez"
-        else:
-          extraTypeParam = "--es"
-        acmd.extend([extraTypeParam, str(key), str(val)])
-
-    if url:
-      acmd.extend(["-d", url])
-
-    # shell output not that interesting and debugging logs should already
-    # show what's going on here... so just create an empty memory buffer
-    # and ignore
-    shellOutput = StringIO.StringIO()
-    if self.shell(acmd, shellOutput) == 0:
-      return True
-
-    return False
-
-  def launchFennec(self, appName, intent="android.intent.action.VIEW",
-                   mozEnv=None, extraArgs=None, url=None):
-    """
-    Convenience method to launch Fennec on Android with various debugging
-    arguments
-    WARNING: FIXME: This would go better in mozrunner. Please do not
-    use this method if you are not comfortable with it going away sometime
-    in the near future
-    returns:
-    success: True
-    failure: False
-    """
-    extras = {}
-
-    if mozEnv:
-      # mozEnv is expected to be a dictionary of environment variables: Fennec
-      # itself will set them when launched
-      for (envCnt, (envkey, envval)) in enumerate(mozEnv.iteritems()):
-        extras["env" + str(envCnt)] = envkey + "=" + envval
-
-    # Additional command line arguments that fennec will read and use (e.g.
-    # with a custom profile)
-    if extraArgs:
-      extras['args'] = " ".join(extraArgs)
-
-    return self.launchApplication(appName, ".App", intent, url=url,
-                                  extras=extras)
-
-class DroidADB(DeviceManagerADB, DroidMixin):
-  pass
-
-class DroidSUT(DeviceManagerSUT, DroidMixin):
-  pass
deleted file mode 100644
--- a/build/mobile/emulator.py
+++ /dev/null
@@ -1,296 +0,0 @@
-# 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 abc import abstractmethod
-import datetime
-from mozprocess import ProcessHandlerMixin
-import multiprocessing
-import os
-import re
-import shutil
-import socket
-import subprocess
-from telnetlib import Telnet
-import tempfile
-import time
-
-from emulator_battery import EmulatorBattery
-
-
-class LogcatProc(ProcessHandlerMixin):
-    """Process handler for logcat which saves all output to a logfile.
-    """
-
-    def __init__(self, logfile, cmd, **kwargs):
-        self.logfile = logfile
-        kwargs.setdefault('processOutputLine', []).append(self.log_output)
-        ProcessHandlerMixin.__init__(self, cmd, **kwargs)
-
-    def log_output(self, line):
-        f = open(self.logfile, 'a')
-        f.write(line + "\n")
-        f.flush()
-
-
-class Emulator(object):
-
-    deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
-
-    def __init__(self, noWindow=False, logcat_dir=None, arch="x86",
-                 emulatorBinary=None, res='480x800', userdata=None,
-                 memory='512', partition_size='512'):
-        self.port = None
-        self._emulator_launched = False
-        self.proc = None
-        self.local_port = None
-        self.telnet = None
-        self._tmp_userdata = None
-        self._adb_started = False
-        self.logcat_dir = logcat_dir
-        self.logcat_proc = None
-        self.arch = arch
-        self.binary = emulatorBinary
-        self.memory = str(memory)
-        self.partition_size = str(partition_size)
-        self.res = res
-        self.battery = EmulatorBattery(self)
-        self.noWindow = noWindow
-        self.dataImg = userdata
-        self.copy_userdata = self.dataImg is None
-
-    def __del__(self):
-        if self.telnet:
-            self.telnet.write('exit\n')
-            self.telnet.read_all()
-
-    @property
-    def args(self):
-        qemuArgs = [self.binary,
-                    '-kernel', self.kernelImg,
-                    '-sysdir', self.sysDir,
-                    '-data', self.dataImg]
-        if self.noWindow:
-            qemuArgs.append('-no-window')
-        qemuArgs.extend(['-memory', self.memory,
-                         '-partition-size', self.partition_size,
-                         '-verbose',
-                         '-skin', self.res,
-                         '-gpu', 'on',
-                         '-qemu'] + self.tail_args)
-        return qemuArgs
-
-    @property
-    def is_running(self):
-        if self._emulator_launched:
-            return self.proc is not None and self.proc.poll() is None
-        else:
-            return self.port is not None
-
-    def _default_adb(self):
-        adb = subprocess.Popen(['which', 'adb'],
-                               stdout=subprocess.PIPE,
-                               stderr=subprocess.STDOUT)
-        retcode = adb.wait()
-        if retcode == 0:
-            self.adb = adb.stdout.read().strip() # remove trailing newline
-        return retcode
-
-    def _check_for_adb(self):
-        if not os.path.exists(self.adb):
-            if self._default_adb() != 0:
-                raise Exception('adb not found!')
-
-    def _run_adb(self, args):
-        args.insert(0, self.adb)
-        adb = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        retcode = adb.wait()
-        if retcode:
-            raise Exception('adb terminated with exit code %d: %s'
-            % (retcode, adb.stdout.read()))
-        return adb.stdout.read()
-
-    def _get_telnet_response(self, command=None):
-        output = []
-        assert(self.telnet)
-        if command is not None:
-            self.telnet.write('%s\n' % command)
-        while True:
-            line = self.telnet.read_until('\n')
-            output.append(line.rstrip())
-            if line.startswith('OK'):
-                return output
-            elif line.startswith('KO:'):
-                raise Exception('bad telnet response: %s' % line)
-
-    def _run_telnet(self, command):
-        if not self.telnet:
-            self.telnet = Telnet('localhost', self.port)
-            self._get_telnet_response()
-        return self._get_telnet_response(command)
-
-    def close(self):
-        if self.is_running and self._emulator_launched:
-            self.proc.terminate()
-            self.proc.wait()
-        if self._adb_started:
-            self._run_adb(['kill-server'])
-            self._adb_started = False
-        if self.proc:
-            retcode = self.proc.poll()
-            self.proc = None
-            if self._tmp_userdata:
-                os.remove(self._tmp_userdata)
-                self._tmp_userdata = None
-            return retcode
-        if self.logcat_proc:
-            self.logcat_proc.kill()
-        return 0
-
-    def _get_adb_devices(self):
-        offline = set()
-        online = set()
-        output = self._run_adb(['devices'])
-        for line in output.split('\n'):
-            m = self.deviceRe.match(line)
-            if m:
-                if m.group(3) == 'offline':
-                    offline.add(m.group(1))
-                else:
-                    online.add(m.group(1))
-        return (online, offline)
-
-    def restart(self):
-        if not self._emulator_launched:
-            return
-        self.close()
-        self.start()
-
-    def start_adb(self):
-        result = self._run_adb(['start-server'])
-        # We keep track of whether we've started adb or not, so we know
-        # if we need to kill it.
-        if 'daemon started successfully' in result:
-            self._adb_started = True
-        else:
-            self._adb_started = False
-
-    def connect(self):
-        self._check_for_adb()
-        self.start_adb()
-
-        online, offline = self._get_adb_devices()
-        now = datetime.datetime.now()
-        while online == set([]):
-            time.sleep(1)
-            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
-                raise Exception('timed out waiting for emulator to be available')
-            online, offline = self._get_adb_devices()
-        self.port = int(list(online)[0])
-
-    @abstractmethod
-    def _locate_files(self):
-        pass
-
-    def start(self):
-        self._locate_files()
-        self.start_adb()
-
-        qemu_args = self.args[:]
-        if self.copy_userdata:
-            # Make a copy of the userdata.img for this instance of the emulator
-            # to use.
-            self._tmp_userdata = tempfile.mktemp(prefix='emulator')
-            shutil.copyfile(self.dataImg, self._tmp_userdata)
-            qemu_args[qemu_args.index('-data') + 1] = self._tmp_userdata
-
-        original_online, original_offline = self._get_adb_devices()
-
-        self.proc = subprocess.Popen(qemu_args,
-                                     stdout=subprocess.PIPE,
-                                     stderr=subprocess.PIPE)
-
-        online, offline = self._get_adb_devices()
-        now = datetime.datetime.now()
-        while online - original_online == set([]):
-            time.sleep(1)
-            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
-                raise Exception('timed out waiting for emulator to start')
-            online, offline = self._get_adb_devices()
-        self.port = int(list(online - original_online)[0])
-        self._emulator_launched = True
-
-        if self.logcat_dir:
-            self.save_logcat()
-
-        # setup DNS fix for networking
-        self._run_adb(['-s', 'emulator-%d' % self.port,
-                       'shell', 'setprop', 'net.dns1', '10.0.2.3'])
-
-    def _save_logcat_proc(self, filename, cmd):
-        self.logcat_proc = LogcatProc(filename, cmd)
-        self.logcat_proc.run()
-        self.logcat_proc.waitForFinish()
-        self.logcat_proc = None
-
-    def rotate_log(self, srclog, index=1):
-        """ Rotate a logfile, by recursively rotating logs further in the sequence,
-            deleting the last file if necessary.
-        """
-        destlog = os.path.join(self.logcat_dir, 'emulator-%d.%d.log' % (self.port, index))
-        if os.path.exists(destlog):
-            if index == 3:
-                os.remove(destlog)
-            else:
-                self.rotate_log(destlog, index + 1)
-        shutil.move(srclog, destlog)
-
-    def save_logcat(self):
-        """ Save the output of logcat to a file.
-        """
-        filename = os.path.join(self.logcat_dir, "emulator-%d.log" % self.port)
-        if os.path.exists(filename):
-            self.rotate_log(filename)
-        cmd = [self.adb, '-s', 'emulator-%d' % self.port, 'logcat']
-
-        # We do this in a separate process because we call mozprocess's
-        # waitForFinish method to process logcat's output, and this method
-        # blocks.
-        proc = multiprocessing.Process(target=self._save_logcat_proc, args=(filename, cmd))
-        proc.daemon = True
-        proc.start()
-
-    def setup_port_forwarding(self, remote_port):
-        """ Set up TCP port forwarding to the specified port on the device,
-            using any availble local port, and return the local port.
-        """
-
-        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        s.bind(("", 0))
-        local_port = s.getsockname()[1]
-        s.close()
-
-        self._run_adb(['-s', 'emulator-%d' % self.port, 'forward',
-                       'tcp:%d' % local_port,
-                       'tcp:%d' % remote_port])
-
-        self.local_port = local_port
-
-        return local_port
-
-    def wait_for_port(self, timeout=300):
-        assert(self.local_port)
-        starttime = datetime.datetime.now()
-        while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
-            try:
-                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-                sock.connect(('localhost', self.local_port))
-                data = sock.recv(16)
-                sock.close()
-                if '"from"' in data:
-                    return True
-            except:
-                import traceback
-                print traceback.format_exc()
-            time.sleep(1)
-        return False
deleted file mode 100644
--- a/build/mobile/emulator_battery.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# 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/.
-
-class EmulatorBattery(object):
-
-    def __init__(self, emulator):
-        self.emulator = emulator
-
-    def get_state(self):
-        status = {}
-        state = {}
-
-        response = self.emulator._run_telnet('power display')
-        for line in response:
-            if ':' in line:
-                field, value = line.split(':')
-                value = value.strip()
-                if value == 'true':
-                    value = True
-                elif value == 'false':
-                    value = False
-                elif field == 'capacity':
-                    value = float(value)
-                status[field] = value
-
-        state['level'] = status.get('capacity', 0.0) / 100
-        if status.get('AC') == 'online':
-            state['charging'] = True
-        else:
-            state['charging'] = False
-
-        return state
-
-    def get_charging(self):
-        return self.get_state()['charging']
-
-    def get_level(self):
-        return self.get_state()['level']
-
-    def set_level(self, level):
-        self.emulator._run_telnet('power capacity %d' % (level * 100))
-
-    def set_charging(self, charging):
-        if charging:
-            cmd = 'power ac on'
-        else:
-            cmd = 'power ac off'
-        self.emulator._run_telnet(cmd)
-
-    charging = property(get_charging, set_charging)
-    level = property(get_level, set_level)
--- a/layout/tools/reftest/Makefile.in
+++ b/layout/tools/reftest/Makefile.in
@@ -55,19 +55,19 @@ libs:: copy-harness
 endif
 
 _HARNESS_FILES = \
   $(srcdir)/runreftest.py \
   $(srcdir)/remotereftest.py \
   $(srcdir)/runreftestb2g.py \
   $(srcdir)/b2g_start_script.js \
   automation.py \
-  $(topsrcdir)/build/mobile/devicemanager.py \
-  $(topsrcdir)/build/mobile/devicemanagerADB.py \
-  $(topsrcdir)/build/mobile/devicemanagerSUT.py \
+  $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanager.py \
+  $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py \
+  $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py \
   $(topsrcdir)/build/mobile/b2gautomation.py \
   $(topsrcdir)/build/automationutils.py \
   $(topsrcdir)/build/mobile/remoteautomation.py \
   $(topsrcdir)/testing/mochitest/server.js \
   $(topsrcdir)/build/pgo/server-locations.txt \
   $(NULL)
 
 $(_DEST_DIR):
--- a/testing/mochitest/Makefile.in
+++ b/testing/mochitest/Makefile.in
@@ -45,19 +45,19 @@ include $(topsrcdir)/build/automation-bu
 
 # files that get copied into $objdir/_tests/
 _SERV_FILES = 	\
 		runtests.py \
 		automation.py \
 		runtestsb2g.py \
 		runtestsremote.py \
 		runtestsvmware.py \
-		$(topsrcdir)/build/mobile/devicemanager.py \
-		$(topsrcdir)/build/mobile/devicemanagerADB.py \
-		$(topsrcdir)/build/mobile/devicemanagerSUT.py \
+		$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanager.py \
+		$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py \
+		$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py \
 		$(topsrcdir)/build/automationutils.py \
 		$(topsrcdir)/build/manifestparser.py \
 		$(topsrcdir)/build/mobile/remoteautomation.py \
 		$(topsrcdir)/build/mobile/b2gautomation.py \
 		gen_template.pl \
 		server.js \
 		harness-overlay.xul \
 		harness.xul \
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/README.md
@@ -0,0 +1,5 @@
+[mozdevice](https://github.com/mozilla/mozbase/tree/master/mozdevice) provides
+an interface to interact with a remote device such as an Android phone connected
+to a workstation. Currently there are two implementations of the interface: one
+uses a TCP-based protocol to communicate with a server running on the device,
+another uses Android's adb utility.
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/__init__.py
@@ -0,0 +1,11 @@
+# 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 devicemanager import DMError
+from devicemanagerADB import DeviceManagerADB
+from devicemanagerSUT import DeviceManagerSUT
+from droid import DroidADB, DroidSUT
+from emulator import Emulator
+from b2gemulator import B2GEmulator
+
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/b2gemulator.py
@@ -0,0 +1,87 @@
+# 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/.
+
+
+import os
+import platform
+
+from emulator import Emulator
+
+
+class B2GEmulator(Emulator):
+
+    def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86",
+                 emulatorBinary=None, res='480x800', userdata=None,
+                 memory='512', partition_size='512'):
+        super(B2GEmulator, self).__init__(noWindow=noWindow, logcat_dir=logcat_dir,
+                                          arch=arch, emulatorBinary=emulatorBinary,
+                                          res=res, userdata=userdata,
+                                          memory=memory, partition_size=partition_size)
+        self.homedir = homedir
+        if self.homedir is not None:
+            self.homedir = os.path.expanduser(homedir)
+
+    def _check_file(self, filePath):
+        if not os.path.exists(filePath):
+            raise Exception(('File not found: %s; did you pass the B2G home '
+                             'directory as the homedir parameter, or set '
+                             'B2G_HOME correctly?') % filePath)
+
+    def _check_for_adb(self, host_dir):
+        if self._default_adb() == 0:
+            return
+        adb_paths = [os.path.join(self.homedir,'glue','gonk','out','host',
+                      host_dir ,'bin','adb'),os.path.join(self.homedir, 'out',
+                      'host', host_dir,'bin','adb'),os.path.join(self.homedir,
+                      'bin','adb')]
+        for option in adb_paths:
+            if os.path.exists(option):
+                self.adb = option
+                return
+        raise Exception('adb not found!')
+
+    def _locate_files(self):
+        if self.homedir is None:
+            self.homedir = os.getenv('B2G_HOME')
+        if self.homedir is None:
+            raise Exception('Must define B2G_HOME or pass the homedir parameter')
+        self._check_file(self.homedir)
+
+        if self.arch not in ("x86", "arm"):
+            raise Exception("Emulator architecture must be one of x86, arm, got: %s" %
+                            self.arch)
+
+        host_dir = "linux-x86"
+        if platform.system() == "Darwin":
+            host_dir = "darwin-x86"
+
+        host_bin_dir = os.path.join("out", "host", host_dir, "bin")
+
+        if self.arch == "x86":
+            binary = os.path.join(host_bin_dir, "emulator-x86")
+            kernel = "prebuilts/qemu-kernel/x86/kernel-qemu"
+            sysdir = "out/target/product/generic_x86"
+            self.tail_args = []
+        else:
+            binary = os.path.join(host_bin_dir, "emulator")
+            kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7"
+            sysdir = "out/target/product/generic"
+            self.tail_args = ["-cpu", "cortex-a8"]
+
+        self._check_for_adb(host_dir)
+
+        if not self.binary:
+            self.binary = os.path.join(self.homedir, binary)
+
+        self._check_file(self.binary)
+
+        self.kernelImg = os.path.join(self.homedir, kernel)
+        self._check_file(self.kernelImg)
+
+        self.sysDir = os.path.join(self.homedir, sysdir)
+        self._check_file(self.sysDir)
+
+        if not self.dataImg:
+            self.dataImg = os.path.join(self.sysDir, 'userdata.img')
+        self._check_file(self.dataImg)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanager.py
@@ -0,0 +1,637 @@
+# 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/.
+
+import hashlib
+import socket
+import os
+import re
+import StringIO
+
+class FileError(Exception):
+  " Signifies an error which occurs while doing a file operation."
+
+  def __init__(self, msg = ''):
+    self.msg = msg
+
+  def __str__(self):
+    return self.msg
+
+class DMError(Exception):
+  "generic devicemanager exception."
+
+  def __init__(self, msg= ''):
+    self.msg = msg
+
+  def __str__(self):
+    return self.msg
+
+def abstractmethod(method):
+  line = method.func_code.co_firstlineno
+  filename = method.func_code.co_filename
+  def not_implemented(*args, **kwargs):
+    raise NotImplementedError('Abstract method %s at File "%s", line %s '
+                              'should be implemented by a concrete class' %
+                              (repr(method), filename,line))
+  return not_implemented
+
+class DeviceManager:
+
+  @abstractmethod
+  def shell(self, cmd, outputfile, env=None, cwd=None, timeout=None):
+    """
+    executes shell command on device
+
+    timeout is specified in seconds, and if no timeout is given, 
+    we will run until the script returns
+    returns:
+    success: Return code from command
+    failure: None
+    """
+
+  @abstractmethod
+  def pushFile(self, localname, destname):
+    """
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+  @abstractmethod
+  def mkDir(self, name):
+    """
+    external function
+    returns:
+    success: directory name
+    failure: None
+    """
+
+  def mkDirs(self, filename):
+    """
+    make directory structure on the device
+    WARNING: does not create last part of the path
+    external function
+    returns:
+    success: directory structure that we created
+    failure: None
+    """
+    parts = filename.split('/')
+    name = ""
+    for part in parts:
+        if (part == parts[-1]): break
+        if (part != ""):
+            name += '/' + part
+            if (not self.dirExists(name)):
+                if (self.mkDir(name) == None):
+                    print "failed making directory: " + str(name)
+                    return None
+    return name
+
+  @abstractmethod
+  def pushDir(self, localDir, remoteDir):
+    """
+    push localDir from host to remoteDir on the device
+    external function
+    returns:
+    success: remoteDir
+    failure: None
+    """
+
+  @abstractmethod
+  def dirExists(self, dirname):
+    """
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+  @abstractmethod
+  def fileExists(self, filepath):
+    """
+    Because we always have / style paths we make this a lot easier with some
+    assumptions
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+  @abstractmethod
+  def listFiles(self, rootdir):
+    """
+    list files on the device, requires cd to directory first
+    external function
+    returns:
+    success: array of filenames, ['file1', 'file2', ...]
+    failure: None
+    """
+
+  @abstractmethod
+  def removeFile(self, filename):
+    """
+    external function
+    returns:
+    success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
+    failure: None
+    """
+
+  @abstractmethod
+  def removeDir(self, remoteDir):
+    """
+    does a recursive delete of directory on the device: rm -Rf remoteDir
+    external function
+    returns:
+    success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
+    failure: None
+    """
+
+  @abstractmethod
+  def getProcessList(self):
+    """
+    external function
+    returns:
+    success: array of process tuples
+    failure: None
+    """
+
+  @abstractmethod
+  def fireProcess(self, appname, failIfRunning=False):
+    """
+    external function
+    DEPRECATED: Use shell() or launchApplication() for new code
+    returns:
+    success: pid
+    failure: None
+    """
+
+  @abstractmethod
+  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
+    """
+    external function
+    DEPRECATED: Use shell() or launchApplication() for new code
+    returns:
+    success: output filename
+    failure: None
+    """
+
+  def processExist(self, appname):
+    """
+    iterates process list and returns pid if exists, otherwise None
+    external function
+    returns:
+    success: pid
+    failure: None
+    """
+
+    pid = None
+
+    #filter out extra spaces
+    parts = filter(lambda x: x != '', appname.split(' '))
+    appname = ' '.join(parts)
+
+    #filter out the quoted env string if it exists
+    #ex: '"name=value;name2=value2;etc=..." process args' -> 'process args'
+    parts = appname.split('"')
+    if (len(parts) > 2):
+      appname = ' '.join(parts[2:]).strip()
+
+    pieces = appname.split(' ')
+    parts = pieces[0].split('/')
+    app = parts[-1]
+
+    procList = self.getProcessList()
+    if (procList == []):
+      return None
+
+    for proc in procList:
+      procName = proc[1].split('/')[-1]
+      if (procName == app):
+        pid = proc[0]
+        break
+    return pid
+
+
+  @abstractmethod
+  def killProcess(self, appname, forceKill=False):
+    """
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+  @abstractmethod
+  def catFile(self, remoteFile):
+    """
+    external function
+    returns:
+    success: filecontents
+    failure: None
+    """
+
+  @abstractmethod
+  def pullFile(self, remoteFile):
+    """
+    external function
+    returns:
+    success: output of pullfile, string
+    failure: None
+    """
+
+  @abstractmethod
+  def getFile(self, remoteFile, localFile = ''):
+    """
+    copy file from device (remoteFile) to host (localFile)
+    external function
+    returns:
+    success: output of pullfile, string
+    failure: None
+    """
+
+  @abstractmethod
+  def getDirectory(self, remoteDir, localDir, checkDir=True):
+    """
+    copy directory structure from device (remoteDir) to host (localDir)
+    external function
+    checkDir exists so that we don't create local directories if the
+    remote directory doesn't exist but also so that we don't call isDir
+    twice when recursing.
+    returns:
+    success: list of files, string
+    failure: None
+    """
+
+  @abstractmethod
+  def isDir(self, remotePath):
+    """
+    external function
+    returns:
+    success: True
+    failure: False
+    Throws a FileError exception when null (invalid dir/filename)
+    """
+
+  @abstractmethod
+  def validateFile(self, remoteFile, localFile):
+    """
+    true/false check if the two files have the same md5 sum
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+  @abstractmethod
+  def getRemoteHash(self, filename):
+    """
+    return the md5 sum of a remote file
+    internal function
+    returns:
+    success: MD5 hash for given filename
+    failure: None
+    """
+
+  def getLocalHash(self, filename):
+    """
+    return the md5 sum of a file on the host
+    internal function
+    returns:
+    success: MD5 hash for given filename
+    failure: None
+    """
+
+    file = open(filename, 'rb')
+    if (file == None):
+      return None
+
+    try:
+      mdsum = hashlib.md5()
+    except:
+      return None
+
+    while 1:
+      data = file.read(1024)
+      if not data:
+        break
+      mdsum.update(data)
+
+    file.close()
+    hexval = mdsum.hexdigest()
+    if (self.debug >= 3): print "local hash returned: '" + hexval + "'"
+    return hexval
+
+  @abstractmethod
+  def getDeviceRoot(self):
+    """
+    Gets the device root for the testing area on the device
+    For all devices we will use / type slashes and depend on the device-agent
+    to sort those out.  The agent will return us the device location where we
+    should store things, we will then create our /tests structure relative to
+    that returned path.
+    Structure on the device is as follows:
+    /tests
+          /<fennec>|<firefox>  --> approot
+          /profile
+          /xpcshell
+          /reftest
+          /mochitest
+    external
+    returns:
+    success: path for device root
+    failure: None
+    """
+
+  @abstractmethod
+  def getAppRoot(self):
+    """
+    Either we will have /tests/fennec or /tests/firefox but we will never have
+    both.  Return the one that exists
+    TODO: ensure we can support org.mozilla.firefox
+    external function
+    returns:
+    success: path for app root
+    failure: None
+    """
+
+  def getTestRoot(self, type):
+    """
+    Gets the directory location on the device for a specific test type
+    Type is one of: xpcshell|reftest|mochitest
+    external function
+    returns:
+    success: path for test root
+    failure: None
+    """
+
+    devroot = self.getDeviceRoot()
+    if (devroot == None):
+      return None
+
+    if (re.search('xpcshell', type, re.I)):
+      self.testRoot = devroot + '/xpcshell'
+    elif (re.search('?(i)reftest', type)):
+      self.testRoot = devroot + '/reftest'
+    elif (re.search('?(i)mochitest', type)):
+      self.testRoot = devroot + '/mochitest'
+    return self.testRoot
+
+  def signal(self, processID, signalType, signalAction):
+    """
+    Sends a specific process ID a signal code and action.
+    For Example: SIGINT and SIGDFL to process x
+    """
+    #currently not implemented in device agent - todo
+
+    pass
+
+  def getReturnCode(self, processID):
+    """Get a return code from process ending -- needs support on device-agent"""
+    # TODO: make this real
+
+    return 0
+
+  @abstractmethod
+  def unpackFile(self, file_path, dest_dir=None):
+    """
+    external function
+    returns:
+    success: output of unzip command
+    failure: None
+    """
+
+  @abstractmethod
+  def reboot(self, ipAddr=None, port=30000):
+    """
+    external function
+    returns:
+    success: status from test agent
+    failure: None
+    """
+
+  def validateDir(self, localDir, remoteDir):
+    """
+    validate localDir from host to remoteDir on the device
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+    if (self.debug >= 2): print "validating directory: " + localDir + " to " + remoteDir
+    for root, dirs, files in os.walk(localDir):
+      parts = root.split(localDir)
+      for file in files:
+        remoteRoot = remoteDir + '/' + parts[1]
+        remoteRoot = remoteRoot.replace('/', '/')
+        if (parts[1] == ""): remoteRoot = remoteDir
+        remoteName = remoteRoot + '/' + file
+        if (self.validateFile(remoteName, os.path.join(root, file)) <> True):
+            return False
+    return True
+
+  @abstractmethod
+  def getInfo(self, directive=None):
+    """
+    Returns information about the device:
+    Directive indicates the information you want to get, your choices are:
+    os - name of the os
+    id - unique id of the device
+    uptime - uptime of the device
+    uptimemillis - uptime of the device in milliseconds (NOT supported on all
+                   implementations)
+    systime - system time of the device
+    screen - screen resolution
+    memory - memory stats
+    process - list of running processes (same as ps)
+    disk - total, free, available bytes on disk
+    power - power status (charge, battery temp)
+    all - all of them - or call it with no parameters to get all the information
+    returns:
+    success: dict of info strings by directive name
+    failure: None
+    """
+
+  @abstractmethod
+  def installApp(self, appBundlePath, destPath=None):
+    """
+    external function
+    returns:
+    success: output from agent for inst command
+    failure: None
+    """
+
+  @abstractmethod
+  def uninstallAppAndReboot(self, appName, installPath=None):
+    """
+    external function
+    returns:
+    success: True
+    failure: None
+    """
+
+  @abstractmethod
+  def updateApp(self, appBundlePath, processName=None,
+                destPath=None, ipAddr=None, port=30000):
+    """
+    external function
+    returns:
+    success: text status from command or callback server
+    failure: None
+    """
+
+  @abstractmethod
+  def getCurrentTime(self):
+    """
+    external function
+    returns:
+    success: time in ms
+    failure: None
+    """
+
+  def recordLogcat(self):
+    """
+    external function
+    returns:
+    success: file is created in <testroot>/logcat.log
+    failure:
+    """
+    #TODO: spawn this off in a separate thread/process so we can collect all the logcat information
+
+    # Right now this is just clearing the logcat so we can only see what happens after this call.
+    buf = StringIO.StringIO()
+    self.shell(['/system/bin/logcat', '-c'], buf, root=True)
+
+  def getLogcat(self):
+    """
+    external function
+    returns: data from the local file
+    success: file is in 'filename'
+    failure: None
+    """
+    buf = StringIO.StringIO()
+    if self.shell(["/system/bin/logcat", "-d", "dalvikvm:S", "ConnectivityService:S", "WifiMonitor:S", "WifiStateTracker:S", "wpa_supplicant:S", "NetworkStateTracker:S"], buf, root=True) != 0:
+      return None
+
+    return str(buf.getvalue()[0:-1]).rstrip().split('\r')
+
+  @abstractmethod
+  def chmodDir(self, remoteDir):
+    """
+    external function
+    returns:
+    success: True
+    failure: False
+    """
+
+  @staticmethod
+  def _escapedCommandLine(cmd):
+    """ Utility function to return escaped and quoted version of command line """
+    quotedCmd = []
+
+    for arg in cmd:
+      arg.replace('&', '\&')
+
+      needsQuoting = False
+      for char in [ ' ', '(', ')', '"', '&' ]:
+        if arg.find(char) >= 0:
+          needsQuoting = True
+          break
+      if needsQuoting:
+        arg = '\'%s\'' % arg
+
+      quotedCmd.append(arg)
+
+    return " ".join(quotedCmd)
+
+
+class NetworkTools:
+  def __init__(self):
+    pass
+
+  # Utilities to get the local ip address
+  def getInterfaceIp(self, ifname):
+    if os.name != "nt":
+      import fcntl
+      import struct
+      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+      return socket.inet_ntoa(fcntl.ioctl(
+                              s.fileno(),
+                              0x8915,  # SIOCGIFADDR
+                              struct.pack('256s', ifname[:15])
+                              )[20:24])
+    else:
+      return None
+
+  def getLanIp(self):
+    try:
+      ip = socket.gethostbyname(socket.gethostname())
+    except socket.gaierror:
+      ip = socket.gethostbyname(socket.gethostname() + ".local") # for Mac OS X
+    if ip.startswith("127.") and os.name != "nt":
+      interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
+      for ifname in interfaces:
+        try:
+          ip = self.getInterfaceIp(ifname)
+          break;
+        except IOError:
+          pass
+    return ip
+
+  # Gets an open port starting with the seed by incrementing by 1 each time
+  def findOpenPort(self, ip, seed):
+    try:
+      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+      s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+      connected = False
+      if isinstance(seed, basestring):
+        seed = int(seed)
+      maxportnum = seed + 5000 # We will try at most 5000 ports to find an open one
+      while not connected:
+        try:
+          s.bind((ip, seed))
+          connected = True
+          s.close()
+          break
+        except:
+          if seed > maxportnum:
+            print "Could not find open port after checking 5000 ports"
+          raise
+        seed += 1
+    except:
+      print "Socket error trying to find open port"
+
+    return seed
+
+def _pop_last_line(file):
+  '''
+  Utility function to get the last line from a file (shared between ADB and
+  SUT device managers). Function also removes it from the file. Intended to
+  strip off the return code from a shell command.
+  '''
+  bytes_from_end = 1
+  file.seek(0, 2)
+  length = file.tell() + 1
+  while bytes_from_end < length:
+    file.seek((-1)*bytes_from_end, 2)
+    data = file.read()
+
+    if bytes_from_end == length-1 and len(data) == 0: # no data, return None
+      return None
+
+    if data[0] == '\n' or bytes_from_end == length-1:
+      # found the last line, which should have the return value
+      if data[0] == '\n':
+        data = data[1:]
+
+      # truncate off the return code line
+      file.truncate(length - bytes_from_end)
+      file.seek(0,2)
+      file.write('\0')
+
+      return data
+
+    bytes_from_end += 1
+
+  return None
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -0,0 +1,900 @@
+# 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/.
+
+import subprocess
+from devicemanager import DeviceManager, DMError, _pop_last_line
+import re
+import os
+import tempfile
+import time
+
+class DeviceManagerADB(DeviceManager):
+
+  def __init__(self, host=None, port=20701, retrylimit=5, packageName='fennec',
+               adbPath='adb', deviceSerial=None, deviceRoot=None):
+    self.host = host
+    self.port = port
+    self.retrylimit = retrylimit
+    self.retries = 0
+    self._sock = None
+    self.useRunAs = False
+    self.haveRoot = False
+    self.useDDCopy = False
+    self.useZip = False
+    self.packageName = None
+    self.tempDir = None
+    self.deviceRoot = deviceRoot
+
+    # the path to adb, or 'adb' to assume that it's on the PATH
+    self.adbPath = adbPath
+
+    # The serial number of the device to use with adb, used in cases
+    # where multiple devices are being managed by the same adb instance.
+    self.deviceSerial = deviceSerial
+
+    if packageName == 'fennec':
+      if os.getenv('USER'):
+        self.packageName = 'org.mozilla.fennec_' + os.getenv('USER')
+      else:
+        self.packageName = 'org.mozilla.fennec_'
+    elif packageName:
+      self.packageName = packageName
+
+    # verify that we can run the adb command. can't continue otherwise
+    self.verifyADB()
+
+    # try to connect to the device over tcp/ip if we have a hostname
+    if self.host:
+      self.connectRemoteADB()
+
+    # verify that we can connect to the device. can't continue
+    self.verifyDevice()
+
+    # set up device root
+    self.setupDeviceRoot()
+
+    # Can we use run-as? (currently not required)
+    try:
+      self.verifyRunAs()
+    except DMError:
+      pass
+
+    # Can we run things as root? (currently not required)
+    useRunAsTmp = self.useRunAs
+    self.useRunAs = False
+    try:
+      self.verifyRoot()
+    except DMError:
+      try:
+        self.checkCmd(["root"])
+        # The root command does not fail even if ADB cannot get
+        # root rights (e.g. due to production builds), so we have
+        # to check again ourselves that we have root now.
+        self.verifyRoot()
+      except DMError:
+        if useRunAsTmp:
+          print "restarting as root failed, but run-as available"
+        else:
+          print "restarting as root failed"
+    self.useRunAs = useRunAsTmp
+
+    # can we use zip to speed up some file operations? (currently not
+    # required)
+    try:
+      self.verifyZip()
+    except DMError:
+      pass
+
+  def __del__(self):
+    if self.host:
+      self.disconnectRemoteADB()
+
+  # external function: executes shell command on device.
+  # timeout is specified in seconds, and if no timeout is given, 
+  # we will run until the script returns
+  # returns:
+  # success: <return code>
+  # failure: None
+  def shell(self, cmd, outputfile, env=None, cwd=None, timeout=None, root=False):
+    # FIXME: this function buffers all output of the command into memory,
+    # always. :(
+
+    # Getting the return code is more complex than you'd think because adb
+    # doesn't actually return the return code from a process, so we have to
+    # capture the output to get it
+    if root:
+      cmdline = "su -c \"%s\"" % self._escapedCommandLine(cmd)
+    else:
+      cmdline = self._escapedCommandLine(cmd)
+    cmdline += "; echo $?"
+
+    # prepend cwd and env to command if necessary
+    if cwd:
+      cmdline = "cd %s; %s" % (cwd, cmdline)
+    if env:
+      envstr = '; '.join(map(lambda x: 'export %s=%s' % (x[0], x[1]), env.iteritems()))
+      cmdline = envstr + "; " + cmdline
+
+    # all output should be in stdout
+    args=[self.adbPath]
+    if self.deviceSerial:
+        args.extend(['-s', self.deviceSerial])
+    args.extend(["shell", cmdline])
+    proc = subprocess.Popen(args,
+                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    if timeout:
+        timeout = int(timeout)
+        start_time = time.time()
+        ret_code = proc.poll()
+        while ((time.time() - start_time) <= timeout) and ret_code == None:
+            time.sleep(1)
+            ret_code = proc.poll()
+        if ret_code == None:
+            proc.kill()
+            raise DMError("Timeout exceeded for shell call")
+    (stdout, stderr) = proc.communicate()
+    outputfile.write(stdout.rstrip('\n'))
+
+    lastline = _pop_last_line(outputfile)
+    if lastline:
+      m = re.search('([0-9]+)', lastline)
+      if m:
+        return_code = m.group(1)
+        outputfile.seek(-2, 2)
+        outputfile.truncate() # truncate off the return code
+        return int(return_code)
+
+    return None
+
+  def connectRemoteADB(self):
+    self.checkCmd(["connect", self.host + ":" + str(self.port)])
+
+  def disconnectRemoteADB(self):
+    self.checkCmd(["disconnect", self.host + ":" + str(self.port)])
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def pushFile(self, localname, destname):
+    try:
+      if (os.name == "nt"):
+        destname = destname.replace('\\', '/')
+      if (self.useRunAs):
+        remoteTmpFile = self.getTempDir() + "/" + os.path.basename(localname)
+        self.checkCmd(["push", os.path.realpath(localname), remoteTmpFile])
+        if self.useDDCopy:
+          self.checkCmdAs(["shell", "dd", "if=" + remoteTmpFile, "of=" + destname])
+        else:
+          self.checkCmdAs(["shell", "cp", remoteTmpFile, destname])
+        self.checkCmd(["shell", "rm", remoteTmpFile])
+      else:
+        self.checkCmd(["push", os.path.realpath(localname), destname])
+      if (self.isDir(destname)):
+        destname = destname + "/" + os.path.basename(localname)
+      return True
+    except:
+      return False
+
+  # external function
+  # returns:
+  #  success: directory name
+  #  failure: None
+  def mkDir(self, name):
+    try:
+      result = self.runCmdAs(["shell", "mkdir", name]).stdout.read()
+      if 'read-only file system' in result.lower():
+        return None
+      if 'file exists' in result.lower():
+        return name
+      return name
+    except:
+      return None
+
+  # push localDir from host to remoteDir on the device
+  # external function
+  # returns:
+  #  success: remoteDir
+  #  failure: None
+  def pushDir(self, localDir, remoteDir):
+    # adb "push" accepts a directory as an argument, but if the directory
+    # contains symbolic links, the links are pushed, rather than the linked
+    # files; we either zip/unzip or push file-by-file to get around this 
+    # limitation
+    try:
+      if (not self.dirExists(remoteDir)):
+        self.mkDirs(remoteDir+"/x")
+      if (self.useZip):
+        try:
+          localZip = tempfile.mktemp()+".zip"
+          remoteZip = remoteDir + "/adbdmtmp.zip"
+          subprocess.check_output(["zip", "-r", localZip, '.'], cwd=localDir)
+          self.pushFile(localZip, remoteZip)
+          os.remove(localZip)
+          data = self.runCmdAs(["shell", "unzip", "-o", remoteZip, "-d", remoteDir]).stdout.read()
+          self.checkCmdAs(["shell", "rm", remoteZip])
+          if (re.search("unzip: exiting", data) or re.search("Operation not permitted", data)):
+            raise Exception("unzip failed, or permissions error")
+        except:
+          print "zip/unzip failure: falling back to normal push"
+          self.useZip = False
+          self.pushDir(localDir, remoteDir)
+      else:
+        for root, dirs, files in os.walk(localDir, followlinks=True):
+          relRoot = os.path.relpath(root, localDir)
+          for file in files:
+            localFile = os.path.join(root, file)
+            remoteFile = remoteDir + "/"
+            if (relRoot!="."):
+              remoteFile = remoteFile + relRoot + "/"
+            remoteFile = remoteFile + file
+            self.pushFile(localFile, remoteFile)
+          for dir in dirs:
+            targetDir = remoteDir + "/"
+            if (relRoot!="."):
+              targetDir = targetDir + relRoot + "/"
+            targetDir = targetDir + dir
+            if (not self.dirExists(targetDir)):
+              self.mkDir(targetDir)
+      return remoteDir
+    except:
+      print "pushing " + localDir + " to " + remoteDir + " failed"
+      return None
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def dirExists(self, dirname):
+    return self.isDir(dirname)
+
+  # Because we always have / style paths we make this a lot easier with some
+  # assumptions
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def fileExists(self, filepath):
+    p = self.runCmd(["shell", "ls", "-a", filepath])
+    data = p.stdout.readlines()
+    if (len(data) == 1):
+      if (data[0].rstrip() == filepath):
+        return True
+    return False
+
+  def removeFile(self, filename):
+    return self.runCmd(["shell", "rm", filename]).stdout.read()
+
+  # does a recursive delete of directory on the device: rm -Rf remoteDir
+  # external function
+  # returns:
+  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
+  #  failure: None
+  def removeSingleDir(self, remoteDir):
+    return self.runCmd(["shell", "rmdir", remoteDir]).stdout.read()
+
+  # does a recursive delete of directory on the device: rm -Rf remoteDir
+  # external function
+  # returns:
+  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
+  #  failure: None
+  def removeDir(self, remoteDir):
+      out = ""
+      if (self.isDir(remoteDir)):
+          files = self.listFiles(remoteDir.strip())
+          for f in files:
+              if (self.isDir(remoteDir.strip() + "/" + f.strip())):
+                  out += self.removeDir(remoteDir.strip() + "/" + f.strip())
+              else:
+                  out += self.removeFile(remoteDir.strip() + "/" + f.strip())
+          out += self.removeSingleDir(remoteDir.strip())
+      else:
+          out += self.removeFile(remoteDir.strip())
+      return out
+
+  def isDir(self, remotePath):
+      p = self.runCmd(["shell", "ls", "-a", remotePath + '/'])
+
+      data = p.stdout.readlines()
+      if len(data) == 1:
+          res = data[0]
+          if "Not a directory" in res or "No such file or directory" in res:
+              return False
+
+      return True
+
+  def listFiles(self, rootdir):
+      p = self.runCmd(["shell", "ls", "-a", rootdir])
+      data = p.stdout.readlines()
+      data[:] = [item.rstrip('\r\n') for item in data]
+      if (len(data) == 1):
+          if (data[0] == rootdir):
+              return []
+          if (data[0].find("No such file or directory") != -1):
+              return []
+          if (data[0].find("Not a directory") != -1):
+              return []
+          if (data[0].find("Permission denied") != -1):
+              return []
+          if (data[0].find("opendir failed") != -1):
+              return []
+      return data
+
+  # external function
+  # returns:
+  #  success: array of process tuples
+  #  failure: []
+  def getProcessList(self):
+    p = self.runCmd(["shell", "ps"])
+      # first line is the headers
+    p.stdout.readline()
+    proc = p.stdout.readline()
+    ret = []
+    while (proc):
+      els = proc.split()
+      ret.append(list([els[1], els[len(els) - 1], els[0]]))
+      proc =  p.stdout.readline()
+    return ret
+
+  # external function
+  # DEPRECATED: Use shell() or launchApplication() for new code
+  # returns:
+  #  success: pid
+  #  failure: None
+  def fireProcess(self, appname, failIfRunning=False):
+    #strip out env vars
+    parts = appname.split('"');
+    if (len(parts) > 2):
+      parts = parts[2:]
+    return self.launchProcess(parts, failIfRunning)
+
+  # external function
+  # DEPRECATED: Use shell() or launchApplication() for new code
+  # returns:
+  #  success: output filename
+  #  failure: None
+  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
+    if cmd[0] == "am":
+      self.checkCmd(["shell"] + cmd)
+      return outputFile
+
+    acmd = ["shell", "am", "start", "-W"]
+    cmd = ' '.join(cmd).strip()
+    i = cmd.find(" ")
+    # SUT identifies the URL by looking for :\\ -- another strategy to consider
+    re_url = re.compile('^[http|file|chrome|about].*')
+    last = cmd.rfind(" ")
+    uri = ""
+    args = ""
+    if re_url.match(cmd[last:].strip()):
+      args = cmd[i:last].strip()
+      uri = cmd[last:].strip()
+    else:
+      args = cmd[i:].strip()
+    acmd.append("-n")
+    acmd.append(cmd[0:i] + "/.App")
+    if args != "":
+      acmd.append("--es")
+      acmd.append("args")
+      acmd.append(args)
+    if env != '' and env != None:
+      envCnt = 0
+      # env is expected to be a dict of environment variables
+      for envkey, envval in env.iteritems():
+        acmd.append("--es")
+        acmd.append("env" + str(envCnt))
+        acmd.append(envkey + "=" + envval);
+        envCnt += 1
+    if uri != "":
+      acmd.append("-d")
+      acmd.append(''.join(['\'',uri, '\'']));
+    print acmd
+    self.checkCmd(acmd)
+    return outputFile
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def killProcess(self, appname, forceKill=False):
+    procs = self.getProcessList()
+    didKillProcess = False
+    for (pid, name, user) in procs:
+      if name == appname:
+         args = ["shell", "kill"]
+         if forceKill:
+           args.append("-9")
+         args.append(pid)
+         p = self.runCmdAs(args)
+         p.communicate()
+         if p.returncode == 0:
+             didKillProcess = True
+
+    return didKillProcess
+
+  # external function
+  # returns:
+  #  success: filecontents
+  #  failure: None
+  def catFile(self, remoteFile):
+    #p = self.runCmd(["shell", "cat", remoteFile])
+    #return p.stdout.read()
+    return self.getFile(remoteFile)
+
+  # external function
+  # returns:
+  #  success: output of pullfile, string
+  #  failure: None
+  def pullFile(self, remoteFile):
+    #return self.catFile(remoteFile)
+    return self.getFile(remoteFile)
+
+  # copy file from device (remoteFile) to host (localFile)
+  # external function
+  # returns:
+  #  success: output of pullfile, string
+  #  failure: None
+  def getFile(self, remoteFile, localFile = 'tmpfile_dm_adb'):
+    # TODO: add debug flags and allow for printing stdout
+    # self.runCmd(["pull", remoteFile, localFile])
+    try:
+
+      # First attempt to pull file regularly
+      outerr = self.runCmd(["pull",  remoteFile, localFile]).communicate()
+
+      # Now check stderr for errors
+      if outerr[1]:
+        errl = outerr[1].splitlines()
+        if (len(errl) == 1):
+          if (((errl[0].find("Permission denied") != -1)
+            or (errl[0].find("does not exist") != -1))
+            and self.useRunAs):
+            # If we lack permissions to read but have run-as, then we should try
+            # to copy the file to a world-readable location first before attempting
+            # to pull it again.
+            remoteTmpFile = self.getTempDir() + "/" + os.path.basename(remoteFile)
+            self.checkCmdAs(["shell", "dd", "if=" + remoteFile, "of=" + remoteTmpFile])
+            self.checkCmdAs(["shell", "chmod", "777", remoteTmpFile])
+            self.runCmd(["pull",  remoteTmpFile, localFile]).stdout.read()
+            # Clean up temporary file
+            self.checkCmdAs(["shell", "rm", remoteTmpFile])
+
+      f = open(localFile)
+      ret = f.read()
+      f.close()
+      return ret
+    except:
+      return None
+
+  # copy directory structure from device (remoteDir) to host (localDir)
+  # external function
+  # checkDir exists so that we don't create local directories if the
+  # remote directory doesn't exist but also so that we don't call isDir
+  # twice when recursing.
+  # returns:
+  #  success: list of files, string
+  #  failure: None
+  def getDirectory(self, remoteDir, localDir, checkDir=True):
+    ret = []
+    p = self.runCmd(["pull", remoteDir, localDir])
+    p.stdout.readline()
+    line = p.stdout.readline()
+    while (line):
+      els = line.split()
+      f = els[len(els) - 1]
+      i = f.find(localDir)
+      if (i != -1):
+        if (localDir[len(localDir) - 1] != '/'):
+          i = i + 1
+        f = f[i + len(localDir):]
+      i = f.find("/")
+      if (i > 0):
+        f = f[0:i]
+      ret.append(f)
+      line =  p.stdout.readline()
+    #the last line is a summary
+    if (len(ret) > 0):
+      ret.pop()
+    return ret
+
+
+
+  # true/false check if the two files have the same md5 sum
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def validateFile(self, remoteFile, localFile):
+    return self.getRemoteHash(remoteFile) == self.getLocalHash(localFile)
+
+  # return the md5 sum of a remote file
+  # internal function
+  # returns:
+  #  success: MD5 hash for given filename
+  #  failure: None
+  def getRemoteHash(self, filename):
+    data = self.runCmd(["shell", "ls", "-l", filename]).stdout.read()
+    return data.split()[3]
+
+  def getLocalHash(self, filename):
+    data = subprocess.Popen(["ls", "-l", filename], stdout=subprocess.PIPE).stdout.read()
+    return data.split()[4]
+
+  # Internal method to setup the device root and cache its value
+  def setupDeviceRoot(self):
+    # if self.deviceRoot is already set, create it if necessary, and use it
+    if self.deviceRoot:
+      if not self.dirExists(self.deviceRoot):
+        if not self.mkDir(self.deviceRoot):
+          raise DMError("Unable to create device root %s" % self.deviceRoot)
+      return
+
+    # /mnt/sdcard/tests is preferred to /data/local/tests, but this can be
+    # over-ridden by creating /data/local/tests
+    testRoot = "/data/local/tests"
+    if (self.dirExists(testRoot)):
+      self.deviceRoot = testRoot
+      return
+
+    for (basePath, subPath) in [('/mnt/sdcard', 'tests'),
+                                ('/data/local', 'tests')]:
+      if self.dirExists(basePath):
+        testRoot = os.path.join(basePath, subPath)
+        if self.mkDir(testRoot):
+          self.deviceRoot = testRoot
+          return
+
+    raise DMError("Unable to set up device root as /mnt/sdcard/tests "
+                  "or /data/local/tests")
+
+  # Gets the device root for the testing area on the device
+  # For all devices we will use / type slashes and depend on the device-agent
+  # to sort those out.  The agent will return us the device location where we
+  # should store things, we will then create our /tests structure relative to
+  # that returned path.
+  # Structure on the device is as follows:
+  # /tests
+  #       /<fennec>|<firefox>  --> approot
+  #       /profile
+  #       /xpcshell
+  #       /reftest
+  #       /mochitest
+  #
+  # external function
+  # returns:
+  #  success: path for device root
+  #  failure: None
+  def getDeviceRoot(self):
+    return self.deviceRoot
+
+  # Gets the temporary directory we are using on this device
+  # base on our device root, ensuring also that it exists.
+  #
+  # internal function
+  # returns:
+  #  success: path for temporary directory
+  #  failure: None
+  def getTempDir(self):
+    # Cache result to speed up operations depending
+    # on the temporary directory.
+    if self.tempDir == None:
+      self.tempDir = self.getDeviceRoot() + "/tmp"
+      if (not self.dirExists(self.tempDir)):
+        return self.mkDir(self.tempDir)
+
+    return self.tempDir
+
+  # Either we will have /tests/fennec or /tests/firefox but we will never have
+  # both.  Return the one that exists
+  # TODO: ensure we can support org.mozilla.firefox
+  # external function
+  # returns:
+  #  success: path for app root
+  #  failure: None
+  def getAppRoot(self, packageName):
+    devroot = self.getDeviceRoot()
+    if (devroot == None):
+      return None
+
+    if (packageName and self.dirExists('/data/data/' + packageName)):
+      self.packageName = packageName
+      return '/data/data/' + packageName
+    elif (self.packageName and self.dirExists('/data/data/' + self.packageName)):
+      return '/data/data/' + self.packageName
+
+    # Failure (either not installed or not a recognized platform)
+    print "devicemanagerADB: getAppRoot failed"
+    return None
+
+  # Gets the directory location on the device for a specific test type
+  # Type is one of: xpcshell|reftest|mochitest
+  # external function
+  # returns:
+  #  success: path for test root
+  #  failure: None
+  def getTestRoot(self, type):
+    devroot = self.getDeviceRoot()
+    if (devroot == None):
+      return None
+
+    if (re.search('xpcshell', type, re.I)):
+      self.testRoot = devroot + '/xpcshell'
+    elif (re.search('?(i)reftest', type)):
+      self.testRoot = devroot + '/reftest'
+    elif (re.search('?(i)mochitest', type)):
+      self.testRoot = devroot + '/mochitest'
+    return self.testRoot
+
+
+  # external function
+  # returns:
+  #  success: status from test agent
+  #  failure: None
+  def reboot(self, wait = False):
+    ret = self.runCmd(["reboot"]).stdout.read()
+    if (not wait):
+      return "Success"
+    countdown = 40
+    while (countdown > 0):
+      countdown
+      try:
+        self.checkCmd(["wait-for-device", "shell", "ls", "/sbin"])
+        return ret
+      except:
+        try:
+          self.checkCmd(["root"])
+        except:
+          time.sleep(1)
+          print "couldn't get root"
+    return "Success"
+
+  # external function
+  # returns:
+  #  success: text status from command or callback server
+  #  failure: None
+  def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000):
+    return self.runCmd(["install", "-r", appBundlePath]).stdout.read()
+
+  # external function
+  # returns:
+  #  success: time in ms
+  #  failure: None
+  def getCurrentTime(self):
+    timestr = self.runCmd(["shell", "date", "+%s"]).stdout.read().strip()
+    if (not timestr or not timestr.isdigit()):
+        return None
+    return str(int(timestr)*1000)
+
+  # Returns information about the device:
+  # Directive indicates the information you want to get, your choices are:
+  # os - name of the os
+  # id - unique id of the device
+  # uptime - uptime of the device
+  # systime - system time of the device
+  # screen - screen resolution
+  # memory - memory stats
+  # process - list of running processes (same as ps)
+  # disk - total, free, available bytes on disk
+  # power - power status (charge, battery temp)
+  # all - all of them - or call it with no parameters to get all the information
+  ### Note that uptimemillis is NOT supported, as there is no way to get this
+  ### data from the shell.
+  # returns:
+  #   success: dict of info strings by directive name
+  #   failure: {}
+  def getInfo(self, directive="all"):
+    ret = {}
+    if (directive == "id" or directive == "all"):
+      ret["id"] = self.runCmd(["get-serialno"]).stdout.read()
+    if (directive == "os" or directive == "all"):
+      ret["os"] = self.runCmd(["shell", "getprop", "ro.build.display.id"]).stdout.read()
+    if (directive == "uptime" or directive == "all"):
+      utime = self.runCmd(["shell", "uptime"]).stdout.read()
+      if (not utime):
+        raise DMError("error getting uptime")
+      utime = utime[9:]
+      hours = utime[0:utime.find(":")]
+      utime = utime[utime[1:].find(":") + 2:]
+      minutes = utime[0:utime.find(":")]
+      utime = utime[utime[1:].find(":") +  2:]
+      seconds = utime[0:utime.find(",")]
+      ret["uptime"] = ["0 days " + hours + " hours " + minutes + " minutes " + seconds + " seconds"]
+    if (directive == "process" or directive == "all"):
+      ret["process"] = self.runCmd(["shell", "ps"]).stdout.read()
+    if (directive == "systime" or directive == "all"):
+      ret["systime"] = self.runCmd(["shell", "date"]).stdout.read()
+    print ret
+    return ret
+
+  def runCmd(self, args):
+    # If we are not root but have run-as, and we're trying to execute
+    # a shell command then using run-as is the best we can do
+    finalArgs = [self.adbPath]
+    if self.deviceSerial:
+      finalArgs.extend(['-s', self.deviceSerial])
+    if (not self.haveRoot and self.useRunAs and args[0] == "shell" and args[1] != "run-as"):
+      args.insert(1, "run-as")
+      args.insert(2, self.packageName)
+    finalArgs.extend(args)
+    return subprocess.Popen(finalArgs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+  def runCmdAs(self, args):
+    if self.useRunAs:
+      args.insert(1, "run-as")
+      args.insert(2, self.packageName)
+    return self.runCmd(args)
+
+  # timeout is specified in seconds, and if no timeout is given, 
+  # we will run until the script returns
+  def checkCmd(self, args, timeout=None):
+    # If we are not root but have run-as, and we're trying to execute
+    # a shell command then using run-as is the best we can do
+    finalArgs = [self.adbPath]
+    if self.deviceSerial:
+      finalArgs.extend(['-s', self.deviceSerial])
+    if (not self.haveRoot and self.useRunAs and args[0] == "shell" and args[1] != "run-as"):
+      args.insert(1, "run-as")
+      args.insert(2, self.packageName)
+    finalArgs.extend(args)
+    if timeout:
+        timeout = int(timeout)
+        proc = subprocess.Popen(finalArgs)
+        start_time = time.time()
+        ret_code = proc.poll()
+        while ((time.time() - start_time) <= timeout) and ret_code == None:
+            time.sleep(1)
+            ret_code = proc.poll()
+        if ret_code == None:
+            proc.kill()
+            raise DMError("Timeout exceeded for checkCmd call")
+        return ret_code
+    return subprocess.check_call(finalArgs)
+
+  def checkCmdAs(self, args, timeout=None):
+    if (self.useRunAs):
+      args.insert(1, "run-as")
+      args.insert(2, self.packageName)
+    return self.checkCmd(args, timeout)
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def chmodDir(self, remoteDir):
+    if (self.isDir(remoteDir)):
+      files = self.listFiles(remoteDir.strip())
+      for f in files:
+        remoteEntry = remoteDir.strip() + "/" + f.strip()
+        if (self.isDir(remoteEntry)):
+          self.chmodDir(remoteEntry)
+        else:
+          self.checkCmdAs(["shell", "chmod", "777", remoteEntry])
+          print "chmod " + remoteEntry
+      self.checkCmdAs(["shell", "chmod", "777", remoteDir])
+      print "chmod " + remoteDir
+    else:
+      self.checkCmdAs(["shell", "chmod", "777", remoteDir.strip()])
+      print "chmod " + remoteDir.strip()
+    return True
+
+  def verifyADB(self):
+    # Check to see if adb itself can be executed.
+    if self.adbPath != 'adb':
+      if not os.access(self.adbPath, os.X_OK):
+        raise DMError("invalid adb path, or adb not executable: %s", self.adbPath)
+
+    try:
+      self.checkCmd(["version"])
+    except os.error, err:
+      raise DMError("unable to execute ADB (%s): ensure Android SDK is installed and adb is in your $PATH" % err)
+    except subprocess.CalledProcessError:
+      raise DMError("unable to execute ADB: ensure Android SDK is installed and adb is in your $PATH")
+
+  def verifyDevice(self):
+    # If there is a device serial number, see if adb is connected to it
+    if self.deviceSerial:
+      deviceStatus = None
+      proc = subprocess.Popen([self.adbPath, "devices"],
+                              stdout=subprocess.PIPE,
+                              stderr=subprocess.STDOUT)
+      for line in proc.stdout:
+        m = re.match('(.+)?\s+(.+)$', line)
+        if m:
+          if self.deviceSerial == m.group(1):
+            deviceStatus = m.group(2)
+      if deviceStatus == None:
+        raise DMError("device not found: %s" % self.deviceSerial)
+      elif deviceStatus != "device":
+        raise DMError("bad status for device %s: %s" % (self.deviceSerial,
+                                                        deviceStatus))
+
+    # Check to see if we can connect to device and run a simple command
+    try:
+      self.checkCmd(["shell", "echo"])
+    except subprocess.CalledProcessError:
+      raise DMError("unable to connect to device: is it plugged in?")
+
+  def verifyRoot(self):
+    # a test to see if we have root privs
+    p = self.runCmd(["shell", "id"])
+    response = p.stdout.readline()
+    response = response.rstrip()
+    response = response.split(' ')
+    if (response[0].find('uid=0') < 0 or response[1].find('gid=0') < 0):
+      print "NOT running as root ", response[0].find('uid=0')
+      raise DMError("not running as root")
+
+    self.haveRoot = True
+
+  def isCpAvailable(self):
+    # Some Android systems may not have a cp command installed,
+    # or it may not be executable by the user.
+    data = self.runCmd(["shell", "cp"]).stdout.read()
+    if (re.search('Usage', data)):
+      return True
+    else:
+      data = self.runCmd(["shell", "dd", "-"]).stdout.read()
+      if (re.search('unknown operand', data)):
+        print "'cp' not found, but 'dd' was found as a replacement"
+        self.useDDCopy = True
+        return True
+      print "unable to execute 'cp' on device; consider installing busybox from Android Market"
+      return False
+
+  def verifyRunAs(self):
+    # If a valid package name is available, and certain other
+    # conditions are met, devicemanagerADB can execute file operations
+    # via the "run-as" command, so that pushed files and directories 
+    # are created by the uid associated with the package, more closely
+    # echoing conditions encountered by Fennec at run time.
+    # Check to see if run-as can be used here, by verifying a 
+    # file copy via run-as.
+    self.useRunAs = False
+    devroot = self.getDeviceRoot()
+    if (self.packageName and self.isCpAvailable() and devroot):
+      tmpDir = self.getTempDir()
+
+      # The problem here is that run-as doesn't cause a non-zero exit code
+      # when failing because of a non-existent or non-debuggable package :(
+      runAsOut = self.runCmd(["shell", "run-as", self.packageName, "mkdir", devroot + "/sanity"]).communicate()[0]
+      if runAsOut.startswith("run-as:") and ("not debuggable" in runAsOut or
+                                             "is unknown" in runAsOut):
+        raise DMError("run-as failed sanity check")
+
+      tmpfile = tempfile.NamedTemporaryFile()
+      self.checkCmd(["push", tmpfile.name, tmpDir + "/tmpfile"])
+      if self.useDDCopy:
+        self.checkCmd(["shell", "run-as", self.packageName, "dd", "if=" + tmpDir + "/tmpfile", "of=" + devroot + "/sanity/tmpfile"])
+      else:
+        self.checkCmd(["shell", "run-as", self.packageName, "cp", tmpDir + "/tmpfile", devroot + "/sanity"])
+      if (self.fileExists(devroot + "/sanity/tmpfile")):
+        print "will execute commands via run-as " + self.packageName
+        self.useRunAs = True
+      self.checkCmd(["shell", "rm", devroot + "/tmp/tmpfile"])
+      self.checkCmd(["shell", "run-as", self.packageName, "rm", "-r", devroot + "/sanity"])
+
+  def isUnzipAvailable(self):
+    data = self.runCmdAs(["shell", "unzip"]).stdout.read()
+    if (re.search('Usage', data)):
+      return True
+    else:
+      return False
+
+  def isLocalZipAvailable(self):
+    try:
+      subprocess.check_call(["zip", "-?"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    except:
+      return False
+    return True
+
+  def verifyZip(self):
+    # If "zip" can be run locally, and "unzip" can be run remotely, then pushDir
+    # can use these to push just one file per directory -- a significant
+    # optimization for large directories.
+    self.useZip = False
+    if (self.isUnzipAvailable() and self.isLocalZipAvailable()):
+      print "will use zip to push directories"
+      self.useZip = True
+    else:
+      raise DMError("zip not available")
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
@@ -0,0 +1,1240 @@
+# 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/.
+
+import select
+import socket
+import SocketServer
+import time
+import os
+import re
+import posixpath
+import subprocess
+from threading import Thread
+import StringIO
+from devicemanager import DeviceManager, FileError, NetworkTools, _pop_last_line
+import errno
+from distutils.version import StrictVersion
+
+class AgentError(Exception):
+  "SUTAgent-specific exception."
+
+  def __init__(self, msg= '', fatal = False):
+    self.msg = msg
+    self.fatal = fatal
+
+  def __str__(self):
+    return self.msg
+
+class DeviceManagerSUT(DeviceManager):
+  host = ''
+  port = 0
+  debug = 2
+  retries = 0
+  tempRoot = os.getcwd()
+  base_prompt = '$>'
+  base_prompt_re = '\$\>'
+  prompt_sep = '\x00'
+  prompt_regex = '.*(' + base_prompt_re + prompt_sep + ')'
+  agentErrorRE = re.compile('^##AGENT-WARNING##\ ?(.*)')
+
+  # TODO: member variable to indicate error conditions.
+  # This should be set to a standard error from the errno module.
+  # So, for example, when an error occurs because of a missing file/directory,
+  # before returning, the function would do something like 'self.error = errno.ENOENT'.
+  # The error would be set where appropriate--so sendCMD() could set socket errors,
+  # pushFile() and other file-related commands could set filesystem errors, etc.
+
+  def __init__(self, host, port = 20701, retrylimit = 5, deviceRoot = None):
+    self.host = host
+    self.port = port
+    self.retrylimit = retrylimit
+    self.retries = 0
+    self._sock = None
+    self.deviceRoot = deviceRoot
+    if self.getDeviceRoot() == None:
+      raise BaseException("Failed to connect to SUT Agent and retrieve the device root.")
+    try:
+      verstring = self.runCmds([{ 'cmd': 'ver' }])
+      self.agentVersion = re.sub('SUTAgentAndroid Version ', '', verstring)
+    except AgentError, err:
+      raise BaseException("Failed to get SUTAgent version")
+
+  def _cmdNeedsResponse(self, cmd):
+    """ Not all commands need a response from the agent:
+        * rebt obviously doesn't get a response
+        * uninstall performs a reboot to ensure starting in a clean state and
+          so also doesn't look for a response
+    """
+    noResponseCmds = [re.compile('^rebt'),
+                      re.compile('^uninst .*$'),
+                      re.compile('^pull .*$')]
+
+    for c in noResponseCmds:
+      if (c.match(cmd)):
+        return False
+
+    # If the command is not in our list, then it gets a response
+    return True
+
+  def _stripPrompt(self, data):
+    '''
+    internal function
+    take a data blob and strip instances of the prompt '$>\x00'
+    '''
+    promptre = re.compile(self.prompt_regex + '.*')
+    retVal = []
+    lines = data.split('\n')
+    for line in lines:
+      foundPrompt = False
+      try:
+        while (promptre.match(line)):
+          foundPrompt = True
+          pieces = line.split(self.prompt_sep)
+          index = pieces.index('$>')
+          pieces.pop(index)
+          line = self.prompt_sep.join(pieces)
+      except(ValueError):
+        pass
+
+      # we don't want to append lines that are blank after stripping the
+      # prompt (those are basically "prompts")
+      if not foundPrompt or line:
+        retVal.append(line)
+
+    return '\n'.join(retVal)
+
+  def _shouldCmdCloseSocket(self, cmd):
+    """ Some commands need to close the socket after they are sent:
+    * rebt
+    * uninst
+    * quit
+    """
+    socketClosingCmds = [re.compile('^quit.*'),
+                         re.compile('^rebt.*'),
+                         re.compile('^uninst .*$')]
+
+    for c in socketClosingCmds:
+      if (c.match(cmd)):
+        return True
+
+    return False
+
+  def sendCmds(self, cmdlist, outputfile, timeout = None):
+    '''
+    a wrapper for _doCmds that loops up to self.retrylimit iterations.
+    this allows us to move the retry logic outside of the _doCmds() to make it
+    easier for debugging in the future.
+    note that since cmdlist is a list of commands, they will all be retried if
+    one fails.  this is necessary in particular for pushFile(), where we don't want
+    to accidentally send extra data if a failure occurs during data transmission.
+    '''
+    if timeout:
+      raise NotImplementedError("'timeout' parameter is not yet supported")
+    while self.retries < self.retrylimit:
+      try:
+        self._doCmds(cmdlist, outputfile, timeout)
+        return
+      except AgentError, err:
+        # re-raise error if it's fatal (i.e. the device got the command but
+        # couldn't execute it). retry otherwise
+        if err.fatal:
+          raise err
+        if self.debug >= 2:
+          print err
+        self.retries += 1
+
+    raise AgentError("unable to connect to %s after %s attempts" % (self.host, self.retrylimit))
+
+  def runCmds(self, cmdlist, timeout = None):
+    '''
+    similar to sendCmds, but just returns any output as a string instead of
+    writing to a file. this is normally what you want to call to send a set
+    of commands to the agent
+    '''
+    outputfile = StringIO.StringIO()
+    self.sendCmds(cmdlist, outputfile, timeout)
+    outputfile.seek(0)
+    return outputfile.read()
+
+  def _doCmds(self, cmdlist, outputfile, timeout):
+    promptre = re.compile(self.prompt_regex + '$')
+    shouldCloseSocket = False
+    recvGuard = 1000
+
+    if not self._sock:
+      try:
+        if self.debug >= 1:
+          print "reconnecting socket"
+        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+      except socket.error, msg:
+        self._sock = None
+        raise AgentError("unable to create socket: "+str(msg))
+
+      try:
+        self._sock.connect((self.host, int(self.port)))
+        self._sock.recv(1024)
+      except socket.error, msg:
+        self._sock.close()
+        self._sock = None
+        raise AgentError("unable to connect socket: "+str(msg))
+
+    for cmd in cmdlist:
+      cmdline = '%s\r\n' % cmd['cmd']
+
+      try:
+        sent = self._sock.send(cmdline)
+        if sent != len(cmdline):
+          raise AgentError("ERROR: our cmd was %s bytes and we "
+                           "only sent %s" % (len(cmdline), sent))
+        if cmd.get('data'):
+          sent = self._sock.send(cmd['data'])
+          if sent != len(cmd['data']):
+              raise AgentError("ERROR: we had %s bytes of data to send, but "
+                               "only sent %s" % (len(cmd['data']), sent))
+
+        if (self.debug >= 4): print "sent cmd: " + str(cmd['cmd'])
+      except socket.error, msg:
+        self._sock.close()
+        self._sock = None
+        if self.debug >= 1:
+          print "Error sending data to socket. cmd="+str(cmd['cmd'])+"; err="+str(msg)
+        return False
+
+      # Check if the command should close the socket
+      shouldCloseSocket = self._shouldCmdCloseSocket(cmd['cmd'])
+
+      # Handle responses from commands
+      if (self._cmdNeedsResponse(cmd['cmd'])):
+        found = False
+        loopguard = 0
+        data = ""
+
+        while (found == False and (loopguard < recvGuard)):
+          temp = ''
+          if (self.debug >= 4): print "recv'ing..."
+
+          # Get our response
+          try:
+             # Wait up to a second for socket to become ready for reading...
+            if select.select([self._sock], [], [], 1)[0]:
+                temp = self._sock.recv(1024)
+            if (self.debug >= 4): print "response: " + str(temp)
+          except socket.error, err:
+            self._sock.close()
+            self._sock = None
+            # This error shows up with we have our tegra rebooted.
+            if err[0] == errno.ECONNRESET:
+              raise AgentError("Automation error: Error receiving data from socket (possible reboot). cmd=%s; err=%s" % (cmd, err))
+            raise AgentError("Error receiving data from socket. cmd=%s; err=%s" % (cmd, err))
+
+          data += temp
+
+          # If something goes wrong in the agent it will send back a string that
+          # starts with '##AGENT-WARNING##'
+          errorMatch = self.agentErrorRE.match(data)
+          if errorMatch:
+            raise AgentError("Agent Error processing command '%s'; err='%s'" %
+                             (cmd['cmd'], errorMatch.group(1)), fatal=True)
+
+          for line in data.splitlines():
+            if promptre.match(line):
+              found = True
+              data = self._stripPrompt(data)
+              break
+
+          # periodically flush data to output file to make sure it doesn't get
+          # too big/unwieldly
+          if len(data) > 1024:
+              outputfile.write(data[0:1024])
+              data = data[1024:]
+
+          # If we violently lose the connection to the device, this loop tends to spin,
+          # this guard prevents that
+          if (temp == ''):
+            loopguard += 1
+
+        # Write any remaining data to outputfile
+        outputfile.write(data)
+
+    if shouldCloseSocket:
+      try:
+        self._sock.close()
+        self._sock = None
+      except:
+        self._sock = None
+        raise AgentError("Error closing socket")
+
+  # external function: executes shell command on device
+  # returns:
+  # success: <return code>
+  # failure: None
+  def shell(self, cmd, outputfile, env=None, cwd=None, timeout=None, root=False):
+    cmdline = self._escapedCommandLine(cmd)
+    if env:
+      cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
+
+    haveExecSu = (StrictVersion(self.agentVersion) >= StrictVersion('1.13'))
+
+    # Depending on agent version we send one of the following commands here:
+    # * exec (run as normal user)
+    # * execsu (run as privileged user)
+    # * execcwd (run as normal user from specified directory)
+    # * execcwdsu (run as privileged user from specified directory)
+
+    cmd = "exec"
+    if cwd:
+      cmd += "cwd"
+    if root and haveExecSu:
+      cmd += "su"
+
+    try:
+      if cwd:
+        self.sendCmds([{ 'cmd': '%s %s %s' % (cmd, cwd, cmdline) }], outputfile, timeout)
+      else:
+        if (not root) or haveExecSu:
+          self.sendCmds([{ 'cmd': '%s %s' % (cmd, cmdline) }], outputfile, timeout)
+        else:
+          # need to manually inject su -c for backwards compatibility (this may
+          # not work on ICS or above!!)
+          # (FIXME: this backwards compatibility code is really ugly and should
+          # be deprecated at some point in the future)
+          self.sendCmds([ { 'cmd': '%s su -c "%s"' % (cmd, cmdline) }], outputfile,
+                          timeout)
+    except AgentError:
+      return None
+
+    # dig through the output to get the return code
+    lastline = _pop_last_line(outputfile)
+    if lastline:
+      m = re.search('return code \[([0-9]+)\]', lastline)
+      if m:
+        return int(m.group(1))
+
+    # woops, we couldn't find an end of line/return value
+    return None
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def pushFile(self, localname, destname):
+    if (os.name == "nt"):
+      destname = destname.replace('\\', '/')
+
+    if (self.debug >= 3): print "in push file with: " + localname + ", and: " + destname
+    if (self.dirExists(destname)):
+      if (not destname.endswith('/')):
+        destname = destname + '/'
+      destname = destname + os.path.basename(localname)
+    if (self.validateFile(destname, localname) == True):
+      if (self.debug >= 3): print "files are validated"
+      return True
+
+    if self.mkDirs(destname) == None:
+      print "unable to make dirs: " + destname
+      return False
+
+    if (self.debug >= 3): print "sending: push " + destname
+
+    filesize = os.path.getsize(localname)
+    f = open(localname, 'rb')
+    data = f.read()
+    f.close()
+
+    try:
+      retVal = self.runCmds([{ 'cmd': 'push ' + destname + ' ' + str(filesize),
+                               'data': data }])
+    except AgentError, e:
+      print "error pushing file: %s" % e.msg
+      return False
+
+    if (self.debug >= 3): print "push returned: " + str(retVal)
+
+    validated = False
+    if (retVal):
+      retline = retVal.strip()
+      if (retline == None):
+        # Then we failed to get back a hash from agent, try manual validation
+        validated = self.validateFile(destname, localname)
+      else:
+        # Then we obtained a hash from push
+        localHash = self.getLocalHash(localname)
+        if (str(localHash) == str(retline)):
+          validated = True
+    else:
+      # We got nothing back from sendCMD, try manual validation
+      validated = self.validateFile(destname, localname)
+
+    if (validated):
+      if (self.debug >= 3): print "Push File Validated!"
+      return True
+    else:
+      if (self.debug >= 2): print "Push File Failed to Validate!"
+      return False
+
+  # external function
+  # returns:
+  #  success: directory name
+  #  failure: None
+  def mkDir(self, name):
+    if (self.dirExists(name)):
+      return name
+    else:
+      try:
+        retVal = self.runCmds([{ 'cmd': 'mkdr ' + name }])
+      except AgentError:
+        retVal = None
+      return retVal
+
+  # push localDir from host to remoteDir on the device
+  # external function
+  # returns:
+  #  success: remoteDir
+  #  failure: None
+  def pushDir(self, localDir, remoteDir):
+    if (self.debug >= 2): print "pushing directory: %s to %s" % (localDir, remoteDir)
+    for root, dirs, files in os.walk(localDir, followlinks=True):
+      parts = root.split(localDir)
+      for file in files:
+        remoteRoot = remoteDir + '/' + parts[1]
+        if (remoteRoot.endswith('/')):
+          remoteName = remoteRoot + file
+        else:
+          remoteName = remoteRoot + '/' + file
+        if (parts[1] == ""): remoteRoot = remoteDir
+        if (self.pushFile(os.path.join(root, file), remoteName) == False):
+          # retry once
+          self.removeFile(remoteName)
+          if (self.pushFile(os.path.join(root, file), remoteName) == False):
+            return None
+    return remoteDir
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def dirExists(self, dirname):
+    match = ".*" + dirname.replace('^', '\^') + "$"
+    dirre = re.compile(match)
+    try:
+      data = self.runCmds([ { 'cmd': 'cd ' + dirname }, { 'cmd': 'cwd' }])
+    except AgentError:
+      return False
+
+    found = False
+    for d in data.splitlines():
+      if (dirre.match(d)):
+        found = True
+
+    return found
+
+  # Because we always have / style paths we make this a lot easier with some
+  # assumptions
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def fileExists(self, filepath):
+    s = filepath.split('/')
+    containingpath = '/'.join(s[:-1])
+    listfiles = self.listFiles(containingpath)
+    for f in listfiles:
+      if (f == s[-1]):
+        return True
+    return False
+
+  # list files on the device, requires cd to directory first
+  # external function
+  # returns:
+  #  success: array of filenames, ['file1', 'file2', ...]
+  #  failure: []
+  def listFiles(self, rootdir):
+    rootdir = rootdir.rstrip('/')
+    if (self.dirExists(rootdir) == False):
+      return []
+    try:
+      data = self.runCmds([{ 'cmd': 'cd ' + rootdir }, { 'cmd': 'ls' }])
+    except AgentError:
+      return []
+
+    files = filter(lambda x: x, data.splitlines())
+    if len(files) == 1 and files[0] == '<empty>':
+      # special case on the agent: empty directories return just the string "<empty>"
+      return []
+    return files
+
+  # external function
+  # returns:
+  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
+  #  failure: None
+  def removeFile(self, filename):
+    if (self.debug>= 2): print "removing file: " + filename
+    try:
+      retVal = self.runCmds([{ 'cmd': 'rm ' + filename }])
+    except AgentError:
+      return None
+
+    return retVal
+
+  # does a recursive delete of directory on the device: rm -Rf remoteDir
+  # external function
+  # returns:
+  #  success: output of telnet, i.e. "removing file: /mnt/sdcard/tests/test.txt"
+  #  failure: None
+  def removeDir(self, remoteDir):
+    try:
+      retVal = self.runCmds([{ 'cmd': 'rmdr ' + remoteDir }])
+    except AgentError:
+      return None
+
+    return retVal
+
+  # external function
+  # returns:
+  #  success: array of process tuples
+  #  failure: []
+  def getProcessList(self):
+    try:
+      data = self.runCmds([{ 'cmd': 'ps' }])
+    except AgentError:
+      return []
+
+    files = []
+    for line in data.splitlines():
+      if line:
+        pidproc = line.strip().split()
+        if (len(pidproc) == 2):
+          files += [[pidproc[0], pidproc[1]]]
+        elif (len(pidproc) == 3):
+          #android returns <userID> <procID> <procName>
+          files += [[pidproc[1], pidproc[2], pidproc[0]]]
+    return files
+
+  # external function
+  # DEPRECATED: Use shell() or launchApplication() for new code
+  # returns:
+  #  success: pid
+  #  failure: None
+  def fireProcess(self, appname, failIfRunning=False):
+    if (not appname):
+      if (self.debug >= 1): print "WARNING: fireProcess called with no command to run"
+      return None
+
+    if (self.debug >= 2): print "FIRE PROC: '" + appname + "'"
+
+    if (self.processExist(appname) != None):
+      print "WARNING: process %s appears to be running already\n" % appname
+      if (failIfRunning):
+        return None
+
+    try:
+      self.runCmds([{ 'cmd': 'exec ' + appname }])
+    except AgentError:
+      return None
+
+    # The 'exec' command may wait for the process to start and end, so checking
+    # for the process here may result in process = None.
+    process = self.processExist(appname)
+    if (self.debug >= 4): print "got pid: %s for process: %s" % (process, appname)
+
+    return process
+
+  # external function
+  # DEPRECATED: Use shell() or launchApplication() for new code
+  # returns:
+  #  success: output filename
+  #  failure: None
+  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
+    if not cmd:
+      if (self.debug >= 1): print "WARNING: launchProcess called without command to run"
+      return None
+
+    cmdline = subprocess.list2cmdline(cmd)
+    if (outputFile == "process.txt" or outputFile == None):
+      outputFile = self.getDeviceRoot();
+      if outputFile is None:
+        return None
+      outputFile += "/process.txt"
+      cmdline += " > " + outputFile
+
+    # Prepend our env to the command
+    cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
+
+    if self.fireProcess(cmdline, failIfRunning) is None:
+      return None
+    return outputFile
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def killProcess(self, appname, forceKill=False):
+    if forceKill:
+      print "WARNING: killProcess(): forceKill parameter unsupported on SUT"
+    try:
+      self.runCmds([{ 'cmd': 'kill ' + appname }])
+    except AgentError:
+      return False
+
+    return True
+
+  # external function
+  # returns:
+  #  success: tmpdir, string
+  #  failure: None
+  def getTempDir(self):
+    try:
+      data = self.runCmds([{ 'cmd': 'tmpd' }])
+    except AgentError:
+      return None
+
+    return data.strip()
+
+  # external function
+  # returns:
+  #  success: filecontents
+  #  failure: None
+  def catFile(self, remoteFile):
+    try:
+      data = self.runCmds([{ 'cmd': 'cat ' + remoteFile }])
+    except AgentError:
+      return None
+
+    return data
+
+  # external function
+  # returns:
+  #  success: output of pullfile, string
+  #  failure: None
+  def pullFile(self, remoteFile):
+    """Returns contents of remoteFile using the "pull" command.
+    The "pull" command is different from other commands in that DeviceManager
+    has to read a certain number of bytes instead of just reading to the
+    next prompt.  This is more robust than the "cat" command, which will be
+    confused if the prompt string exists within the file being catted.
+    However it means we can't use the response-handling logic in sendCMD().
+    """
+
+    def err(error_msg):
+        err_str = 'error returned from pull: %s' % error_msg
+        print err_str
+        self._sock = None
+        raise FileError(err_str)
+
+    # FIXME: We could possibly move these socket-reading functions up to
+    # the class level if we wanted to refactor sendCMD().  For now they are
+    # only used to pull files.
+
+    def uread(to_recv, error_msg):
+      """ unbuffered read """
+      try:
+        data = self._sock.recv(to_recv)
+        if not data:
+          err(error_msg)
+          return None
+        return data
+      except:
+        err(error_msg)
+        return None
+
+    def read_until_char(c, buffer, error_msg):
+      """ read until 'c' is found; buffer rest """
+      while not '\n' in buffer:
+        data = uread(1024, error_msg)
+        if data == None:
+          err(error_msg)
+          return ('', '', '')
+        buffer += data
+      return buffer.partition(c)
+
+    def read_exact(total_to_recv, buffer, error_msg):
+      """ read exact number of 'total_to_recv' bytes """
+      while len(buffer) < total_to_recv:
+        to_recv = min(total_to_recv - len(buffer), 1024)
+        data = uread(to_recv, error_msg)
+        if data == None:
+          return None
+        buffer += data
+      return buffer
+
+    prompt = self.base_prompt + self.prompt_sep
+    buffer = ''
+
+    # expected return value:
+    # <filename>,<filesize>\n<filedata>
+    # or, if error,
+    # <filename>,-1\n<error message>
+    try:
+      # just send the command first, we read the response inline below
+      self.runCmds([{ 'cmd': 'pull ' + remoteFile }])
+    except AgentError:
+      return None
+
+    # read metadata; buffer the rest
+    metadata, sep, buffer = read_until_char('\n', buffer, 'could not find metadata')
+    if not metadata:
+      return None
+    if self.debug >= 3:
+      print 'metadata: %s' % metadata
+
+    filename, sep, filesizestr = metadata.partition(',')
+    if sep == '':
+      err('could not find file size in returned metadata')
+      return None
+    try:
+        filesize = int(filesizestr)
+    except ValueError:
+      err('invalid file size in returned metadata')
+      return None
+
+    if filesize == -1:
+      # read error message
+      error_str, sep, buffer = read_until_char('\n', buffer, 'could not find error message')
+      if not error_str:
+        return None
+      # prompt should follow
+      read_exact(len(prompt), buffer, 'could not find prompt')
+      print "DeviceManager: error pulling file '%s': %s" % (remoteFile, error_str)
+      return None
+
+    # read file data
+    total_to_recv = filesize + len(prompt)
+    buffer = read_exact(total_to_recv, buffer, 'could not get all file data')
+    if buffer == None:
+      return None
+    if buffer[-len(prompt):] != prompt:
+      err('no prompt found after file data--DeviceManager may be out of sync with agent')
+      return buffer
+    return buffer[:-len(prompt)]
+
+  # copy file from device (remoteFile) to host (localFile)
+  # external function
+  # returns:
+  #  success: output of pullfile, string
+  #  failure: None
+  def getFile(self, remoteFile, localFile = ''):
+    if localFile == '':
+      localFile = os.path.join(self.tempRoot, "temp.txt")
+
+    try:
+      retVal = self.pullFile(remoteFile)
+    except:
+      return None
+
+    if (retVal is None):
+      return None
+
+    fhandle = open(localFile, 'wb')
+    fhandle.write(retVal)
+    fhandle.close()
+    if not self.validateFile(remoteFile, localFile):
+      print 'failed to validate file when downloading %s!' % remoteFile
+      return None
+    return retVal
+
+  # copy directory structure from device (remoteDir) to host (localDir)
+  # external function
+  # checkDir exists so that we don't create local directories if the
+  # remote directory doesn't exist but also so that we don't call isDir
+  # twice when recursing.
+  # returns:
+  #  success: list of files, string
+  #  failure: None
+  def getDirectory(self, remoteDir, localDir, checkDir=True):
+    if (self.debug >= 2): print "getting files in '" + remoteDir + "'"
+    if checkDir:
+      try:
+        is_dir = self.isDir(remoteDir)
+      except FileError:
+        return None
+      if not is_dir:
+        return None
+
+    filelist = self.listFiles(remoteDir)
+    if (self.debug >= 3): print filelist
+    if not os.path.exists(localDir):
+      os.makedirs(localDir)
+
+    for f in filelist:
+      if f == '.' or f == '..':
+        continue
+      remotePath = remoteDir + '/' + f
+      localPath = os.path.join(localDir, f)
+      try:
+        is_dir = self.isDir(remotePath)
+      except FileError:
+        print 'isdir failed on file "%s"; continuing anyway...' % remotePath
+        continue
+      if is_dir:
+        if (self.getDirectory(remotePath, localPath, False) == None):
+          print 'failed to get directory "%s"' % remotePath
+          return None
+      else:
+        # It's sometimes acceptable to have getFile() return None, such as
+        # when the agent encounters broken symlinks.
+        # FIXME: This should be improved so we know when a file transfer really
+        # failed.
+        if self.getFile(remotePath, localPath) == None:
+          print 'failed to get file "%s"; continuing anyway...' % remotePath
+    return filelist
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  #  Throws a FileError exception when null (invalid dir/filename)
+  def isDir(self, remotePath):
+    try:
+      data = self.runCmds([{ 'cmd': 'isdir ' + remotePath }])
+    except AgentError:
+      # normally there should be no error here; a nonexistent file/directory will
+      # return the string "<filename>: No such file or directory".
+      # However, I've seen AGENT-WARNING returned before.
+      return False
+
+    retVal = data.strip()
+    if not retVal:
+      raise FileError('isdir returned null')
+    return retVal == 'TRUE'
+
+  # true/false check if the two files have the same md5 sum
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def validateFile(self, remoteFile, localFile):
+    remoteHash = self.getRemoteHash(remoteFile)
+    localHash = self.getLocalHash(localFile)
+
+    if (remoteHash == None):
+      return False
+
+    if (remoteHash == localHash):
+      return True
+
+    return False
+
+  # return the md5 sum of a remote file
+  # internal function
+  # returns:
+  #  success: MD5 hash for given filename
+  #  failure: None
+  def getRemoteHash(self, filename):
+    try:
+      data = self.runCmds([{ 'cmd': 'hash ' + filename }])
+    except AgentError:
+      return None
+
+    retVal = None
+    if data:
+      retVal = data.strip()
+    if self.debug >= 3:
+      print "remote hash returned: '%s'" % retVal
+    return retVal
+
+  # Gets the device root for the testing area on the device
+  # For all devices we will use / type slashes and depend on the device-agent
+  # to sort those out.  The agent will return us the device location where we
+  # should store things, we will then create our /tests structure relative to
+  # that returned path.
+  # Structure on the device is as follows:
+  # /tests
+  #       /<fennec>|<firefox>  --> approot
+  #       /profile
+  #       /xpcshell
+  #       /reftest
+  #       /mochitest
+  #
+  # external function
+  # returns:
+  #  success: path for device root
+  #  failure: None
+  def getDeviceRoot(self):
+    if self.deviceRoot:
+      deviceRoot = self.deviceRoot
+    else:
+      try:
+        data = self.runCmds([{ 'cmd': 'testroot' }])
+      except:
+        return None
+
+      deviceRoot = data.strip() + '/tests'
+
+    if (not self.dirExists(deviceRoot)):
+      if (self.mkDir(deviceRoot) == None):
+        return None
+
+    self.deviceRoot = deviceRoot
+    return self.deviceRoot
+
+  def getAppRoot(self, packageName):
+    try:
+      data = self.runCmds([{ 'cmd': 'getapproot '+packageName }])
+    except:
+      return None
+
+    return data.strip()
+
+  # external function
+  # returns:
+  #  success: output of unzip command
+  #  failure: None
+  def unpackFile(self, file_path, dest_dir=None):
+    devroot = self.getDeviceRoot()
+    if (devroot == None):
+      return None
+
+    # if no dest_dir is passed in just set it to file_path's folder
+    if not dest_dir:
+      dest_dir = posixpath.dirname(file_path)
+
+    if dest_dir[-1] != '/':
+      dest_dir += '/'
+
+    try:
+      data = self.runCmds([{ 'cmd': 'unzp %s %s' % (file_path, dest_dir)}])
+    except AgentError:
+      return None
+
+    return data
+
+  # external function
+  # returns:
+  #  success: status from test agent
+  #  failure: None
+  def reboot(self, ipAddr=None, port=30000):
+    cmd = 'rebt'
+
+    if (self.debug > 3): print "INFO: sending rebt command"
+
+    if (ipAddr is not None):
+    #create update.info file:
+      try:
+        destname = '/data/data/com.mozilla.SUTAgentAndroid/files/update.info'
+        data = "%s,%s\rrebooting\r" % (ipAddr, port)
+        self.runCmds([{ 'cmd': 'push %s %s' % (destname, len(data)),
+                        'data': data }])
+      except AgentError:
+        return None
+
+      ip, port = self.getCallbackIpAndPort(ipAddr, port)
+      cmd += " %s %s" % (ip, port)
+      # Set up our callback server
+      callbacksvr = callbackServer(ip, port, self.debug)
+
+    try:
+      status = self.runCmds([{ 'cmd': cmd }])
+    except AgentError:
+      return None
+
+    if (ipAddr is not None):
+      status = callbacksvr.disconnect()
+
+    if (self.debug > 3): print "INFO: rebt- got status back: " + str(status)
+    return status
+
+  # Returns information about the device:
+  # Directive indicates the information you want to get, your choices are:
+  # os - name of the os
+  # id - unique id of the device
+  # uptime - uptime of the device
+  # uptimemillis - uptime of the device in milliseconds (SUTAgent 1.11+)
+  # systime - system time of the device
+  # screen - screen resolution
+  # rotation - rotation of the device (in degrees)
+  # memory - memory stats
+  # process - list of running processes (same as ps)
+  # disk - total, free, available bytes on disk
+  # power - power status (charge, battery temp)
+  # all - all of them - or call it with no parameters to get all the information
+  # returns:
+  #   success: dict of info strings by directive name
+  #   failure: {}
+  def getInfo(self, directive=None):
+    data = None
+    result = {}
+    collapseSpaces = re.compile('  +')
+
+    directives = ['os','id','uptime','uptimemillis','systime','screen',
+                  'rotation','memory','process','disk','power']
+    if (directive in directives):
+      directives = [directive]
+
+    for d in directives:
+      try:
+        data = self.runCmds([{ 'cmd': 'info ' + d }])
+      except AgentError:
+        return result
+
+      if (data is None):
+        continue
+      data = collapseSpaces.sub(' ', data)
+      result[d] = data.split('\n')
+
+    # Get rid of any 0 length members of the arrays
+    for k, v in result.iteritems():
+      result[k] = filter(lambda x: x != '', result[k])
+
+    # Format the process output
+    if 'process' in result:
+      proclist = []
+      for l in result['process']:
+        if l:
+          proclist.append(l.split('\t'))
+      result['process'] = proclist
+
+    if (self.debug >= 3): print "results: " + str(result)
+    return result
+
+  """
+  Installs the application onto the device
+  Application bundle - path to the application bundle on the device
+  Destination - destination directory of where application should be
+                installed to (optional)
+  Returns None for success, or output if known failure
+  """
+  # external function
+  # returns:
+  #  success: output from agent for inst command
+  #  failure: None
+  def installApp(self, appBundlePath, destPath=None):
+    cmd = 'inst ' + appBundlePath
+    if destPath:
+      cmd += ' ' + destPath
+    try:
+      data = self.runCmds([{ 'cmd': cmd }])
+    except AgentError:
+      return None
+
+    f = re.compile('Failure')
+    for line in data.split():
+      if (f.match(line)):
+        return data
+    return None
+
+  """
+  Uninstalls the named application from device and causes a reboot.
+  Takes an optional argument of installation path - the path to where the application
+  was installed.
+  Returns True, but it doesn't mean anything other than the command was sent,
+  the reboot happens and we don't know if this succeeds or not.
+  """
+  # external function
+  # returns:
+  #  success: True
+  #  failure: None
+  def uninstallAppAndReboot(self, appName, installPath=None):
+    cmd = 'uninst ' + appName
+    if installPath:
+      cmd += ' ' + installPath
+    try:
+      data = self.runCmds([{ 'cmd': cmd }])
+    except AgentError:
+      return None
+
+    if (self.debug > 3): print "uninstallAppAndReboot: " + str(data)
+    return True
+
+  """
+  Updates the application on the device.
+  Application bundle - path to the application bundle on the device
+  Process name of application - used to end the process if the applicaiton is
+                                currently running
+  Destination - Destination directory to where the application should be
+                installed (optional)
+  ipAddr - IP address to await a callback ping to let us know that the device has updated
+           properly - defaults to current IP.
+  port - port to await a callback ping to let us know that the device has updated properly
+         defaults to 30000, and counts up from there if it finds a conflict
+  Returns True if succeeds, False if not
+  """
+  # external function
+  # returns:
+  #  success: text status from command or callback server
+  #  failure: None
+  def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000):
+    status = None
+    cmd = 'updt '
+    if (processName == None):
+      # Then we pass '' for processName
+      cmd += "'' " + appBundlePath
+    else:
+      cmd += processName + ' ' + appBundlePath
+
+    if (destPath):
+      cmd += " " + destPath
+
+    if (ipAddr is not None):
+      ip, port = self.getCallbackIpAndPort(ipAddr, port)
+      cmd += " %s %s" % (ip, port)
+      # Set up our callback server
+      callbacksvr = callbackServer(ip, port, self.debug)
+
+    if (self.debug >= 3): print "INFO: updateApp using command: " + str(cmd)
+
+    try:
+      status = self.runCmds([{ 'cmd': cmd }])
+    except AgentError:
+      return None
+
+    if ipAddr is not None:
+      status = callbacksvr.disconnect()
+
+    if (self.debug >= 3): print "INFO: updateApp: got status back: " + str(status)
+
+    return status
+
+  """
+    return the current time on the device
+  """
+  # external function
+  # returns:
+  #  success: time in ms
+  #  failure: None
+  def getCurrentTime(self):
+    try:
+      data = self.runCmds([{ 'cmd': 'clok' }])
+    except AgentError:
+      return None
+
+    return data.strip()
+
+  """
+    Connect the ipaddress and port for a callback ping.  Defaults to current IP address
+    And ports starting at 30000.
+    NOTE: the detection for current IP address only works on Linux!
+  """
+  def getCallbackIpAndPort(self, aIp, aPort):
+    ip = aIp
+    nettools = NetworkTools()
+    if (ip == None):
+      ip = nettools.getLanIp()
+    if (aPort != None):
+      port = nettools.findOpenPort(ip, aPort)
+    else:
+      port = nettools.findOpenPort(ip, 30000)
+    return ip, port
+
+  """
+    Returns a properly formatted env string for the agent.
+    Input - env, which is either None, '', or a dict
+    Output - a quoted string of the form: '"envvar1=val1,envvar2=val2..."'
+    If env is None or '' return '' (empty quoted string)
+  """
+  def formatEnvString(self, env):
+    if (env == None or env == ''):
+      return ''
+
+    retVal = '"%s"' % ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems()))
+    if (retVal == '""'):
+      return ''
+
+    return retVal
+
+  """
+    adjust the screen resolution on the device, REBOOT REQUIRED
+    NOTE: this only works on a tegra ATM
+    success: True
+    failure: False
+
+    supported resolutions: 640x480, 800x600, 1024x768, 1152x864, 1200x1024, 1440x900, 1680x1050, 1920x1080
+  """
+  def adjustResolution(self, width=1680, height=1050, type='hdmi'):
+    if self.getInfo('os')['os'][0].split()[0] != 'harmony-eng':
+      if (self.debug >= 2): print "WARNING: unable to adjust screen resolution on non Tegra device"
+      return False
+
+    results = self.getInfo('screen')
+    parts = results['screen'][0].split(':')
+    if (self.debug >= 3): print "INFO: we have a current resolution of %s, %s" % (parts[1].split()[0], parts[2].split()[0])
+
+    #verify screen type is valid, and set it to the proper value (https://bugzilla.mozilla.org/show_bug.cgi?id=632895#c4)
+    screentype = -1
+    if (type == 'hdmi'):
+      screentype = 5
+    elif (type == 'vga' or type == 'crt'):
+      screentype = 3
+    else:
+      return False
+
+    #verify we have numbers
+    if not (isinstance(width, int) and isinstance(height, int)):
+      return False
+
+    if (width < 100 or width > 9999):
+      return False
+
+    if (height < 100 or height > 9999):
+      return False
+
+    if (self.debug >= 3): print "INFO: adjusting screen resolution to %s, %s and rebooting" % (width, height)
+    try:
+      self.runCmds([{ 'cmd': "exec setprop persist.tegra.dpy%s.mode.width %s" % (screentype, width) }])
+      self.runCmds([{ 'cmd': "exec setprop persist.tegra.dpy%s.mode.height %s" % (screentype, height) }])
+    except AgentError:
+      return False
+
+    return True
+
+  # external function
+  # returns:
+  #  success: True
+  #  failure: False
+  def chmodDir(self, remoteDir):
+    try:
+      self.runCmds([{ 'cmd': "chmod "+remoteDir }])
+    except AgentError:
+      return False
+    return True
+
+gCallbackData = ''
+
+class myServer(SocketServer.TCPServer):
+  allow_reuse_address = True
+
+class callbackServer():
+  def __init__(self, ip, port, debuglevel):
+    global gCallbackData
+    if (debuglevel >= 1): print "DEBUG: gCallbackData is: %s on port: %s" % (gCallbackData, port)
+    gCallbackData = ''
+    self.ip = ip
+    self.port = port
+    self.connected = False
+    self.debug = debuglevel
+    if (self.debug >= 3): print "Creating server with " + str(ip) + ":" + str(port)
+    self.server = myServer((ip, port), self.myhandler)
+    self.server_thread = Thread(target=self.server.serve_forever)
+    self.server_thread.setDaemon(True)
+    self.server_thread.start()
+
+  def disconnect(self, step = 60, timeout = 600):
+    t = 0
+    if (self.debug >= 3): print "Calling disconnect on callback server"
+    while t < timeout:
+      if (gCallbackData):
+        # Got the data back
+        if (self.debug >= 3): print "Got data back from agent: " + str(gCallbackData)
+        break
+      else:
+        if (self.debug >= 0): print '.',
+      time.sleep(step)
+      t += step
+
+    try:
+      if (self.debug >= 3): print "Shutting down server now"
+      self.server.shutdown()
+    except:
+      if (self.debug >= 1): print "Unable to shutdown callback server - check for a connection on port: " + str(self.port)
+
+    #sleep 1 additional step to ensure not only we are online, but all our services are online
+    time.sleep(step)
+    return gCallbackData
+
+  class myhandler(SocketServer.BaseRequestHandler):
+    def handle(self):
+      global gCallbackData
+      gCallbackData = self.request.recv(1024)
+      #print "Callback Handler got data: " + str(gCallbackData)
+      self.request.send("OK")
+
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/droid.py
@@ -0,0 +1,83 @@
+# 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 devicemanagerADB import DeviceManagerADB
+from devicemanagerSUT import DeviceManagerSUT
+import StringIO
+
+class DroidMixin(object):
+  """Mixin to extend DeviceManager with Android-specific functionality"""
+
+  def launchApplication(self, appName, activityName, intent, url=None,
+                        extras=None):
+    """
+    Launches an Android application
+    returns:
+    success: True
+    failure: False
+    """
+    # only one instance of an application may be running at once
+    if self.processExist(appName):
+      return False
+
+    acmd = [ "am", "start", "-W", "-n", "%s/%s" % (appName, activityName)]
+
+    if intent:
+      acmd.extend(["-a", intent])
+
+    if extras:
+      for (key, val) in extras.iteritems():
+        if type(val) is int:
+          extraTypeParam = "--ei"
+        elif type(val) is bool:
+          extraTypeParam = "--ez"
+        else:
+          extraTypeParam = "--es"
+        acmd.extend([extraTypeParam, str(key), str(val)])
+
+    if url:
+      acmd.extend(["-d", url])
+
+    # shell output not that interesting and debugging logs should already
+    # show what's going on here... so just create an empty memory buffer
+    # and ignore
+    shellOutput = StringIO.StringIO()
+    if self.shell(acmd, shellOutput) == 0:
+      return True
+
+    return False
+
+  def launchFennec(self, appName, intent="android.intent.action.VIEW",
+                   mozEnv=None, extraArgs=None, url=None):
+    """
+    Convenience method to launch Fennec on Android with various debugging
+    arguments
+    WARNING: FIXME: This would go better in mozrunner. Please do not
+    use this method if you are not comfortable with it going away sometime
+    in the near future
+    returns:
+    success: True
+    failure: False
+    """
+    extras = {}
+
+    if mozEnv:
+      # mozEnv is expected to be a dictionary of environment variables: Fennec
+      # itself will set them when launched
+      for (envCnt, (envkey, envval)) in enumerate(mozEnv.iteritems()):
+        extras["env" + str(envCnt)] = envkey + "=" + envval
+
+    # Additional command line arguments that fennec will read and use (e.g.
+    # with a custom profile)
+    if extraArgs:
+      extras['args'] = " ".join(extraArgs)
+
+    return self.launchApplication(appName, ".App", intent, url=url,
+                                  extras=extras)
+
+class DroidADB(DeviceManagerADB, DroidMixin):
+  pass
+
+class DroidSUT(DeviceManagerSUT, DroidMixin):
+  pass
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/emulator.py
@@ -0,0 +1,296 @@
+# 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 abc import abstractmethod
+import datetime
+from mozprocess import ProcessHandlerMixin
+import multiprocessing
+import os
+import re
+import shutil
+import socket
+import subprocess
+from telnetlib import Telnet
+import tempfile
+import time
+
+from emulator_battery import EmulatorBattery
+
+
+class LogcatProc(ProcessHandlerMixin):
+    """Process handler for logcat which saves all output to a logfile.
+    """
+
+    def __init__(self, logfile, cmd, **kwargs):
+        self.logfile = logfile
+        kwargs.setdefault('processOutputLine', []).append(self.log_output)
+        ProcessHandlerMixin.__init__(self, cmd, **kwargs)
+
+    def log_output(self, line):
+        f = open(self.logfile, 'a')
+        f.write(line + "\n")
+        f.flush()
+
+
+class Emulator(object):
+
+    deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
+
+    def __init__(self, noWindow=False, logcat_dir=None, arch="x86",
+                 emulatorBinary=None, res='480x800', userdata=None,
+                 memory='512', partition_size='512'):
+        self.port = None
+        self._emulator_launched = False
+        self.proc = None
+        self.local_port = None
+        self.telnet = None
+        self._tmp_userdata = None
+        self._adb_started = False
+        self.logcat_dir = logcat_dir
+        self.logcat_proc = None
+        self.arch = arch
+        self.binary = emulatorBinary
+        self.memory = str(memory)
+        self.partition_size = str(partition_size)
+        self.res = res
+        self.battery = EmulatorBattery(self)
+        self.noWindow = noWindow
+        self.dataImg = userdata
+        self.copy_userdata = self.dataImg is None
+
+    def __del__(self):
+        if self.telnet:
+            self.telnet.write('exit\n')
+            self.telnet.read_all()
+
+    @property
+    def args(self):
+        qemuArgs = [self.binary,
+                    '-kernel', self.kernelImg,
+                    '-sysdir', self.sysDir,
+                    '-data', self.dataImg]
+        if self.noWindow:
+            qemuArgs.append('-no-window')
+        qemuArgs.extend(['-memory', self.memory,
+                         '-partition-size', self.partition_size,
+                         '-verbose',
+                         '-skin', self.res,
+                         '-gpu', 'on',
+                         '-qemu'] + self.tail_args)
+        return qemuArgs
+
+    @property
+    def is_running(self):
+        if self._emulator_launched:
+            return self.proc is not None and self.proc.poll() is None
+        else:
+            return self.port is not None
+
+    def _default_adb(self):
+        adb = subprocess.Popen(['which', 'adb'],
+                               stdout=subprocess.PIPE,
+                               stderr=subprocess.STDOUT)
+        retcode = adb.wait()
+        if retcode == 0:
+            self.adb = adb.stdout.read().strip() # remove trailing newline
+        return retcode
+
+    def _check_for_adb(self):
+        if not os.path.exists(self.adb):
+            if self._default_adb() != 0:
+                raise Exception('adb not found!')
+
+    def _run_adb(self, args):
+        args.insert(0, self.adb)
+        adb = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        retcode = adb.wait()
+        if retcode:
+            raise Exception('adb terminated with exit code %d: %s'
+            % (retcode, adb.stdout.read()))
+        return adb.stdout.read()
+
+    def _get_telnet_response(self, command=None):
+        output = []
+        assert(self.telnet)
+        if command is not None:
+            self.telnet.write('%s\n' % command)
+        while True:
+            line = self.telnet.read_until('\n')
+            output.append(line.rstrip())
+            if line.startswith('OK'):
+                return output
+            elif line.startswith('KO:'):
+                raise Exception('bad telnet response: %s' % line)
+
+    def _run_telnet(self, command):
+        if not self.telnet:
+            self.telnet = Telnet('localhost', self.port)
+            self._get_telnet_response()
+        return self._get_telnet_response(command)
+
+    def close(self):
+        if self.is_running and self._emulator_launched:
+            self.proc.terminate()
+            self.proc.wait()
+        if self._adb_started:
+            self._run_adb(['kill-server'])
+            self._adb_started = False
+        if self.proc:
+            retcode = self.proc.poll()
+            self.proc = None
+            if self._tmp_userdata:
+                os.remove(self._tmp_userdata)
+                self._tmp_userdata = None
+            return retcode
+        if self.logcat_proc:
+            self.logcat_proc.kill()
+        return 0
+
+    def _get_adb_devices(self):
+        offline = set()
+        online = set()
+        output = self._run_adb(['devices'])
+        for line in output.split('\n'):
+            m = self.deviceRe.match(line)
+            if m:
+                if m.group(3) == 'offline':
+                    offline.add(m.group(1))
+                else:
+                    online.add(m.group(1))
+        return (online, offline)
+
+    def restart(self):
+        if not self._emulator_launched:
+            return
+        self.close()
+        self.start()
+
+    def start_adb(self):
+        result = self._run_adb(['start-server'])
+        # We keep track of whether we've started adb or not, so we know
+        # if we need to kill it.
+        if 'daemon started successfully' in result:
+            self._adb_started = True
+        else:
+            self._adb_started = False
+
+    def connect(self):
+        self._check_for_adb()
+        self.start_adb()
+
+        online, offline = self._get_adb_devices()
+        now = datetime.datetime.now()
+        while online == set([]):
+            time.sleep(1)
+            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
+                raise Exception('timed out waiting for emulator to be available')
+            online, offline = self._get_adb_devices()
+        self.port = int(list(online)[0])
+
+    @abstractmethod
+    def _locate_files(self):
+        pass
+
+    def start(self):
+        self._locate_files()
+        self.start_adb()
+
+        qemu_args = self.args[:]
+        if self.copy_userdata:
+            # Make a copy of the userdata.img for this instance of the emulator
+            # to use.
+            self._tmp_userdata = tempfile.mktemp(prefix='emulator')
+            shutil.copyfile(self.dataImg, self._tmp_userdata)
+            qemu_args[qemu_args.index('-data') + 1] = self._tmp_userdata
+
+        original_online, original_offline = self._get_adb_devices()
+
+        self.proc = subprocess.Popen(qemu_args,
+                                     stdout=subprocess.PIPE,
+                                     stderr=subprocess.PIPE)
+
+        online, offline = self._get_adb_devices()
+        now = datetime.datetime.now()
+        while online - original_online == set([]):
+            time.sleep(1)
+            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
+                raise Exception('timed out waiting for emulator to start')
+            online, offline = self._get_adb_devices()
+        self.port = int(list(online - original_online)[0])
+        self._emulator_launched = True
+
+        if self.logcat_dir:
+            self.save_logcat()
+
+        # setup DNS fix for networking
+        self._run_adb(['-s', 'emulator-%d' % self.port,
+                       'shell', 'setprop', 'net.dns1', '10.0.2.3'])
+
+    def _save_logcat_proc(self, filename, cmd):
+        self.logcat_proc = LogcatProc(filename, cmd)
+        self.logcat_proc.run()
+        self.logcat_proc.waitForFinish()
+        self.logcat_proc = None
+
+    def rotate_log(self, srclog, index=1):
+        """ Rotate a logfile, by recursively rotating logs further in the sequence,
+            deleting the last file if necessary.
+        """
+        destlog = os.path.join(self.logcat_dir, 'emulator-%d.%d.log' % (self.port, index))
+        if os.path.exists(destlog):
+            if index == 3:
+                os.remove(destlog)
+            else:
+                self.rotate_log(destlog, index + 1)
+        shutil.move(srclog, destlog)
+
+    def save_logcat(self):
+        """ Save the output of logcat to a file.
+        """
+        filename = os.path.join(self.logcat_dir, "emulator-%d.log" % self.port)
+        if os.path.exists(filename):
+            self.rotate_log(filename)
+        cmd = [self.adb, '-s', 'emulator-%d' % self.port, 'logcat']
+
+        # We do this in a separate process because we call mozprocess's
+        # waitForFinish method to process logcat's output, and this method
+        # blocks.
+        proc = multiprocessing.Process(target=self._save_logcat_proc, args=(filename, cmd))
+        proc.daemon = True
+        proc.start()
+
+    def setup_port_forwarding(self, remote_port):
+        """ Set up TCP port forwarding to the specified port on the device,
+            using any availble local port, and return the local port.
+        """
+
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        s.bind(("", 0))
+        local_port = s.getsockname()[1]
+        s.close()
+
+        self._run_adb(['-s', 'emulator-%d' % self.port, 'forward',
+                       'tcp:%d' % local_port,
+                       'tcp:%d' % remote_port])
+
+        self.local_port = local_port
+
+        return local_port
+
+    def wait_for_port(self, timeout=300):
+        assert(self.local_port)
+        starttime = datetime.datetime.now()
+        while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
+            try:
+                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+                sock.connect(('localhost', self.local_port))
+                data = sock.recv(16)
+                sock.close()
+                if '"from"' in data:
+                    return True
+            except:
+                import traceback
+                print traceback.format_exc()
+            time.sleep(1)
+        return False
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/emulator_battery.py
@@ -0,0 +1,52 @@
+# 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/.
+
+class EmulatorBattery(object):
+
+    def __init__(self, emulator):
+        self.emulator = emulator
+
+    def get_state(self):
+        status = {}
+        state = {}
+
+        response = self.emulator._run_telnet('power display')
+        for line in response:
+            if ':' in line:
+                field, value = line.split(':')
+                value = value.strip()
+                if value == 'true':
+                    value = True
+                elif value == 'false':
+                    value = False
+                elif field == 'capacity':
+                    value = float(value)
+                status[field] = value
+
+        state['level'] = status.get('capacity', 0.0) / 100
+        if status.get('AC') == 'online':
+            state['charging'] = True
+        else:
+            state['charging'] = False
+
+        return state
+
+    def get_charging(self):
+        return self.get_state()['charging']
+
+    def get_level(self):
+        return self.get_state()['level']
+
+    def set_level(self, level):
+        self.emulator._run_telnet('power capacity %d' % (level * 100))
+
+    def set_charging(self, charging):
+        if charging:
+            cmd = 'power ac on'
+        else:
+            cmd = 'power ac off'
+        self.emulator._run_telnet(cmd)
+
+    charging = property(get_charging, set_charging)
+    level = property(get_level, set_level)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/sutcli.py
@@ -0,0 +1,183 @@
+# 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/.
+
+"""
+Command-line client to control a device with the SUTAgent software installed
+"""
+
+import os
+import posixpath
+import StringIO
+import sys
+from optparse import OptionParser
+
+from mozdevice import droid
+
+class SUTCli(object):
+
+    def __init__(self, args=sys.argv[1:]):
+        usage = "usage: %prog [options] <command> [<args>]\n\ndevice commands:\n"
+        self.commands = { 'install': { 'function': self.install,
+                                       'min_args': 1,
+                                       'max_args': 1,
+                                       'help_args': '<file>',
+                                       'help': 'push this package file to the device and install it' },
+                          'killapp': { 'function': self.killapp,
+                                       'min_args': 1,
+                                       'max_args': 1,
+                                       'help_args': '<process name>',
+                                       'help': 'kills any processes with a particular name on device' },
+                          'launchapp': { 'function': self.launchapp,
+                                         'min_args': 4,
+                                         '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' },
+                          '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,
+                                    'help_args': '[os|id|uptime|systime|screen|memory|processes]',
+                                    'help': 'get information on a specified '
+                                    'aspect of the device (if no argument '
+                                    'given, print all available information)'
+                                    },
+                          'ps': { 'function': self.processlist,
+                                    'min_args': None,
+                                    'max_args': 0,
+                                    'help_args': '',
+                                    'help': 'get information on running processes on device'
+                                },
+                          'ls': { 'function': self.listfiles,
+                                  'min_args': 1,
+                                  'max_args': 1,
+                                  'help_args': '<remote>',
+                                  'help': 'list files on device'
+                                },
+                          'rm': { 'function': lambda file: self.dm.removeFile(file),
+                                    'min_args': 1,
+                                    'max_args': 1,
+                                    'help_args': '<remote>',
+                                    'help': 'remove file from device'
+                                },
+                          'rmdir': { 'function': lambda dir: self.dm.removeDir(dir),
+                                    'min_args': 1,
+                                    'max_args': 1,
+                                    'help_args': '<remote>',
+                                    'help': 'recursively remove directory from device'
+                                }
+                          }
+
+        for (commandname, command) in self.commands.iteritems():
+            help_args = command['help_args']
+            usage += "  %s - %s\n" % (" ".join([ commandname,
+                                                 help_args ]).rstrip(),
+                                      command['help'])
+        self.parser = OptionParser(usage)
+        self.add_options(self.parser)
+
+        (self.options, self.args) = self.parser.parse_args(args)
+
+        if len(self.args) < 1:
+            self.parser.error("must specify command")
+
+        if not self.options.deviceip:
+            if not os.environ.get('TEST_DEVICE'):
+                self.parser.error("Must specify device ip in TEST_DEVICE or "
+                                  "with --remoteDevice option")
+            else:
+                self.options.deviceip = os.environ.get('TEST_DEVICE')
+
+        (command_name, command_args) = (self.args[0], self.args[1:])
+        if command_name not in self.commands:
+            self.parser.error("Invalid command. Valid commands: %s" %
+                              " ".join(self.commands.keys()))
+
+        command = self.commands[command_name]
+        if command['min_args'] and len(command_args) < command['min_args'] or \
+                command['max_args'] and len(command_args) > command['max_args']:
+            self.parser.error("Wrong number of arguments")
+
+        self.dm = droid.DroidSUT(self.options.deviceip,
+                                 port=int(self.options.deviceport))
+        command['function'](*command_args)
+
+    def add_options(self, parser):
+        parser.add_option("-r", "--remoteDevice", action="store",
+                          type = "string", dest = "deviceip",
+                          help = "Device IP", default=None)
+        parser.add_option("-p", "--remotePort", action="store",
+                          type = "int", dest = "deviceport",
+                          help = "SUTAgent port (defaults to 20701)",
+                          default=20701)
+
+    def push(self, src, dest):
+        if os.path.isdir(src):
+            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 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):
+        self.dm.launchApplication(appname, activity, intent, url)
+
+    def killapp(self, *args):
+        for appname in args:
+            self.dm.killProcess(appname)
+
+    def shell(self, *args):
+        buf = StringIO.StringIO()
+        self.dm.shell(args, buf)
+        print str(buf.getvalue()[0:-1]).rstrip()
+
+    def getinfo(self, *args):
+        directive=None
+        if args:
+            directive=args[0]
+        info = self.dm.getInfo(directive=directive)
+        for (infokey, infoitem) in sorted(info.iteritems()):
+            if infokey == "process":
+                pass # skip process list: get that through ps
+            elif not directive and not infoitem:
+                print "%s:" % infokey.upper()
+            elif not directive:
+                for line in infoitem:
+                    print "%s: %s" % (infokey.upper(), line)
+            else:
+                print "%s" % "\n".join(infoitem)
+
+    def processlist(self):
+        pslist = self.dm.getProcessList()
+        for ps in pslist:
+            print " ".join(ps)
+
+    def listfiles(self, dir):
+        filelist = self.dm.listFiles(dir)
+        for file in filelist:
+            print file
+
+def cli(args=sys.argv[1:]):
+    # process the command line
+    cli = SUTCli(args)
+
+if __name__ == '__main__':
+    cli()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/setup.py
@@ -0,0 +1,38 @@
+# 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/.
+
+import os
+from setuptools import setup
+
+PACKAGE_VERSION = '0.5'
+
+# take description from README
+here = os.path.dirname(os.path.abspath(__file__))
+try:
+    description = file(os.path.join(here, 'README.md')).read()
+except (OSError, IOError):
+    description = ''
+
+deps = ['mozprocess == 0.5']
+
+setup(name='mozdevice',
+      version=PACKAGE_VERSION,
+      description="Mozilla-authored device management",
+      long_description=description,
+      classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+      keywords='',
+      author='Mozilla Automation and Testing Team',
+      author_email='tools@lists.mozilla.org',
+      url='https://wiki.mozilla.org/Auto-tools/Projects/MozBase',
+      license='MPL',
+      packages=['mozdevice'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=deps,
+      entry_points="""
+      # -*- Entry points: -*-
+      [console_scripts]
+      sut = mozdevice.sutcli:cli
+      """,
+      )
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/README.md
@@ -0,0 +1,15 @@
+# SUT Agent tests
+
+* 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*
+
+* Make sure the SUTAgent on the device is running.
+
+* Run: python runtests.py
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/dmunit.py
@@ -0,0 +1,52 @@
+# 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 mozdevice import devicemanager
+from mozdevice import devicemanagerSUT
+import types
+import unittest
+
+ip = ''
+port = 0
+
+
+class DeviceManagerTestCase(unittest.TestCase):
+    """DeviceManager tests should subclass this.
+    """
+
+    """Set to False in your derived class if this test
+    should not be run on the Python agent.
+    """
+    runs_on_test_device = True
+
+    def _setUp(self):
+        """ Override this if you want set-up code in your test."""
+        return
+
+    def setUp(self):
+        self.dm = devicemanagerSUT.DeviceManagerSUT(host=ip, port=port)
+        self.dm.debug = 3
+        self.dmerror = devicemanager.DMError
+        self.nettools = devicemanager.NetworkTools
+        self._setUp()
+
+
+class DeviceManagerTestLoader(unittest.TestLoader):
+
+    def __init__(self, isTestDevice=False):
+        self.isTestDevice = isTestDevice
+
+    def loadTestsFromModuleName(self, module_name):
+        """Loads tests from modules unless the SUT is a test device and
+        the test case has runs_on_test_device set to False
+        """
+        tests = []
+        module = __import__(module_name)
+        for name in dir(module):
+            obj = getattr(module, name)
+            if (isinstance(obj, (type, types.ClassType)) and
+                issubclass(obj, unittest.TestCase)) and \
+                (not self.isTestDevice or obj.runs_on_test_device):
+                tests.append(self.loadTestsFromTestCase(obj))
+        return self.suiteClass(tests)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/genfiles.py
@@ -0,0 +1,85 @@
+# 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 random import randint
+from zipfile import ZipFile
+import os
+import shutil
+
+
+def gen_binary_file(path, size):
+    with open(path, 'wb') as f:
+        for i in xrange(size):
+            byte = '%c' % randint(0, 255)
+            f.write(byte)
+
+
+def gen_zip(path, files, stripped_prefix=''):
+    with ZipFile(path, 'w') as z:
+        for f in files:
+            new_name = f.replace(stripped_prefix, '')
+            z.write(f, new_name)
+
+
+def mkdir(path, *args):
+    try:
+        os.mkdir(path, *args)
+    except OSError:
+        pass
+
+
+def gen_folder_structure():
+    root = 'test-files'
+    prefix = os.path.join(root, 'push2')
+    mkdir(prefix)
+
+    gen_binary_file(os.path.join(prefix, 'file4.bin'), 59036)
+    mkdir(os.path.join(prefix, 'sub1'))
+    shutil.copyfile(os.path.join(root, 'mytext.txt'),
+                    os.path.join(prefix, 'sub1', 'file1.txt'))
+    mkdir(os.path.join(prefix, 'sub1', 'sub1.1'))
+    shutil.copyfile(os.path.join(root, 'mytext.txt'),
+                    os.path.join(prefix, 'sub1', 'sub1.1', 'file2.txt'))
+    mkdir(os.path.join(prefix, 'sub2'))
+    shutil.copyfile(os.path.join(root, 'mytext.txt'),
+                    os.path.join(prefix, 'sub2', 'file3.txt'))
+
+
+def gen_test_files():
+    gen_folder_structure()
+    flist = [
+        os.path.join('test-files', 'push2'),
+        os.path.join('test-files', 'push2', 'file4.bin'),
+        os.path.join('test-files', 'push2', 'sub1'),
+        os.path.join('test-files', 'push2', 'sub1', 'file1.txt'),
+        os.path.join('test-files', 'push2', 'sub1', 'sub1.1'),
+        os.path.join('test-files', 'push2', 'sub1', 'sub1.1', 'file2.txt'),
+        os.path.join('test-files', 'push2', 'sub2'),
+        os.path.join('test-files', 'push2', 'sub2', 'file3.txt')
+    ]
+    gen_zip(os.path.join('test-files', 'mybinary.zip'),
+            flist, stripped_prefix=('test-files' + os.path.sep))
+    gen_zip(os.path.join('test-files', 'mytext.zip'),
+            [os.path.join('test-files', 'mytext.txt')])
+
+
+def clean_test_files():
+    ds = [os.path.join('test-files', d) for d in ('push1', 'push2')]
+    for d in ds:
+        try:
+            shutil.rmtree(d)
+        except OSError:
+            pass
+
+    fs = [os.path.join('test-files', f) for f in ('mybinary.zip', 'mytext.zip')]
+    for f in fs:
+        try:
+            os.remove(f)
+        except OSError:
+            pass
+
+
+if __name__ == '__main__':
+    gen_test_files()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/runtests.py
@@ -0,0 +1,85 @@
+# 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 optparse import OptionParser
+import os
+import re
+import unittest
+import sys
+
+import dmunit
+import genfiles
+
+
+def main(ip, port, scripts, directory, isTestDevice):
+    dmunit.ip = ip
+    dmunit.port = port
+
+    suite = unittest.TestSuite()
+
+    genfiles.gen_test_files()
+
+    if scripts:
+        # Ensure the user didn't include the .py on the name of the test file
+        # (and get rid of it if they did)
+        scripts = map(lambda x: x.split('.')[0], scripts)
+    else:
+        # Go through the directory and pick up everything
+        # named test_*.py and run it
+        testfile = re.compile('^test_.*\.py$')
+        files = os.listdir(directory)
+
+        for f in files:
+            if testfile.match(f):
+                scripts.append(f.split('.')[0])
+
+    testLoader = dmunit.DeviceManagerTestLoader(isTestDevice)
+    for s in scripts:
+        suite.addTest(testLoader.loadTestsFromModuleName(s))
+    unittest.TextTestRunner(verbosity=2).run(suite)
+
+    genfiles.clean_test_files()
+
+
+if  __name__ == "__main__":
+
+    default_ip = '127.0.0.1'
+    default_port = 20701
+
+    env_ip, _, env_port = os.getenv('TEST_DEVICE', '').partition(':')
+    if env_port:
+        try:
+            env_port = int(env_port)
+        except ValueError:
+            print >> sys.stderr, "Port in TEST_DEVICE should be an integer."
+            sys.exit(1)
+
+    # Deal with the options
+    parser = OptionParser()
+    parser.add_option("--ip", action="store", type="string", dest="ip",
+                      help="IP address for device running SUTAgent, defaults "
+                      "to what's provided in $TEST_DEVICE or 127.0.0.1",
+                      default=(env_ip or default_ip))
+
+    parser.add_option("--port", action="store", type="int", dest="port",
+                      help="Port of SUTAgent on device, defaults to "
+                      "what's provided in $TEST_DEVICE or 20701",
+                      default=(env_port or default_port))
+
+    parser.add_option("--script", action="append", type="string",
+                      dest="scripts", help="Name of test script to run, "
+                      "can be specified multiple times", default=[])
+
+    parser.add_option("--directory", action="store", type="string", dest="dir",
+                      help="Directory to look for tests in, defaults to "
+                      "current directory", default=os.getcwd())
+
+    parser.add_option("--testDevice", action="store_true", dest="isTestDevice",
+                      help="Specifies that the device is a local test agent",
+                      default=False)
+
+    (options, args) = parser.parse_args()
+
+    main(options.ip, options.port, options.scripts,
+         options.dir, options.isTestDevice)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test-files/mytext.txt
@@ -0,0 +1,177 @@
+this is a file with 71K bytes of text in it
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc placerat, mi sit amet laoreet sollicitudin, neque urna bibendum eros, nec adipiscing tellus ipsum id risus. Sed aliquam ligula nec nibh sollicitudin venenatis. Praesent faucibus tortor vel felis egestas pellentesque. Cras viverra, dui viverra vulputate ornare, eros nunc volutpat nisl, sed sodales turpis orci quis diam. Donec eu sem mi. Mauris dictum blandit mauris quis ultricies. Sed faucibus erat vel velit viverra adipiscing. Donec placerat mattis venenatis. Suspendisse placerat sagittis risus et dapibus. Vivamus diam nisi, elementum ac mollis nec, porta ut sapien. Curabitur ac dolor ligula, vel sollicitudin sapien. Nullam blandit ligula nisl. Proin faucibus, ipsum sit amet molestie tincidunt, tellus neque accumsan lectus, a congue felis odio eu nunc. Pellentesque mauris sapien, varius ut scelerisque et, dictum sed magna. In faucibus tristique erat, a malesuada justo tincidunt sed.
+
+Morbi quis iaculis elit. Praesent nec diam mi, eu auctor neque. Phasellus fringilla turpis a metus imperdiet laoreet et ut augue. Mauris imperdiet scelerisque arcu quis sollicitudin. Nulla mauris dui, ultricies at vulputate quis, pharetra in erat. Donec mollis ipsum quis purus fermentum commodo. Nunc nec orci sem, quis rhoncus mauris. Sed iaculis tempus quam, non consectetur nisl tincidunt vitae. Nulla aliquam sodales auctor. Donec placerat venenatis facilisis. In sollicitudin arcu tincidunt lorem molestie bibendum. Phasellus rutrum ante vitae lorem iaculis eget porta odio pretium.
+
+Duis id mauris ante, eget ullamcorper justo. Integer vitae felis nisi, eget blandit tortor. Vivamus ligula odio, adipiscing sit amet tincidunt id, pretium sed massa. Suspendisse massa felis, viverra non adipiscing quis, dictum eget metus. In porta, tortor a imperdiet sodales, nulla mi mollis ipsum, quis venenatis nunc ipsum sit amet libero. Aenean sed leo eros. Curabitur varius egestas tempor. Nullam vitae convallis nunc. Phasellus molestie volutpat purus ut commodo. Phasellus eget lacus sem. Maecenas ligula magna, lacinia mollis molestie vitae, fringilla ac turpis. Sed ut nunc id nunc fringilla consectetur at et neque.
+
+Aliquam erat volutpat. Nullam lacinia, neque id luctus consectetur, nisl justo porta justo, eu scelerisque ligula ligula sed purus. Cras faucibus porttitor nisi at vulputate. Integer iaculis urna ut sapien iaculis ac malesuada quam congue. Mauris volutpat tristique est, vitae vehicula nisi imperdiet tincidunt. Curabitur semper, tellus sed cursus placerat, mi nulla dapibus odio, quis adipiscing arcu eros eu quam. Nullam fermentum dictum tellus non pretium. Sed dignissim enim a odio varius pellentesque. Nullam at lacinia mi. Nam et sem non risus suscipit pharetra vel et nisl. Cras porta lorem quis diam tempus nec dapibus velit sodales. Suspendisse laoreet hendrerit fringilla.
+
+Phasellus velit quam, malesuada eget rhoncus in, hendrerit sed nibh. Quisque nisl erat, pulvinar vitae condimentum sed, vehicula sit amet elit. Nulla eget mauris est, vel lacinia eros. Maecenas feugiat tortor ac nulla porta bibendum. Phasellus commodo ultrices rhoncus. Ut nec lacus in mauris semper congue. Vivamus rhoncus dolor a nulla accumsan semper. Donec vestibulum dictum blandit. Donec lobortis, purus a cursus faucibus, enim nisl fermentum odio, sed sagittis odio quam quis elit. Sed eget varius augue. Quisque a erat dolor, sit amet porttitor eros. Curabitur libero orci, dignissim vel egestas ut, laoreet sit amet augue. Curabitur porta consectetur felis. Etiam sit amet enim dolor, quis lacinia libero. Nunc vel vulputate turpis. Nulla elit nunc, dignissim sed hendrerit vitae, laoreet et urna. Donec massa est, porta eget lobortis sed, dictum vel arcu. Curabitur nec sem neque.
+
+Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In ipsum risus, blandit ac porta non, imperdiet ac erat. Sed libero nisi, gravida quis dignissim vel, mattis quis sem. Ut pretium vulputate augue, a varius mi vehicula at. Ut cursus interdum lobortis. Duis ac sagittis lacus. Suspendisse pulvinar feugiat mi id vestibulum. Integer aliquet augue vitae augue tincidunt pharetra. Duis interdum nunc pellentesque nisl malesuada volutpat. Nam molestie pulvinar felis, quis volutpat urna commodo in. Donec sed adipiscing risus. Mauris nec orci ac eros lacinia euismod sed sed dui. Mauris vel est eget mi bibendum venenatis nec id enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ac orci varius mi aliquam sodales. Cras dapibus lorem et erat tincidunt non consectetur risus commodo. Aenean tincidunt varius orci eu placerat. Sed in euismod justo.
+
+Pellentesque auctor porta magna, vitae volutpat est pharetra id. Phasellus at mi nibh, vitae eleifend mi. Sed egestas orci lacus. Mauris suscipit nunc non diam mattis rutrum. Etiam pretium, mi et ultricies molestie, ante nibh posuere dolor, a fermentum diam massa eget purus. Aliquam erat volutpat. Nam accumsan dapibus quam, vitae dictum est bibendum ut. Sed at vehicula mi. Phasellus vitae ipsum a quam cursus euismod sit amet et turpis. Nam ultricies molestie massa, a consectetur ipsum aliquet sit amet. Pellentesque non orci mauris. Suspendisse congue venenatis est convallis laoreet. Aenean nulla est, bibendum id adipiscing quis, fermentum quis nisi. Nam lectus ante, sodales sodales ultrices a, vehicula ac ligula. Phasellus feugiat tempor lectus, id interdum turpis mollis eu. Suspendisse potenti. Sed euismod tempus ipsum, et iaculis felis consequat sed. Mauris bibendum, eros a semper pharetra, nunc urna commodo lacus, quis placerat dui urna semper libero. Mauris turpis metus, mattis id dignissim eget, sollicitudin nec lacus.
+
+Donec massa dui, laoreet dignissim interdum sit amet, semper vel ligula. Maecenas ut eros est, quis hendrerit purus. In sit amet mattis quam. Curabitur sit amet turpis ac ipsum gravida pulvinar sit amet ut libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum bibendum massa eu nisi fermentum varius. Mauris sollicitudin ultrices nunc, eget facilisis est imperdiet sit amet. Nam elementum magna eget nisi commodo tincidunt. Aliquam erat volutpat. Curabitur in mauris nunc, at eleifend lectus. Integer tincidunt vestibulum lectus, ut porttitor magna dapibus a. Vivamus erat massa, pretium sed tincidunt ac, tincidunt hendrerit ligula. Praesent purus eros, euismod at commodo eu, bibendum eu turpis.
+
+Sed tempor ultrices tortor, et imperdiet est porttitor a. Vestibulum sodales mauris sed urna pellentesque eleifend. Ut euismod tristique nulla eu fermentum. Ut eu dui non purus varius mollis in vel enim. Maecenas ut congue nulla. Suspendisse ultrices sollicitudin molestie. Aliquam vel pulvinar metus. Nulla varius adipiscing metus, ac commodo ante dapibus ac. Phasellus sit amet ligula sed elit scelerisque molestie sit amet ac quam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque sollicitudin libero a quam rutrum egestas ac quis arcu. Etiam mattis massa vel erat mattis ut elementum diam cursus. Fusce bibendum lorem in erat auctor posuere. Ut non mi sed neque sodales vulputate. Donec lacinia, lacus nec hendrerit luctus, dolor nisi dignissim turpis, at rhoncus dui nisi nec elit. Integer laoreet, justo ut pellentesque iaculis, diam turpis scelerisque quam, sit amet semper purus lacus at erat. Sed sollicitudin consectetur eros at ultricies.
+
+Nam in dolor massa. Vivamus semper, quam sed bibendum pellentesque, lectus purus auctor dui, eget mollis tellus urna luctus nisi. Duis felis tellus, dapibus sed sollicitudin commodo, ornare id metus. Aliquam rhoncus pulvinar elit sit amet fermentum. Curabitur ut ligula augue, nec rhoncus orci. Proin ipsum elit, tristique semper rhoncus sit amet, ultrices vel orci. Integer mattis hendrerit blandit. Curabitur tempor quam eget nunc rutrum nec porta elit elementum. Morbi at accumsan libero. Etiam vestibulum facilisis augue vitae feugiat. Vivamus in quam arcu, vel ornare purus. Pellentesque non augue sit amet metus imperdiet accumsan. Suspendisse condimentum vulputate congue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec consequat enim ac est iaculis dictum. Vivamus rhoncus, urna sit amet tempor ornare, nulla sem eleifend mi, eu pretium justo sapien a nulla. Nulla facilisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean sed mattis turpis.
+
+Nulla in magna scelerisque sem imperdiet tempus. Aenean adipiscing pretium sem, eget vulputate turpis pretium vitae. Etiam id enim a mauris faucibus facilisis faucibus vel enim. Phasellus blandit mi nec nibh rhoncus nec sollicitudin mi semper. Maecenas euismod dui sit amet dolor dictum dignissim. Mauris ac quam urna, quis posuere lacus. Sed velit elit, dapibus hendrerit sagittis at, pulvinar ac velit. Quisque in nulla vel massa posuere feugiat sed quis enim. Donec erat eros, adipiscing at fringilla sed, ornare id nisl. Duis eleifend consectetur tincidunt. Donec enim augue, mollis sed commodo mattis, luctus ac libero. Vestibulum erat ante, lacinia ac porttitor quis, vulputate et ligula. Nunc nisl orci, eleifend et laoreet eu, egestas et est. Nulla nulla purus, euismod nec porttitor quis, volutpat id diam. Nunc ut nisl eget orci venenatis mattis. In eget nisi nibh. Integer erat mauris, interdum nec mattis in, pulvinar vitae orci. Duis dictum tortor in elit aliquet commodo. Vestibulum venenatis auctor faucibus. Nulla adipiscing nisi eu lectus ornare ultrices.
+
+Curabitur placerat ante a odio dapibus placerat. Praesent ante quam, rutrum quis dignissim vulputate, dignissim vitae elit. Curabitur et nibh ante. Sed luctus bibendum pulvinar. Ut vel justo eros. Maecenas faucibus ornare consequat. Mauris non interdum elit. Mauris tortor magna, tempor quis rutrum ac, congue ut sem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed semper interdum quam eu semper. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris enim velit, mattis at dictum eget, ornare vel erat. Quisque non tincidunt lectus. Vestibulum auctor scelerisque erat eget adipiscing. Mauris ac metus purus, sit amet dignissim felis.
+
+Curabitur vitae quam sagittis massa aliquet facilisis id tempor justo. Aenean vulputate libero nec odio porta in rhoncus massa interdum. Maecenas consectetur suscipit consectetur. Proin a mauris sit amet ante sollicitudin auctor id ac libero. Vivamus hendrerit porta augue, ac pretium nibh cursus at. Aliquam varius nulla porta quam pellentesque scelerisque eget a felis. Maecenas elit quam, tempor vel dignissim nec, aliquam ac justo. Curabitur scelerisque cursus orci, sit amet scelerisque dolor consectetur vel. Integer tellus tortor, laoreet laoreet consequat id, vehicula nec neque. Sed sit amet ante sed magna faucibus luctus et vel nisi.
+
+Curabitur placerat viverra urna et auctor. Proin ac lacus urna, vitae sagittis erat. In ut tellus ipsum, rutrum auctor orci. Sed dolor nibh, laoreet egestas egestas non, eleifend eu lectus. Aenean lorem leo, rhoncus sit amet fermentum in, porta vel leo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent lorem orci, congue nec consectetur eu, ullamcorper non nulla. Duis sed augue libero. Suspendisse potenti. Nunc id neque massa.
+
+Etiam odio magna, congue ut tristique non, dignissim nec est. Sed id purus velit. Vivamus dui dui, rutrum sit amet imperdiet non, pharetra cursus ante. Curabitur aliquet dapibus massa, non molestie orci aliquet tincidunt. Aenean in varius risus. Nullam faucibus sapien odio. Integer id est erat. Nam iaculis purus a ipsum sagittis in vestibulum lectus pulvinar. Nulla ultricies nisi a nibh gravida eget vestibulum tellus auctor. Suspendisse ut dolor elementum mi iaculis dignissim eu eleifend tellus. Sed pretium mi ligula. Integer vitae sem sit amet nunc dignissim rutrum nec eleifend felis. Aenean blandit fermentum lectus quis dignissim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis congue sem a est accumsan sit amet facilisis erat dapibus. Mauris id lectus ipsum. Sed velit metus, ultrices rhoncus porta non, consectetur id ligula.
+
+Fusce eu odio volutpat sem pellentesque laoreet. Integer a justo ante, sed elementum elit. Donec sed mattis arcu. Vivamus imperdiet sodales ante, eget tincidunt turpis imperdiet et. Donec mi ante, tincidunt nec adipiscing sit amet, sodales vel arcu. Cras eu libero arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam ac dui justo. Nam nisi ipsum, dignissim id fermentum at, accumsan ut quam. Quisque non est quis nibh iaculis gravida nec id velit. Cras elementum tincidunt mattis. Mauris odio erat, sodales ut egestas nec, semper eget enim. Mauris quis tincidunt quam.
+
+Nullam vestibulum ligula imperdiet nunc tincidunt feugiat imperdiet neque sodales. Praesent lacinia sollicitudin pulvinar. Donec ipsum augue, interdum et commodo vitae, lobortis nec ipsum. Nulla ac diam sed ipsum venenatis malesuada at eu odio. Vivamus in urna sed sapien mollis convallis eget eu massa. Proin viverra dolor vitae sem porta vulputate. Donec velit leo, ullamcorper dictum rhoncus in, euismod et ante. Morbi at leo venenatis felis faucibus elementum a a elit. Integer aliquet tempor neque ac bibendum. In fermentum commodo faucibus. In hac habitasse platea dictumst. Nam pulvinar gravida metus in rhoncus. Praesent lobortis ornare libero quis faucibus. Donec a erat ligula. Praesent quis sapien sit amet urna adipiscing sagittis.
+
+Praesent eget libero sed massa ornare congue eget eu lorem. Nunc porta magna ut massa dignissim ultricies. Duis eu arcu quis purus consequat egestas vitae a ipsum. In nunc sapien, venenatis et commodo sollicitudin, facilisis rhoncus risus. Nullam aliquam, orci eu vestibulum sagittis, nulla risus dictum dui, non luctus diam arcu in massa. Maecenas risus lacus, adipiscing sed laoreet sed, ornare sit amet quam. Nam convallis euismod sagittis. Fusce justo mauris, laoreet lobortis gravida semper, tincidunt pellentesque nisl. Sed sit amet turpis in nisi molestie sagittis eget sit amet nulla. Donec eget semper mauris. Aenean nec odio a nibh faucibus dapibus. Donec imperdiet tortor non elit congue varius. Morbi libero enim, tincidunt at bibendum vitae, dapibus ac ante. Proin eu metus quis turpis bibendum molestie. Nulla malesuada magna quis ante mollis ultrices. Suspendisse vel nibh at risus porttitor mattis. Nulla laoreet consequat viverra. Ut scelerisque faucibus mauris sed vestibulum. In pulvinar massa in magna dapibus ullamcorper. Quisque in ante sapien, nec ullamcorper tortor.
+
+Etiam in ipsum urna, eu feugiat nibh. In sed eros ligula, eget interdum lorem. Cras ut malesuada purus. Suspendisse vel odio quam. Vivamus eu rutrum quam. Integer nec luctus est. Mauris aliquam est ac neque convallis placerat. Sed massa ante, sagittis a tincidunt semper, interdum eget mauris. Sed a ligula sed justo facilisis sagittis vel eu ipsum. Quisque aliquam vestibulum nisl quis commodo.
+
+Morbi id rutrum mi. Curabitur a est quis mauris accumsan egestas a vulputate urna. Nunc eleifend lacus non lacus tincidunt vitae commodo odio mattis. Cras accumsan blandit odio, vitae mattis est egestas eget. Integer condimentum sem in lectus euismod consectetur. Donec est lectus, posuere sit amet ornare non, ullamcorper vel dolor. Vestibulum luctus consectetur scelerisque. Duis suscipit congue mi id venenatis. Quisque eu mauris venenatis dolor condimentum gravida a a leo. Aenean et massa est. Sed arcu ligula, sagittis in luctus in, condimentum a nisl. In placerat interdum felis, eu luctus dolor rutrum sed. Nam commodo, urna a adipiscing scelerisque, turpis arcu adipiscing metus, at blandit nulla elit quis sapien. Quisque sodales tincidunt odio, quis sodales erat bibendum condimentum. Ut semper dolor in ipsum tincidunt convallis. Phasellus molestie nulla id ipsum semper ultrices. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris aliquam semper neque at sagittis. Curabitur luctus tristique facilisis. Donec scelerisque ante non tortor fringilla eleifend non in felis.
+
+Maecenas nec ipsum eget odio ornare egestas non non tortor. Vestibulum elementum ultrices ipsum, nec elementum augue dapibus vitae. Fusce hendrerit erat eget libero porttitor sit amet venenatis neque mollis. Donec lorem quam, egestas sed rutrum pharetra, ultrices quis quam. Phasellus iaculis risus eget leo suscipit eu consectetur libero bibendum. Nulla euismod, est sit amet tristique tincidunt, nisi turpis sagittis justo, ornare elementum nibh turpis at ipsum. Mauris id velit risus, in lacinia libero. Integer at urna eu sapien luctus sollicitudin. Vestibulum vitae varius est. Curabitur eget quam urna, cursus egestas orci.
+
+Sed eu felis nisi. Nullam nisi lacus, imperdiet sed accumsan sed, pretium ac dolor. Curabitur feugiat tristique velit, id fermentum velit blandit lobortis. Phasellus ac arcu vel lacus ultricies aliquet. Morbi aliquet pulvinar convallis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tincidunt commodo tortor, vitae semper velit consequat ac. Suspendisse ac sollicitudin elit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque imperdiet, mi sed ultrices ullamcorper, eros justo malesuada urna, ac dapibus turpis leo sed sem. Nulla commodo consectetur libero a scelerisque. Maecenas in tortor sem, vitae rhoncus magna. Nulla nec nisl nisl, eget iaculis felis. Phasellus placerat consectetur erat, non porta tellus egestas nec. Praesent gravida pharetra arcu. Nullam bibendum congue eleifend.
+
+Nam risus dolor, mollis in suscipit vel, egestas eget augue. Donec et nulla mi. Vestibulum nunc mauris, volutpat eget lacinia ut, consequat non justo. Etiam bibendum elit quis ipsum volutpat sit amet convallis erat feugiat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed non turpis elit, in laoreet sapien. Quisque ac elit id odio luctus pharetra. Phasellus sit amet est nec orci vestibulum varius. Cras ut justo a velit accumsan scelerisque. Proin lacus odio, convallis in semper egestas, ullamcorper sit amet erat. Proin ornare mollis pharetra. Phasellus convallis, sapien a placerat scelerisque, magna ante lobortis massa, ut semper nibh turpis a nibh.
+
+Vestibulum risus mauris, auctor eu aliquam quis, pretium vel massa. Nunc imperdiet magna quis nisi facilisis euismod. Nunc aliquam, felis quis mollis aliquam, mi arcu commodo eros, sit amet convallis nunc magna non magna. Suspendisse accumsan tortor non metus convallis pharetra. In vitae mi sed leo ornare viverra. Donec a massa at sem euismod scelerisque id a sapien. Nam nec purus purus, quis lacinia sem. Sed laoreet erat quis tortor feugiat at mattis lacus sollicitudin. In hac habitasse platea dictumst. Vivamus tristique rhoncus eros a hendrerit. Etiam semper dapibus tortor, quis porta purus ullamcorper eget. In iaculis elit ut neque varius at consequat tellus accumsan.
+
+Praesent ut ipsum nec nulla consequat laoreet. Quisque viverra rutrum bibendum. Vivamus vitae bibendum augue. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla hendrerit condimentum lacinia. Donec sed bibendum lectus. Ut venenatis tincidunt neque et fermentum. Mauris fermentum, est at molestie luctus, nunc lorem sodales dolor, ut facilisis massa risus ut sem. Vestibulum nec nisi sed lacus imperdiet ornare. Duis sed lobortis nisi. In urna ipsum, posuere fringilla adipiscing eu, euismod a purus. Proin bibendum feugiat adipiscing. Morbi neque turpis, ullamcorper at feugiat ac, condimentum ut ante. Proin eget orci mauris, nec congue dolor.
+
+Sed quis dolor massa, sed fermentum eros. Fusce et scelerisque tortor. Donec bibendum vestibulum neque, id tristique leo eleifend non. Ut vel lacinia orci. Etiam lacus erat, varius viverra accumsan sit amet, imperdiet at sapien. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum erat lacus, hendrerit consectetur vulputate id, mattis eu nunc. Morbi lacinia bibendum eros, sit amet luctus nisl lobortis lobortis. Nullam sit amet nisl vel justo ornare bibendum eu quis nunc. Morbi faucibus dictum quam, sed suscipit est auctor ac. Sed egestas ultricies sem a pharetra. Phasellus sagittis ornare lorem eu aliquam. Praesent vitae lectus ut dui consectetur varius. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam ac orci id metus tincidunt congue vel ut mi. Nunc auctor tristique enim quis sodales.
+
+Aenean quis tempor libero. In sed quam purus. Nam in velit erat. Ut ullamcorper nunc ut nibh facilisis non imperdiet enim interdum. Praesent et mi nulla, quis facilisis lacus. Nulla luctus, velit vulputate egestas aliquet, arcu dolor vulputate tellus, eu auctor ipsum tortor ut lorem. In sed nulla auctor elit adipiscing laoreet. Mauris id pretium velit. Vestibulum aliquet bibendum laoreet. Duis convallis, leo vitae tincidunt fringilla, massa eros porta lorem, a convallis sem massa sit amet libero. Nam ligula leo, porta non hendrerit a, luctus pellentesque tortor. Nulla fermentum mi lacinia est pellentesque sed rhoncus nisl tristique. Curabitur venenatis neque id magna egestas eget dictum nisi volutpat.
+
+Ut sagittis fringilla arcu, ut condimentum metus tempor et. Duis elit neque, varius quis consectetur et, vulputate egestas odio. Curabitur molestie congue nibh, pulvinar tincidunt elit tempus ut. Quisque nec magna lacus. Quisque eu justo lacus. Maecenas tempus porttitor consequat. Ut vulputate lacinia tempus. Praesent dignissim iaculis orci ac euismod. Proin porttitor lorem auctor erat placerat quis tincidunt tellus posuere. Nam ultrices sapien ultrices urna aliquet convallis. Aenean auctor fringilla vestibulum.
+
+Proin eros nisl, viverra placerat eleifend a, facilisis et augue. Duis commodo tincidunt molestie. Nullam malesuada ligula eget libero tincidunt viverra. Ut euismod sem in turpis posuere rhoncus. Donec luctus, eros quis ultricies eleifend, lacus ligula porttitor magna, sit amet lobortis enim turpis non orci. Nunc odio nisi, luctus id euismod non, hendrerit quis dolor. Proin tristique sem semper massa porttitor fringilla. Curabitur a felis tellus. Donec tempus, libero at ornare commodo, risus sapien venenatis mi, sit amet fringilla diam enim at arcu. Suspendisse potenti. Phasellus auctor, lorem sed pulvinar ornare, eros nunc tincidunt dui, semper interdum lorem purus nec turpis. Sed egestas, orci non varius dapibus, nulla felis rutrum tortor, a vehicula nisi magna et magna. Donec aliquam rhoncus arcu ac volutpat.
+
+Quisque leo risus, egestas eu posuere eget, malesuada quis erat. Donec vel nisi quis erat vestibulum consectetur. Donec mi mi, dictum vel posuere ac, pharetra non justo. Vivamus rhoncus mollis odio, eu fermentum turpis blandit a. Pellentesque ornare consequat odio, non sodales massa sollicitudin ac. Vestibulum euismod nisi non augue commodo vitae laoreet justo tempor. Vestibulum at arcu ac elit tincidunt vehicula pretium eget magna. Nullam non eros eros. Morbi sed diam ut leo viverra gravida a sit amet sem. Duis ultricies tellus in nisi vulputate rhoncus. Praesent molestie eros et ligula sodales ut euismod arcu egestas. Cras ullamcorper dapibus erat id luctus. Maecenas pretium rutrum mauris, ac rhoncus lacus commodo eu. Duis ut diam quis neque accumsan laoreet in eu tellus. Curabitur sit amet ligula nibh. Vestibulum vitae semper leo. Sed volutpat turpis dictum justo luctus quis gravida tortor volutpat. Proin velit dolor, tempor quis iaculis eu, congue vitae nisl. Vestibulum porttitor, risus id consequat suscipit, ipsum leo luctus tellus, sed sollicitudin nulla orci eget arcu.
+
+Fusce et urna sed erat porttitor condimentum convallis et ipsum. Integer sagittis arcu sit amet dolor interdum eu tincidunt sapien sodales. Sed ut elementum ipsum. Aliquam erat volutpat. Fusce vel enim velit. Duis sit amet gravida quam. Sed iaculis aliquet erat sed semper. Sed in ipsum nisi. Suspendisse blandit urna ac lectus congue hendrerit. Donec sapien enim, auctor quis suscipit id, interdum a nunc. Etiam erat velit, hendrerit eget tincidunt ut, pellentesque in lectus. Integer vitae lacus eget est tempor dapibus. Duis in velit augue. In accumsan ipsum eu nibh commodo id consequat lectus condimentum. Integer volutpat condimentum posuere.
+
+Proin at turpis sapien, vel bibendum odio. Etiam scelerisque, nulla vel dapibus dapibus, neque nunc fringilla libero, nec malesuada elit erat eget turpis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec eu mi nisi. Mauris quis dolor libero. Etiam non libero mauris. Nam posuere tortor vel dolor aliquam eu porttitor nisi convallis. Sed eu ante nec diam hendrerit aliquet. Suspendisse fermentum, augue ut lobortis viverra, turpis mi tristique felis, a facilisis est nisi vitae nisl. Nunc sit amet semper tortor. Duis et enim in nulla aliquet fermentum. Etiam ultrices facilisis justo, quis molestie enim convallis ut. Donec congue, eros quis rhoncus interdum, nisl orci porta nisl, posuere tincidunt est tellus nec magna. Suspendisse interdum, lorem nec dictum dignissim, justo dui imperdiet felis, laoreet ultricies lacus elit eu libero. Sed quis urna nec nisi condimentum tristique pulvinar id orci. Vivamus a leo nec libero hendrerit imperdiet. Sed gravida interdum urna, ac dictum odio dictum id. Vestibulum vel varius dolor.
+
+Nulla consequat condimentum eros nec mollis. Donec eget ornare eros. Etiam consequat accumsan aliquet. Quisque non leo nibh. Mauris convallis congue hendrerit. Aliquam nec augue at risus ornare viverra at id felis. Nullam ac turpis ut nisl semper rhoncus quis sit amet justo. Aliquam laoreet arcu vitae odio consequat condimentum. Aliquam erat volutpat. Sed consectetur ipsum nec justo tempor ullamcorper. Donec ac sapien lectus. Suspendisse ut velit eget massa dapibus tincidunt vel eget enim. Etiam quis quam vel lectus tincidunt viverra eget eget risus.
+
+Nulla pulvinar, odio eu hendrerit egestas, nisl nunc gravida mi, non adipiscing tortor mauris a lectus. Sed sapien mi, porttitor vel consectetur ut, viverra ut ipsum. Duis id velit vel ipsum vestibulum sodales. Nunc lorem mi, mollis nec malesuada nec, ornare faucibus nunc. Vestibulum gravida pulvinar eros quis blandit. Nulla facilisi. Curabitur consectetur condimentum justo sed faucibus. Vestibulum neque urna, tincidunt in adipiscing a, interdum a orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero neque, fringilla quis bibendum vel, tincidunt eget metus. Integer tristique, lectus quis rhoncus iaculis, enim dui adipiscing massa, sit amet blandit risus orci eu magna. Fusce ultricies tellus quis massa tempus at laoreet turpis dapibus. Donec sit amet massa viverra purus tincidunt scelerisque. Nunc ut leo nec tellus imperdiet vulputate tincidunt sed nisi. Suspendisse potenti. Sed a nisi nunc. Ut tortor quam, vestibulum et ultrices id, mattis non lacus.
+
+Nullam tincidunt quam quis erat rutrum eget tempor diam vestibulum. Morbi dapibus, quam sed placerat blandit, mi enim dictum nulla, sit amet sollicitudin lectus ante eu sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in elit id nisi aliquet mollis. Cras non lorem risus. Ut libero elit, ornare id placerat ut, sodales at lectus. Nunc orci turpis, tempus vitae pellentesque id, sodales et sem. Aliquam erat volutpat. Sed sit amet tellus condimentum magna cursus consectetur non sed arcu. Vivamus in consectetur massa. Aliquam vitae nibh nec lacus volutpat sodales. Quisque est arcu, porttitor a pharetra ac, laoreet nec nibh. Nunc ullamcorper adipiscing libero a dictum. Vivamus vulputate egestas arcu non viverra. Phasellus eget libero in ipsum fringilla dapibus. Quisque vehicula rhoncus lorem vel dictum. Sed molestie lorem ac tellus ultrices a varius dui faucibus. Integer quis quam libero. Sed fringilla aliquet lacus, non porttitor erat ultricies eu.
+
+Fusce bibendum euismod porta. Praesent libero nunc, dapibus ac aliquam fringilla, ornare quis eros. Vivamus tincidunt arcu vitae felis varius nec facilisis elit fermentum. In quis quam eget mauris porta faucibus. Fusce nec erat eu lectus pellentesque tempus. Morbi a justo a ante pulvinar ultricies ac tincidunt turpis. Etiam malesuada ultrices nibh quis bibendum. Quisque lacus dui, mattis id lobortis sit amet, fermentum id nisl. Donec fermentum nisi ac metus consectetur semper. Duis condimentum ipsum sit amet arcu adipiscing cursus. Nulla vulputate risus vel elit adipiscing sed pretium mauris venenatis. Vestibulum tincidunt, sapien at dapibus rutrum, urna nisi sollicitudin orci, ut condimentum lectus tellus ut lacus. Sed in nisl et urna placerat vestibulum. Ut fringilla suscipit iaculis. In in eros eget neque suscipit mollis quis ut libero. Pellentesque hendrerit consectetur tellus. Nulla a purus ut dolor volutpat ultrices.
+
+Pellentesque at laoreet libero. Quisque pretium tempus placerat. Proin egestas rhoncus est, eu vehicula justo gravida eu. Sed sem velit, sodales tincidunt gravida vitae, rhoncus vel neque. Proin quis quam ut turpis rhoncus suscipit quis vitae tellus. Phasellus non scelerisque nisl. Vestibulum lectus odio, tristique vitae rhoncus id, dapibus vitae magna. Vestibulum aliquet magna in turpis eleifend in dapibus augue lacinia. Ut risus mi, dictum at mollis eu, feugiat a massa. Nam in velit urna. Aliquam imperdiet porta eros a suscipit. Nullam ante quam, congue ut lacinia vel, laoreet vitae felis. Mauris commodo ultricies lobortis. Donec id varius augue. Vivamus convallis, nulla eget aliquam varius, ligula quam rhoncus augue, vel rutrum diam odio in felis. Nulla facilisi. Duis pretium magna nulla, id pretium mi.
+
+Sed elit odio, semper non semper vel, dapibus eu metus. Ut quis nibh vel leo laoreet egestas vitae id odio. Nunc nec egestas nisl. Vivamus tristique pulvinar leo ullamcorper convallis. Praesent elementum condimentum consectetur. Etiam dui nisi, convallis vel fringilla ac, dignissim vel velit. Fusce magna quam, malesuada at vehicula quis, luctus vel tortor. Vivamus viverra consectetur velit, quis bibendum dolor hendrerit nec. Mauris pretium laoreet eleifend. Donec in ligula a enim fringilla pellentesque vitae sed magna. Integer vitae odio et arcu tempor molestie.
+
+In lacus quam, placerat nec accumsan ut, faucibus eget tellus. Maecenas cursus risus enim. Pellentesque quis lorem orci, id dictum velit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed justo arcu, tristique vitae mollis id, dictum non enim. Proin gravida fringilla est eu elementum. Donec ac nulla sapien, et volutpat lectus. Mauris eget quam vel dolor aliquet pretium eu nec dolor. Phasellus auctor nunc ut risus aliquet eu consequat urna rutrum. Integer porta lacus vel metus hendrerit sed fermentum arcu hendrerit. Morbi nibh arcu, tristique ut hendrerit in, rhoncus eget elit.
+
+Morbi tincidunt lectus ut metus aliquam adipiscing. Phasellus eros purus, laoreet non rhoncus nec, aliquet sed justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque leo nunc, feugiat ut consequat in, condimentum sit amet urna. Nam et dui sed orci pellentesque feugiat. Aliquam erat volutpat. Aliquam rhoncus sollicitudin orci. Ut blandit dignissim est, a dapibus erat tincidunt vel. Fusce dignissim vehicula lorem non suscipit. Vivamus gravida accumsan est nec consectetur. Etiam congue diam non nisi ornare semper. Maecenas pretium vestibulum velit. Suspendisse at tincidunt quam. In vitae sagittis est. Duis convallis sollicitudin nunc quis posuere. Quisque et augue eget metus commodo pulvinar. Pellentesque et velit eget massa scelerisque sagittis. Aenean tortor magna, auctor sed sodales et, vestibulum sit amet leo. Vestibulum id ligula vel nisi faucibus cursus.
+
+Quisque hendrerit, lorem vel ultricies adipiscing, massa ligula consectetur odio, eu eleifend sem eros varius magna. Mauris metus arcu, hendrerit et fringilla sit amet, vehicula vel leo. Pellentesque eu tellus in nulla sollicitudin tempus. Sed dapibus cursus facilisis. Cras id lectus turpis, et iaculis felis. Nulla dignissim dui non sem posuere posuere. Ut id arcu sit amet quam tristique malesuada. Curabitur ut posuere urna. Vivamus aliquet pretium leo, id sollicitudin nulla tempor eget. Aliquam commodo enim lacus, quis hendrerit lacus. Praesent tortor felis, semper vel aliquet eget, aliquet a ante. Nullam ullamcorper arcu nibh, a facilisis neque. Nunc rutrum posuere sagittis. Donec eleifend aliquam vulputate. Curabitur eget dapibus ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras mollis laoreet nunc, ut suscipit tellus laoreet semper.
+
+Phasellus libero enim, malesuada ut rutrum a, sollicitudin sed elit. Ut suscipit imperdiet nibh, vel gravida mauris fringilla non. Pellentesque sagittis libero id nulla adipiscing vitae iaculis justo consequat. In hac habitasse platea dictumst. Sed venenatis cursus est, et iaculis nisi convallis vel. Etiam non elementum mi. Etiam semper faucibus orci. Nullam tincidunt, lorem commodo sodales placerat, est velit interdum nulla, ut rutrum lectus massa malesuada elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris faucibus odio vel tellus ornare vitae lacinia libero lobortis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras porttitor, tortor vel adipiscing ornare, nunc elit lobortis nisl, eu vehicula sapien purus id diam. Sed blandit bibendum facilisis. Pellentesque ornare auctor commodo. In et aliquet magna. Fusce molestie sem eget orci semper sollicitudin. Donec placerat tristique urna, a varius velit sagittis eget. Aliquam vitae rutrum orci. Vivamus ac lobortis dui. Integer ornare lobortis sem vel convallis.
+
+Praesent ornare aliquet arcu, sed lacinia dui convallis quis. Suspendisse nec arcu lectus. Suspendisse potenti. Curabitur scelerisque quam id lacus vehicula ut tristique eros viverra. Mauris et mi ac massa auctor pharetra a eget enim. Sed vel dui sem, ut pulvinar risus. Etiam ac ipsum ipsum, eu venenatis odio. Proin lacinia eleifend risus sed hendrerit. Quisque velit nunc, sodales vitae venenatis vitae, lacinia porta neque. Donec nec vestibulum massa. Duis blandit, sapien in congue pharetra, dolor felis pharetra velit, semper vulputate metus massa ac leo. Etiam dictum neque sed lectus condimentum euismod. Maecenas vel magna ultrices lorem fermentum feugiat. Proin pulvinar ornare libero, aliquet tincidunt neque laoreet vitae. Mauris adipiscing convallis massa, quis pellentesque nulla rhoncus quis. Etiam viverra condimentum commodo. Nulla feugiat molestie ipsum sed pretium. Aenean rhoncus imperdiet urna, quis fringilla justo commodo sed. Aliquam erat volutpat. Morbi sed sem nulla.
+
+Integer scelerisque leo eu massa porta non tincidunt velit dictum. Ut ac ligula ipsum. Phasellus vehicula gravida felis, ac commodo lacus mattis ac. Nam bibendum enim eget diam mattis pharetra. Suspendisse malesuada arcu lacus. Nulla elementum arcu a nulla aliquam eu vestibulum dui pulvinar. Duis a facilisis risus. Nam ac dui nibh, eu porttitor mauris. Integer sollicitudin egestas dui, mollis laoreet mauris molestie ac. Aliquam egestas auctor neque, vitae aliquet dolor tincidunt blandit. Suspendisse laoreet orci at augue dapibus suscipit. In hac habitasse platea dictumst. Phasellus egestas ornare sem ac tincidunt. Suspendisse condimentum sem non augue tincidunt vulputate. Mauris cursus quam vel tortor dapibus eu ultricies mauris viverra. Nulla elit dolor, placerat sit amet facilisis non, fringilla in felis.
+
+Proin consequat diam non quam accumsan faucibus. Sed malesuada, dui quis placerat sagittis, sapien libero molestie libero, a sodales tortor neque non elit. Nulla et sodales ante. Donec tempor, tortor ut congue pulvinar, mi elit tempus risus, a pharetra libero quam a augue. Nulla facilisi. Quisque feugiat tortor a arcu dictum tincidunt. Nulla tincidunt tincidunt tortor, ac suscipit eros bibendum pharetra. Ut dignissim sollicitudin massa, et porttitor ligula vulputate a. Integer condimentum dapibus diam in tempor. Pellentesque molestie fringilla rhoncus. Donec eget laoreet libero. Suspendisse vulputate sapien eu sapien faucibus egestas.
+
+Integer nec erat dui, at eleifend arcu. Cras mauris est, cursus vel euismod sed, suscipit quis lorem. Donec neque sem, laoreet suscipit scelerisque a, volutpat at lectus. Pellentesque non felis erat, sed pulvinar nisl. In congue sollicitudin metus sodales convallis. Fusce venenatis risus ut velit adipiscing vestibulum eu sed augue. Proin metus turpis, sodales at faucibus vel, fringilla sodales ligula. Sed fringilla magna sed diam lacinia adipiscing. Maecenas nibh nibh, consequat vel malesuada sed, vestibulum nec felis. Quisque tempus lobortis dui ut euismod. Nulla facilisi. Ut adipiscing purus quis purus pellentesque eu viverra nunc placerat. Nullam nec dignissim diam. Fusce non dignissim massa. Donec condimentum, orci iaculis vulputate elementum, lectus nunc luctus augue, sit amet suscipit nulla odio at massa. Aliquam eu turpis nec massa feugiat condimentum a ac lectus. Nunc lectus ligula, feugiat vel bibendum et, tempor quis mi. Curabitur molestie, urna quis fringilla consequat, ipsum erat sodales turpis, ut laoreet velit risus vitae libero.
+
+Aliquam erat volutpat. Suspendisse tincidunt accumsan eros in posuere. Morbi non ullamcorper augue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dui felis, feugiat semper venenatis vitae, lobortis nec ipsum. In lacinia mauris in massa ornare vel congue ipsum lacinia. Maecenas rhoncus vulputate enim, ut porttitor purus gravida id. Nunc urna ligula, pulvinar eu lacinia nec, scelerisque at nibh. Nam accumsan leo est. Pellentesque congue fermentum nisl ac semper. Sed eget blandit urna. Nullam interdum, risus id hendrerit ultrices, turpis erat vestibulum turpis, quis vehicula mauris sem sit amet est. Mauris et lorem metus, id rutrum nisl. Donec blandit dapibus neque, hendrerit fringilla diam tempus sed. Integer vestibulum, felis quis pulvinar adipiscing, ipsum risus convallis lorem, ac pulvinar lacus nunc sed felis.
+
+Vestibulum vitae tristique orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam erat volutpat. Maecenas non eros quis nulla adipiscing rutrum eu at mi. Suspendisse laoreet nulla vitae nunc venenatis vitae adipiscing felis pharetra. Integer viverra vehicula risus, vitae dictum massa tempor a. Sed id leo neque, nec consectetur tellus. Donec fermentum eros vitae magna vulputate ac volutpat ligula suscipit. Curabitur mi orci, molestie tristique bibendum egestas, blandit vel arcu. Sed molestie ullamcorper nisl nec dignissim. Fusce consectetur suscipit mauris at ullamcorper. In massa diam, feugiat in euismod id, tincidunt id libero. Donec adipiscing, tellus id vehicula hendrerit, justo mauris sagittis odio, eget placerat felis ante et enim.
+
+Curabitur posuere fermentum arcu id fringilla. Maecenas et purus ipsum. Maecenas auctor, velit a ullamcorper eleifend, arcu tellus adipiscing turpis, ac malesuada ante lorem eu massa. Aenean libero velit, mollis sed imperdiet in, fringilla eu lectus. Cras ullamcorper lobortis massa non volutpat. Nunc sapien lorem, posuere posuere mattis at, rutrum et dolor. Vivamus dignissim consequat nisi in viverra. Maecenas nec diam quis urna ultrices rutrum feugiat quis urna. Cras sed leo mauris. Vestibulum vitae odio ut nunc posuere lobortis. Ut felis eros, posuere at porttitor sit amet, tincidunt in justo. Nullam turpis magna, egestas ac sodales ut, cursus in eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus bibendum nulla nec augue vehicula laoreet. Morbi vitae nunc ac lorem pharetra pellentesque sit amet ut sapien. Maecenas placerat nunc ultricies felis consequat varius. Duis scelerisque ultrices dolor in commodo. Sed sagittis, enim quis pulvinar volutpat, lectus ante tempor arcu, id fringilla velit risus id nibh. Vivamus ac risus ut lorem dapibus ullamcorper.
+
+Vestibulum blandit lacus mattis eros cursus hendrerit. Quisque nibh arcu, condimentum ut imperdiet eget, interdum sed magna. Cras sem mauris, sagittis at dapibus sit amet, vulputate et felis. Suspendisse gravida tincidunt pellentesque. Fusce aliquet, augue eu porttitor ultricies, diam quam lacinia eros, sed consectetur diam dui ut augue. Phasellus turpis diam, hendrerit faucibus convallis et, rhoncus ac mauris. Vivamus vel turpis id arcu mattis imperdiet a nec enim. Ut ultricies mauris at sapien sollicitudin pharetra. Donec dignissim, metus ut condimentum semper, sapien elit pulvinar nisi, id placerat est orci iaculis lectus. Suspendisse quis sem a libero placerat placerat. Etiam ligula nisi, mattis vitae faucibus nec, malesuada et leo.
+
+Fusce mollis venenatis vehicula. Maecenas sit amet tortor mi, et dapibus leo. In ullamcorper dignissim lorem nec interdum. Sed nisl arcu, aliquet vel facilisis sed, rhoncus at quam. Nunc et posuere arcu. Nam faucibus blandit mi ac lacinia. Nullam ultrices tellus a turpis tincidunt sit amet convallis lacus posuere. Proin vitae orci vel justo tempus consequat sed mollis elit. Integer pellentesque bibendum nunc, et gravida mi auctor et. In vitae arcu eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum nulla bibendum justo fermentum suscipit. Cras lobortis lobortis vulputate. Donec risus nisl, sagittis vel congue vel, adipiscing ac augue. Curabitur at diam quis nisl fermentum luctus non ut nisi. Nulla sed justo urna, non viverra ante. Suspendisse congue, sem non convallis fringilla, est nisl varius nunc, id laoreet nisl neque in elit. Fusce posuere euismod mattis.
+
+Curabitur a massa vitae lectus laoreet eleifend. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc malesuada turpis vehicula velit placerat ut venenatis eros ultricies. Sed nulla ligula, pretium vestibulum sagittis sed, ornare at sem. Fusce ultrices, nibh non rhoncus semper, massa tortor eleifend ante, ac mollis odio arcu ac velit. Aenean quis augue eget lectus sollicitudin accumsan. Curabitur non tortor eros, eu condimentum nulla. Phasellus at sapien ac nibh pretium condimentum. Nulla rhoncus eros vel lorem ultricies dignissim. Donec tempor, risus in mollis pretium, justo urna fermentum mi, id varius ipsum ipsum quis felis. Mauris mollis diam quis lacus laoreet sit amet ultrices felis hendrerit. Nam ac dui nisi. Cras vel risus turpis.
+
+Vivamus eleifend sapien pulvinar libero blandit ullamcorper. Morbi vitae nisl eros, sit amet porttitor erat. Donec varius velit eu tellus feugiat a tempor nunc pellentesque. Morbi sed est libero. Nulla in turpis molestie orci posuere interdum vel vel erat. Curabitur tempus eros id sem scelerisque euismod. Pellentesque varius egestas metus, id cursus massa condimentum non. Donec sagittis ultricies lacus, sit amet iaculis magna bibendum vel. Nulla cursus velit vitae neque ultricies id bibendum dui eleifend. Pellentesque porttitor rutrum interdum. Fusce nulla mi, elementum vitae sagittis id, luctus id urna.
+
+Proin nec ornare magna. Morbi euismod sapien dolor, sed consectetur nisl. In erat dui, tristique ut fringilla sit amet, imperdiet eu sem. Quisque tristique augue sodales nunc malesuada nec varius lectus laoreet. In hac habitasse platea dictumst. Vestibulum a dolor leo, ut interdum lectus. Etiam eu tortor augue, nec tristique metus. Maecenas gravida mauris a ligula vulputate consequat. Suspendisse potenti. Proin id quam magna. Etiam at ipsum augue. Nam tincidunt bibendum mi, ac vehicula tellus pretium eu. Vivamus consectetur risus id enim aliquam et laoreet tortor lacinia. Phasellus interdum dapibus orci eu imperdiet. Nulla egestas, ipsum non rhoncus suscipit, tellus purus porttitor elit, et tempus arcu odio ut justo. Etiam id lorem sed velit sagittis consequat. Duis diam sem, scelerisque in mollis non, tempor eu elit. Nullam molestie blandit dapibus. Nullam interdum laoreet iaculis.
+
+Cras sagittis luctus risus vel placerat. In in justo eget nisi pellentesque varius ut quis mi. Cras eleifend leo ultricies metus auctor accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam vel velit orci, nec tristique metus. Aliquam viverra leo sit amet leo viverra tincidunt. Praesent pellentesque nisl vehicula leo fringilla blandit. Duis dignissim tincidunt placerat. Quisque ornare pellentesque nisi, a tempor odio laoreet sed. Ut dapibus dolor cursus arcu suscipit in facilisis nunc ornare. Suspendisse consectetur pulvinar tellus eget rutrum. Aenean sagittis egestas diam, sit amet posuere lorem euismod vitae.
+
+Morbi sit amet leo metus, non vehicula ligula. Mauris nec sem sit amet ipsum feugiat sodales id vitae risus. Nullam viverra nisi at erat vestibulum dictum. Morbi et nulla magna. Proin a augue neque, sit amet tristique orci. Suspendisse ornare lorem sodales augue vehicula nec varius turpis hendrerit. Praesent nulla augue, euismod ut pretium id, luctus vel mauris. Morbi eu elit eu augue scelerisque gravida. Sed porta tortor a magna mattis volutpat. Nullam vitae tellus quam, et rhoncus dolor. Nulla ultrices nunc nec mauris mattis in blandit nibh placerat. Nam velit arcu, ultrices a imperdiet eget, pulvinar vel augue. Sed at sapien magna. Nullam accumsan nulla in nulla bibendum molestie sollicitudin lorem faucibus. In nisl tortor, tincidunt ac molestie non, commodo ut dolor. Nullam non nunc enim. Mauris ultrices, dui nec scelerisque hendrerit, erat orci feugiat eros, sed elementum ligula ipsum at velit.
+
+Donec sit amet nisi at est aliquam euismod in eget justo. Ut justo turpis, lobortis quis accumsan sit amet, suscipit non lorem. Duis pulvinar lorem at magna porttitor tristique. Duis tortor mauris, auctor sit amet feugiat in, luctus et risus. Nunc lacinia, arcu id convallis lobortis, nibh sapien scelerisque dui, ac volutpat ante tellus nec odio. In euismod viverra nibh non fringilla. Nunc non nisl risus, at interdum nunc. Phasellus porta tempus aliquam. Cras massa tellus, aliquet a dignissim sed, posuere nec massa. Vestibulum et nisi nulla. Donec ut nisi ante. Sed ac justo eu ligula varius hendrerit a sed justo. Fusce ornare eleifend nisl, at condimentum arcu lobortis ut. Mauris neque felis, viverra ut dignissim dignissim, faucibus et lectus. Aenean laoreet tristique massa id congue.
+
+Mauris accumsan elit quis augue consectetur faucibus. Donec blandit, libero in tincidunt volutpat, purus est gravida eros, ut accumsan orci felis eu purus. Nam est nibh, tincidunt ut faucibus quis, consequat at est. Fusce nec diam ligula. Morbi eu ipsum purus, non semper neque. Maecenas in lacus arcu, vel imperdiet turpis. Curabitur eget nunc velit, in consequat nulla. Donec magna tortor, faucibus vitae hendrerit ac, pretium sed ipsum. Etiam pulvinar cursus enim facilisis consectetur. Maecenas pretium pellentesque nulla, nec viverra risus placerat sed. Nam rutrum justo id augue venenatis ut feugiat risus ultricies. Sed vitae risus nec velit rutrum faucibus at vel orci. Ut feugiat mi eu dui condimentum sit amet suscipit ligula imperdiet. Sed eu bibendum augue. Ut sit amet pulvinar libero. Duis luctus urna tincidunt purus porta euismod.
+
+Suspendisse ullamcorper mi congue lacus volutpat aliquam. Nam pharetra vestibulum enim. Aliquam erat volutpat. Ut convallis consequat neque. Donec commodo vulputate fermentum. Suspendisse potenti. Mauris at nibh ac felis blandit sagittis at sed velit. Morbi fringilla consequat eleifend. Duis lobortis, erat at vulputate posuere, odio diam sodales turpis, ut iaculis tortor leo ac risus. Proin blandit eleifend lacus ac imperdiet. Quisque consequat mollis elementum. Proin hendrerit odio ut orci tempor porta et non enim.
+
+Nullam luctus sagittis molestie. Proin sollicitudin rhoncus condimentum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque mattis, eros non ultrices sodales, libero sem iaculis dui, tempus porttitor libero nibh a eros. Donec et mauris imperdiet arcu semper luctus aliquet dictum turpis. Sed porttitor scelerisque vehicula. Sed eget metus elit, ac accumsan massa. Nam et diam quis purus rhoncus ultrices. Proin dapibus malesuada metus eu elementum. Aliquam luctus lorem non massa ornare non tincidunt quam ultricies. Vestibulum convallis diam id urna vestibulum aliquet. Nulla facilisi. Vestibulum nec egestas turpis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean purus elit, vestibulum quis vehicula vel, auctor vel odio. Mauris eu tellus nunc.
+
+Sed placerat, massa et adipiscing aliquam, massa neque gravida velit, vitae consectetur quam velit non augue. Vivamus et eros metus, et aliquet diam. Aliquam a dui sem. Aenean pretium lacus ut massa faucibus in iaculis sapien pellentesque. Integer odio nibh, condimentum et condimentum vitae, ullamcorper sit amet odio. Fusce vel velit ut diam imperdiet interdum eget at nibh. Suspendisse potenti. Proin vestibulum, ante nec scelerisque volutpat, sapien purus porta ante, at gravida arcu urna consequat dolor. Praesent lorem magna, fringilla quis faucibus id, ultrices sollicitudin risus. Etiam leo lectus, viverra eu laoreet in, sollicitudin eget felis.
+
+Vestibulum tincidunt enim ac diam commodo id placerat erat lacinia. Duis egestas ante venenatis est ullamcorper viverra. Fusce suscipit eleifend velit quis sollicitudin. Donec felis libero, ullamcorper tincidunt luctus eget, fermentum a risus. Phasellus placerat egestas dui, sit amet aliquet arcu tincidunt sit amet. Suspendisse pharetra pellentesque ante sed egestas. Ut sit amet nibh urna, quis tincidunt arcu. Fusce sed sapien in diam rutrum pretium. Duis eu congue diam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed placerat fermentum ligula eu pretium. Aliquam vitae orci nibh.
+
+Donec justo nisi, congue non ultrices eget, pharetra sit amet nunc. Etiam ullamcorper massa vel mauris semper posuere viverra nisi aliquet. Nullam mi tortor, feugiat sed viverra eu, congue id mi. Vestibulum nec enim sit amet libero dapibus hendrerit eget ac diam. Sed at massa nisl, a placerat tellus. Donec hendrerit tempus scelerisque. Nulla facilisi. Vivamus nec ipsum nisl, ut tempor mi. Integer ornare augue et orci scelerisque sed condimentum lectus scelerisque. Sed mauris lacus, egestas a laoreet facilisis, venenatis at ipsum. Aenean vel ante sed tortor sodales faucibus. Curabitur quis magna quis quam ultrices luctus vitae ac neque. Vivamus sed tortor et purus adipiscing consectetur hendrerit non eros. Vivamus et tristique erat. Maecenas eu quam nibh, sit amet fermentum ante. Fusce adipiscing congue nulla sodales condimentum. Nulla viverra dapibus enim vel rutrum. Mauris sodales varius metus sed gravida.
+
+Suspendisse potenti. Aliquam erat volutpat. Integer et diam purus, et semper erat. Proin ornare, lectus ac congue tincidunt, erat sapien ultrices erat, ac sagittis enim nulla faucibus ligula. In malesuada velit eu velit tincidunt et vestibulum nibh auctor. Integer in felis justo. Nullam in lorem lacus, eget sagittis odio. Quisque congue lorem vitae massa laoreet tempor. Quisque congue magna quis eros cursus vel luctus tellus gravida. Vivamus risus nibh, cursus pulvinar porttitor in, accumsan id orci. Donec hendrerit velit vel sem tristique porta. Vestibulum libero elit, aliquam et blandit nec, convallis id sem.
+
+Cras et odio urna. Sed ut semper metus. In hac habitasse platea dictumst. In hac habitasse platea dictumst. In nec augue eget sapien lacinia porta. Phasellus odio neque, tempus nec commodo at, vehicula ut lacus. Nullam accumsan ultricies placerat. Mauris tincidunt, erat ultrices placerat tincidunt, libero erat tempus nunc, eu consectetur risus est vel mauris. Duis in justo at augue lobortis molestie. Donec ut sem sed orci gravida tristique in at magna. Aliquam pellentesque, justo non mattis egestas, dolor purus aliquam elit, at blandit lectus neque non enim. Fusce sed turpis nisl, quis varius ligula. Proin id enim in neque scelerisque ultrices non id magna. Aenean tortor lectus, viverra eu elementum et, fringilla non arcu. Mauris eget odio eget enim aliquet fringilla. Proin pretium, libero eget dignissim rhoncus, ante sapien accumsan diam, a accumsan nibh neque id dolor. Sed est ante, euismod nec pulvinar sed, faucibus at turpis. Integer fringilla consequat sagittis. Sed elit ipsum, laoreet id viverra in, ornare sed massa.
+
+Praesent eget ligula quis orci condimentum congue ut id dolor. Ut eleifend, dui eu lacinia luctus, magna tellus consectetur nunc, gravida placerat elit risus sed nibh. Integer tristique ornare nibh, eu cursus ante ultrices et. Etiam vehicula pharetra purus quis aliquam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut at velit mauris. Nulla in ipsum ante, vel sollicitudin quam. Integer a justo ut mi tempor vulputate quis malesuada magna. Ut lacinia ligula nec massa tincidunt at vehicula tortor facilisis. Donec malesuada volutpat adipiscing. Donec iaculis mi at est venenatis consequat. Sed risus sem, accumsan ut dapibus sit amet, laoreet sed mauris.
+
+Phasellus quis euismod sem. Praesent sit amet odio libero. Proin ullamcorper lectus nec arcu pulvinar vitae commodo nunc porttitor. Sed accumsan tellus et nisl dictum vel ornare neque porttitor. Morbi id egestas massa. Nunc condimentum leo vitae nibh pulvinar facilisis. Nunc elit ligula, commodo sed mollis et, ullamcorper et risus. Curabitur risus justo, viverra vel malesuada quis, convallis vitae tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse potenti. Phasellus interdum nulla a est hendrerit quis scelerisque ante convallis. Duis suscipit dolor nec lectus rhoncus vestibulum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pellentesque pulvinar tellus quis rhoncus.
+
+Integer et pellentesque lorem. Maecenas blandit laoreet justo, non interdum nulla pellentesque sed. Nullam rutrum justo et nibh varius convallis. Praesent rhoncus eleifend ante vitae venenatis. Suspendisse ullamcorper sem at tortor fermentum suscipit sit amet in libero. Aliquam erat volutpat. Suspendisse egestas accumsan tortor, quis egestas lacus vulputate et. Sed vitae turpis in purus volutpat consectetur. Duis imperdiet nisi non augue iaculis dictum. Cras ut ipsum enim, vitae convallis urna. Sed ornare, lorem ac pellentesque iaculis, urna augue egestas arcu, nec mollis dolor tortor non justo. Cras adipiscing, massa vel tristique dignissim, dolor arcu sollicitudin mauris, eget luctus tortor purus in velit. Aenean suscipit erat et dui sagittis elementum. Mauris elementum, lorem et placerat fringilla, ante enim luctus nisl, id posuere dolor urna vel metus. Proin ligula mi, elementum fermentum rhoncus eget, sagittis at eros. Integer fringilla porta varius. Nullam dignissim semper tempus.
+
+Curabitur leo nibh, cursus vitae ultrices id, vulputate sit amet arcu. Aenean vitae lectus turpis, et gravida odio. Praesent mattis sagittis diam, ut fermentum justo euismod et. Nam pharetra, nibh non gravida dignissim, ipsum leo malesuada augue, egestas semper ipsum est sed tortor. Sed quis malesuada elit. In hac habitasse platea dictumst. Mauris ornare aliquet purus, scelerisque gravida orci pretium sed. Nunc sed orci massa, vel molestie lectus. Quisque eget adipiscing odio. Donec vestibulum justo dui, quis malesuada urna. Donec pretium tellus eget erat condimentum ornare. Sed sem urna, rutrum nec elementum ac, ornare vel enim. Fusce pellentesque varius ultricies. Suspendisse vulputate consectetur erat, ut pellentesque felis congue sit amet. Maecenas nisi tellus, fringilla a aliquam sit amet, consectetur eget felis. Maecenas nec urna at lacus posuere hendrerit nec sit amet nisl. Proin quis ligula eu mauris volutpat hendrerit. In interdum bibendum ultricies. Cras sit amet neque at felis sodales scelerisque. Etiam et vulputate sem.
+
+Fusce neque nulla, pharetra sit amet varius eget, aliquam vel tortor. Curabitur a odio velit. Phasellus tempus luctus vulputate. Aenean et libero pulvinar velit aliquet vulputate. In hac habitasse platea dictumst. Etiam at massa urna, eu pulvinar elit. Vestibulum lectus risus, tempor eget cursus ac, fermentum a augue. Maecenas at neque at lacus mollis elementum quis id tellus. Pellentesque ultricies eleifend urna, at blandit augue commodo non. Praesent tincidunt mauris sit amet enim posuere ullamcorper. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In euismod dignissim ligula, et tincidunt justo hendrerit id.
+
+Donec mi eros, bibendum id suscipit vel, posuere non tortor. Praesent enim urna, posuere at mollis vel, commodo sit amet urna. Vestibulum quis arcu quam. Fusce risus tortor, tempor vel mollis sit amet, ornare et lacus. Quisque sit amet velit justo. Nam vitae erat et nisi ultrices vehicula in quis nunc. Curabitur tristique elit eu nibh fringilla eget adipiscing elit sollicitudin. Nulla nec leo vel enim luctus scelerisque a id augue. Quisque interdum rhoncus elit, consectetur viverra felis fringilla id. Mauris volutpat ultricies nibh quis euismod. Quisque mattis semper purus et aliquet. Praesent vestibulum pulvinar quam, a dictum enim mattis non. Aenean mollis vehicula lorem, vel cursus leo venenatis id. Vivamus dapibus bibendum diam, at ultricies massa interdum et. Nulla lobortis aliquet nisi, non vehicula elit commodo in. Donec commodo, elit vel malesuada suscipit, urna lacus feugiat mi, ac mollis metus enim nec mi. Quisque fermentum, quam quis commodo luctus, quam ligula rhoncus urna, vel molestie ipsum risus ut nulla. Donec mi ligula, pulvinar vel convallis sed, volutpat eu urna. Curabitur a gravida lorem. Quisque sagittis felis ac urna laoreet quis pretium dolor congue.
+
+Proin vehicula diam id odio laoreet in suscipit quam blandit. Nullam sed ante at augue iaculis dignissim et quis ligula. Integer cursus posuere egestas. Duis turpis lacus, bibendum sit amet hendrerit ut, tincidunt vestibulum ante. Maecenas faucibus velit sit amet erat hendrerit et sodales neque scelerisque. Proin sit amet risus pharetra justo tincidunt accumsan ut posuere urna. In massa odio, viverra et pretium at, lobortis non tellus. Aliquam facilisis eleifend facilisis. Maecenas a risus id ante semper ultricies nec nec quam. Curabitur elementum, arcu ut fermentum luctus, nulla lorem accumsan mauris, vitae elementum felis enim ullamcorper lectus. Nulla facilisi. Etiam at turpis sed turpis viverra posuere. Praesent porta mattis mi id feugiat.
+
+Fusce commodo sodales erat quis sodales. Vestibulum dolor felis, interdum semper consectetur eu, mollis eget turpis. Integer accumsan elit sit amet libero dapibus eu viverra tortor porttitor. Ut pulvinar mattis tellus, non pulvinar erat dignissim vitae. Donec sagittis tincidunt quam, in auctor est euismod eu. Aenean feugiat luctus dolor at tincidunt. Aenean a mi sed lacus porta dapibus. Pellentesque ligula est, ultricies vitae tincidunt nec, placerat quis ipsum. Morbi dignissim libero sed nunc mollis feugiat. Vivamus mauris ante, venenatis eget sodales pharetra, vestibulum a ipsum. Vestibulum suscipit tempor sem, sagittis bibendum diam vehicula tempor. Proin at imperdiet dui. Mauris et metus quis mauris tincidunt tempor.
+
+Nunc pulvinar scelerisque magna non lobortis. Pellentesque eget risus mauris, sed suscipit lectus. Nam pharetra magna non urna vehicula rutrum. Duis adipiscing elementum porta. Donec eleifend enim vitae justo ultrices sodales. Nunc facilisis dui nec justo pretium blandit eu in est. Sed turpis lectus, imperdiet ac convallis ut, adipiscing vel mauris. Nulla commodo sollicitudin ante, ut vestibulum leo sollicitudin vitae. Curabitur imperdiet tellus sed tellus tincidunt porta. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus convallis viverra vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
+
+Sed at mi tortor. Morbi ac sapien nisl. Etiam at sollicitudin nisl. Vestibulum vulputate varius tortor. Donec id magna dolor, non molestie sem. Nullam dolor elit, vulputate ac convallis quis, adipiscing id neque. Aliquam at justo justo, non sagittis nunc. Nullam quis sem libero, non suscipit quam. Duis nec ipsum metus. Praesent nec turpis quam, non malesuada nisi. Praesent ultricies suscipit sollicitudin. Pellentesque at massa nec nisl aliquet dapibus eget et dolor. Vestibulum ullamcorper dui sit amet erat imperdiet varius. In porttitor ultrices purus in imperdiet. Maecenas at erat fringilla tellus ultricies placerat id ut nulla. Aliquam tempus condimentum nunc, in molestie erat laoreet et. Phasellus at erat in massa luctus facilisis quis id purus. Duis dui turpis, gravida in aliquet sit amet, condimentum sed magna. Praesent non tellus in nunc aliquam dictum quis a enim.
+
+Maecenas sed neque velit, ut iaculis neque. Morbi leo arcu, volutpat non sodales ut, volutpat in ligula. Curabitur blandit neque ac arcu lobortis egestas. Nunc id odio ante, in sodales quam. Suspendisse condimentum est et massa bibendum malesuada. Sed fermentum tellus vel lorem dignissim fermentum. Maecenas pretium est sit amet dui congue viverra. Nullam vestibulum accumsan sagittis. Phasellus sit amet justo leo. Pellentesque ut sem lectus, elementum convallis nisl. Pellentesque dictum porttitor nisi, vel feugiat dui interdum nec. Phasellus arcu risus, convallis sit amet sodales in, imperdiet sed lacus. Mauris sed quam sit amet est venenatis sodales. Ut eleifend quam in enim bibendum eu rutrum erat placerat. Nunc faucibus massa ac augue dignissim venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed sed commodo urna. Nam eu urna tortor, eu pharetra magna. Pellentesque tortor elit, molestie sit amet rhoncus eget, aliquam a quam. Phasellus vel nunc et sem pellentesque hendrerit.
+
+Aliquam eu arcu ac felis volutpat scelerisque. Morbi ut dignissim nibh. Nullam convallis, odio a aliquet dignissim, purus leo elementum augue, vitae tristique neque dolor eu nulla. Vivamus sit amet massa a augue lacinia vehicula et vel dolor. Etiam sapien sem, consequat vel vehicula id, pellentesque at augue. Donec est neque, consequat ac convallis in, suscipit sed tortor. Maecenas imperdiet, dolor sit amet congue congue, metus urna suscipit libero, ut congue nisl sapien facilisis est. Nunc eget orci odio, ut aliquam dolor. Fusce nec leo eu enim sollicitudin pharetra in nec sapien. Cras id nisi vitae ipsum semper vehicula. Nunc eu magna ac felis vehicula eleifend vel non felis.
+
+Vestibulum mattis dapibus mauris varius pretium. Nulla facilisi. Morbi quis euismod turpis. Nunc dignissim molestie consectetur. Quisque a mattis ipsum. Ut viverra leo sed odio faucibus sodales. Sed placerat luctus mattis. Aenean auctor iaculis placerat. Pellentesque lorem dui, pharetra id faucibus eget, iaculis egestas diam. Sed a metus tellus, eu aliquam dolor. Pellentesque eget nunc urna. Ut placerat erat in velit ornare luctus.
+
+Proin pharetra enim non lectus fringilla eu varius diam fermentum. Etiam tellus quam, sagittis a pellentesque in, tincidunt non ipsum. Vivamus id faucibus metus. Aliquam sodales venenatis massa nec lacinia. Pellentesque a urna a quam accumsan sollicitudin. Donec feugiat ante a urna aliquam ut laoreet neque molestie. Sed metus erat, hendrerit ornare tempus ut, aliquet eget neque. Morbi rutrum, lectus sit amet dictum luctus, ante tellus molestie nunc, non interdum orci velit a lorem. Suspendisse scelerisque augue eu velit placerat ac iaculis est mattis. Mauris lorem quam, molestie vel tempus eget, tincidunt et est. Etiam sit amet risus ac tellus ultrices porta sit amet a nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
+
+Fusce orci leo, tempor sed fermentum ut, rhoncus et erat. Integer a vulputate diam. Pellentesque luctus ornare varius. Quisque ornare tempus lacus quis porta. Integer consequat vestibulum eleifend. Nulla id eros eget odio eleifend vehicula. Duis ultricies ante eget massa vestibulum suscipit. Nunc et dui mi. Aliquam sit amet nunc neque, ut iaculis lorem. Nunc ornare lacinia mauris sed semper. Donec venenatis mollis urna at posuere. Etiam vestibulum dignissim magna nec hendrerit. Nullam interdum suscipit eros, ac sollicitudin mi semper in. Etiam eget feugiat augue. Etiam id imperdiet enim. Proin sed libero id quam dapibus sollicitudin. Cras suscipit dapibus nisi, quis sagittis dui consectetur vitae. Aenean lobortis congue sapien a pulvinar.
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a diam in nulla porta hendrerit. Suspendisse massa ligula, tristique eu molestie quis, congue ut neque. Nullam vitae libero eget justo feugiat gravida ullamcorper at quam. Aenean eget interdum risus. Aliquam erat volutpat. Morbi odio purus, pharetra at cursus eget, tristique sit amet est. Pellentesque et turpis nisi, vitae vulputate dolor. Quisque odio nunc, condimentum ut mollis eget, laoreet pretium metus. Morbi vel est a nulla ultricies laoreet. Morbi ac ultrices eros. Fusce et pharetra leo. Pellentesque volutpat urna orci, sit amet scelerisque urna. Etiam vel orci mauris. Etiam sit amet lectus id massa elementum accumsan. Ut tincidunt ultricies lorem lacinia tempor.
+
+Mauris placerat massa at arcu ultricies sit amet malesuada urna sollicitudin. Pellentesque eleifend rhoncus ullamcorper. Fusce malesuada tincidunt lorem vel ullamcorper. Fusce non quam sapien. In hac habitasse platea dictumst. Praesent facilisis feugiat tempus. Quisque dictum placerat odio, vitae tincidunt lorem tincidunt in. Nam molestie, nisl id tempor auctor, erat nunc gravida nisi, nec vulputate tellus turpis tincidunt mi. Maecenas pretium porttitor lectus, vitae volutpat massa rutrum quis. Mauris ac sapien a arcu interdum condimentum ut quis urna. Mauris ligula neque, malesuada non rutrum et, condimentum ac velit. Sed condimentum neque at eros placerat placerat. Sed porttitor nibh non ipsum vehicula auctor commodo velit lobortis. Aliquam auctor elementum elementum.
+
+Nam aliquam pretium purus vel auctor. Mauris et arcu vel libero adipiscing dictum fermentum sed metus. Mauris dictum elit sed neque pharetra ac facilisis ante volutpat. Ut ut aliquam ligula. Duis vitae tortor nibh. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi varius pulvinar purus id vehicula. Proin sit amet libero at leo varius egestas. Vestibulum posuere porttitor felis, nec lacinia orci rhoncus non. Suspendisse potenti. Maecenas ut tempor felis. Cras at ipsum vitae tellus luctus aliquet. Nulla mauris erat, feugiat et condimentum id, adipiscing sed tellus. Nunc condimentum luctus auctor. In hac habitasse platea dictumst. Cras libero ante, commodo at adipiscing ut, consectetur ut metus. Maecenas eros augue, cursus cursus porta vitae, ullamcorper egestas tortor. Nullam ante felis, viverra in convallis quis, gravida sit amet velit.
+
+Duis consectetur sagittis enim ut dignissim. Integer ut augue at odio vehicula tincidunt. Nam sapien tortor, euismod et suscipit eu, euismod in tellus. Nam ornare orci ac nulla consequat quis semper risus aliquam. Nunc tristique turpis et lacus venenatis a fermentum odio placerat. Morbi condimentum, enim ac tristique rutrum, sem nisi rhoncus orci, id mollis purus justo ut dui. Nulla facilisi. Suspendisse consectetur odio rhoncus ante porttitor ac eleifend metus suscipit. In porttitor tempus massa quis dictum. Integer in orci nibh. Duis nec risus eu nunc sagittis mattis at vitae nunc. Donec sed mi sed ante fermentum posuere nec a est. Quisque vel massa quam. Pellentesque feugiat massa venenatis risus bibendum sit amet dapibus lectus gravida. Mauris nunc lorem, interdum sit amet pulvinar vitae, euismod id mi. Suspendisse turpis elit, lobortis ac fringilla at, aliquet eget libero. Quisque eleifend ullamcorper pharetra. Fusce vitae eros tortor, sed pulvinar neque. Praesent pretium, felis quis adipiscing laoreet, sapien turpis molestie erat, malesuada pretium urna purus id ante. Aliquam ac massa sit amet sapien scelerisque convallis.
+
+Quisque eget libero leo. In nec diam vitae metus varius tempus vitae non purus. Phasellus porttitor, lectus vel aliquam tincidunt, nisl odio volutpat diam, nec ultrices elit quam eget lectus. Sed mollis purus at ipsum porta tempus. Sed rhoncus nisi vel magna rhoncus vitae tristique massa tempor. Etiam metus ligula, hendrerit eu accumsan vitae, euismod ac mi. Suspendisse dui turpis, congue ut fringilla et, laoreet eu enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc aliquet lorem quis dolor pharetra tempor. Integer molestie varius laoreet. Curabitur ultrices nibh sit amet elit condimentum sit amet sagittis elit venenatis. Aliquam magna nunc, suscipit sed aliquam in, fringilla vel libero. Nunc eget elit risus. Suspendisse imperdiet, magna vel pulvinar sodales, metus velit accumsan mi, sed venenatis erat dolor eget turpis. Proin lacinia tincidunt semper. Fusce vestibulum sodales massa, a dapibus libero lobortis a. Pellentesque augue mauris, posuere sed faucibus eget, molestie at ante. Proin orci nunc, auctor vel auctor vitae, ultricies sit amet lectus. Integer at nunc eget diam tincidunt suscipit vitae et libero. Donec ac quam tortor, in vestibulum leo.
+
+Praesent laoreet pharetra libero, quis cursus erat tincidunt ac. Vivamus euismod odio vel erat placerat sed vehicula eros rutrum. Sed fermentum, lectus feugiat feugiat dictum, quam sapien commodo tellus, vel ornare urna felis interdum est. Integer condimentum lectus eu nulla lacinia ut porta turpis tempor. Pellentesque quis semper justo. Duis malesuada faucibus condimentum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin condimentum est quis urna pulvinar vehicula. Nam convallis enim non nibh elementum blandit. Curabitur dui urna, aliquam sed posuere eget, porttitor et tortor. Nam vitae velit dignissim quam porttitor congue sed quis massa. Cras sed diam vestibulum nisl pretium rutrum vel at ipsum. In eget euismod sem. Pellentesque vitae sem et augue vehicula pretium sit amet et quam. Proin enim nunc, malesuada vel lobortis non, viverra non leo. Donec eu convallis nibh. Fusce sodales orci nec felis vulputate interdum at in sem. Nulla facilisi.
+
+Nunc posuere orci sed diam fringilla ullamcorper. Vivamus laoreet condimentum purus sit amet consequat. Donec at tristique ipsum. Donec tincidunt, nisi sit amet commodo sagittis, velit diam eleifend nulla, sed faucibus enim arcu eget nisi. Quisque condimentum laoreet ante vel posuere. Aliquam sit amet massa quis orci placerat posuere ut at velit. Ut eu commodo nisi. Pellentesque ornare quam et lorem facilisis nec venenatis ligula dictum. Aliquam vel arcu diam. Nullam ut elit nec lorem eleifend tincidunt vel sed orci. In vulputate semper felis, id tincidunt neque mollis a. Quisque eu nisi non justo vehicula pellentesque. Maecenas nec sem nibh, dictum sagittis nibh. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In diam purus, commodo eget hendrerit eget, aliquam a sapien. Sed et justo eros. Etiam eget massa urna, non gravida enim. Cras ac ornare ligula.
+
+Suspendisse potenti. Sed non suscipit arcu. Mauris augue elit, porttitor non hendrerit id, egestas a eros. Nunc id orci magna. Fusce massa urna, gravida et porttitor ac, posuere eget nisl. Proin sed. 
+Here is the last line there is no return
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test-files/smalltext.txt
@@ -0,0 +1,1 @@
+this is a short text file
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_cat2.py
@@ -0,0 +1,27 @@
+# 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/.
+
+import hashlib
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class Cat2TestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """This tests copying a binary file to and from the device the binary.
+           File is > 64K.
+        """
+        testroot = posixpath.join(self.dm.getDeviceRoot(), 'infratest')
+        self.dm.removeDir(testroot)
+        self.dm.mkDir(testroot)
+        origFile = open(os.path.join('test-files', 'mybinary.zip'), 'rb').read()
+        self.dm.pushFile(
+                         os.path.join('test-files', 'mybinary.zip'),
+                         posixpath.join(testroot, 'mybinary.zip'))
+        resultFile = self.dm.catFile(posixpath.join(testroot, 'mybinary.zip'))
+        self.assertEqual(hashlib.md5(origFile).hexdigest(),
+                         hashlib.md5(resultFile).hexdigest())
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_datachannel.py
@@ -0,0 +1,56 @@
+# 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/.
+
+import socket
+from time import strptime
+import re
+
+from dmunit import DeviceManagerTestCase
+
+
+class DataChannelTestCase(DeviceManagerTestCase):
+
+    runs_on_test_device = False
+
+    def runTest(self):
+        """ This tests the heartbeat and the data channel
+        """
+        ip = self.dm.host
+        port = 20700
+
+        # Let's connect
+        self._datasock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        # Assume 60 seconds between heartbeats
+        self._datasock.settimeout(float(60 * 2))
+        self._datasock.connect((ip, port))
+        self._connected = True
+
+        # Let's listen
+        numbeats = 0
+        capturedHeader = False
+        while(numbeats < 3):
+            data = self._datasock.recv(1024)
+            print data
+            self.assertNotEqual(len(data), 0)
+
+            # Check for the header
+            if not capturedHeader:
+                m = re.match(r"(.*?) trace output", data)
+                self.assertNotEqual(m, None,
+                    'trace output line does not match. The line: ' + str(data))
+                lastHeartbeatTime = strptime(m.group(1), "%Y%m%d-%H:%M:%S")
+                capturedHeader = True
+
+            # Check for standard heartbeat messsage
+            m = re.match(r"(.*?) Thump thump - (.*)", data)
+            if m == None:
+                # This isn't an error, it usually means we've obtained some
+                # unexpected data from the device
+                continue
+
+            # Ensure it matches our format
+            mHeartbeatTime = m.group(1)
+            mHeartbeatTime = strptime(mHeartbeatTime, "%Y%m%d-%H:%M:%S")
+            mDeviceID = m.group(2)
+            numbeats = numbeats + 1
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_getdir.py
@@ -0,0 +1,54 @@
+# 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/.
+
+import os
+import posixpath
+import shutil
+import tempfile
+
+from dmunit import DeviceManagerTestCase
+
+
+class GetDirectoryTestCase(DeviceManagerTestCase):
+
+    def _setUp(self):
+        self.localsrcdir = tempfile.mkdtemp()
+        os.makedirs(os.path.join(self.localsrcdir, 'push1', 'sub.1', 'sub.2'))
+        path = os.path.join(self.localsrcdir,
+                            'push1', 'sub.1', 'sub.2', 'testfile')
+        file(path, 'w').close()
+        os.makedirs(os.path.join(self.localsrcdir, 'push1', 'emptysub'))
+        self.localdestdir = tempfile.mkdtemp()
+        self.expected_filelist = ['emptysub', 'sub.1']
+
+    def tearDown(self):
+        shutil.rmtree(self.localsrcdir)
+        shutil.rmtree(self.localdestdir)
+
+    def runTest(self):
+        """This tests the getDirectory() function.
+        """
+        testroot = posixpath.join(self.dm.getDeviceRoot(), 'infratest')
+        self.dm.removeDir(testroot)
+        self.dm.mkDir(testroot)
+        self.dm.pushDir(
+            os.path.join(self.localsrcdir, 'push1'),
+            posixpath.join(testroot, 'push1'))
+        # pushDir doesn't copy over empty directories, but we want to make sure
+        # that they are retrieved correctly.
+        self.dm.mkDir(posixpath.join(testroot, 'push1', 'emptysub'))
+        filelist = self.dm.getDirectory(
+            posixpath.join(testroot, 'push1'),
+            os.path.join(self.localdestdir, 'push1'))
+        filelist.sort()
+        self.assertEqual(filelist, self.expected_filelist)
+        self.assertTrue(os.path.exists(
+            os.path.join(self.localdestdir,
+                         'push1', 'sub.1', 'sub.2', 'testfile')))
+        self.assertTrue(os.path.exists(
+            os.path.join(self.localdestdir, 'push1', 'emptysub')))
+        filelist = self.dm.getDirectory('/dummy',
+            os.path.join(self.localdestdir, '/none'))
+        self.assertEqual(filelist, None)
+        self.assertFalse(os.path.exists(self.localdestdir + '/none'))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_info.py
@@ -0,0 +1,25 @@
+# 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 dmunit import DeviceManagerTestCase
+
+
+class InfoTestCase(DeviceManagerTestCase):
+
+    runs_on_test_device = False
+
+    def runTest(self):
+        """ This tests the "info" command
+        """
+        cmds = ('os', 'id', 'systime', 'uptime', 'screen',
+                'memory', 'power', 'process')
+        for c in cmds:
+            data = self.dm.getInfo(c)
+            print c + str(data)
+
+        print " ==== Now we call them all ===="
+        data = self.dm.getInfo('all')
+        print str(data)
+
+        # No real good way to verify this.  If it doesn't throw, we're ok.
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_isdir.py
@@ -0,0 +1,31 @@
+# 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/.
+
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class IsDirTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """This tests the isDir() function.
+        """
+        testroot = posixpath.join(self.dm.getDeviceRoot(), 'infratest')
+        self.dm.removeDir(testroot)
+        self.dm.mkDir(testroot)
+        self.assertTrue(self.dm.isDir(testroot))
+        testdir = posixpath.join(testroot, 'testdir')
+        self.assertFalse(self.dm.isDir(testdir))
+        self.dm.mkDir(testdir)
+        self.assertTrue(self.dm.isDir(testdir))
+        self.dm.pushFile(os.path.join('test-files', 'mytext.txt'),
+                         posixpath.join(testdir, 'mytext.txt'))
+        self.assertFalse(self.dm.isDir(posixpath.join(testdir, 'mytext.txt')))
+        self.dm.removeDir(testroot)
+        self.assertFalse(self.dm.isDir(testroot))
+        self.assertFalse(self.dm.isDir(testdir))
+        self.assertFalse(self.dm.isDir(posixpath.join(testdir, 'mytext.txt')))
+        self.assertFalse(self.dm.isDir(posixpath.join('/', 'noroot', 'nosub')))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_prompt.py
@@ -0,0 +1,30 @@
+# 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/.
+
+import re
+import socket
+
+from dmunit import DeviceManagerTestCase
+
+
+class PromptTestCase(DeviceManagerTestCase):
+
+    def tearDown(self):
+        if self.sock:
+            self.sock.close()
+
+    def runTest(self):
+        """This tests getting a prompt from the device.
+        """
+        self.sock = None
+        ip = self.dm.host
+        port = self.dm.port
+
+        promptre = re.compile('.*\$\>\x00')
+        data = ""
+        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.sock.connect((ip, int(port)))
+        data = self.sock.recv(1024)
+        print data
+        self.assert_(promptre.match(data))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_ps.py
@@ -0,0 +1,28 @@
+# 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/.
+
+import re
+
+from dmunit import DeviceManagerTestCase
+
+
+class ProcessListTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """ This tests getting a process list from the device
+        """
+        proclist = self.dm.getProcessList()
+
+        # This returns a process list of the form:
+        # [[<procid>,<procname>],[<procid>,<procname>]...]
+        # on android the userID is affixed to the process array:
+        # [[<procid>, <procname>, <userid>]...]
+        procid = re.compile('^[a-f0-9]+')
+        procname = re.compile('.+')
+
+        self.assertNotEqual(len(proclist), 0)
+
+        for item in proclist:
+            self.assert_(procid.match(item[0]))
+            self.assert_(procname.match(item[1]))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_pull.py
@@ -0,0 +1,33 @@
+# 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/.
+
+import hashlib
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class PullTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """Tests the "pull" command with a binary file.
+        """
+        m_orig = hashlib.md5()
+        m_new = hashlib.md5()
+        local_test_file = os.path.join('test-files', 'mybinary.zip')
+        m_orig.update(file(local_test_file, 'r').read())
+
+        testroot = self.dm.getDeviceRoot()
+        remote_test_file = posixpath.join(testroot, 'mybinary.zip')
+        self.dm.removeFile(remote_test_file)
+        self.dm.pushFile(local_test_file, remote_test_file)
+        m_new.update(self.dm.pullFile(remote_test_file))
+        # use hexdigest() instead of digest() since values are printed
+        # if assert fails
+        self.assertEqual(m_orig.hexdigest(), m_new.hexdigest())
+
+        remote_missing_file = posixpath.join(testroot, 'doesnotexist')
+        self.dm.removeFile(remote_missing_file)  # just to be sure
+        self.assertEqual(self.dm.pullFile(remote_missing_file), None)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_push1.py
@@ -0,0 +1,40 @@
+# 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/.
+
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class Push1TestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """ This tests copying a directory structure to the device
+        """
+        dvroot = self.dm.getDeviceRoot()
+        dvpath = posixpath.join(dvroot, 'infratest')
+        self.dm.removeDir(dvpath)
+        self.dm.mkDir(dvpath)
+
+        p1 = os.path.join('test-files', 'push1')
+        # Set up local stuff
+        try:
+            os.rmdir(p1)
+        except:
+            pass
+
+        if not os.path.exists(p1):
+            os.makedirs(os.path.join(p1, 'sub.1', 'sub.2'))
+        if not os.path.exists(os.path.join(p1, 'sub.1', 'sub.2', 'testfile')):
+            file(os.path.join(p1, 'sub.1', 'sub.2', 'testfile'), 'w').close()
+
+        # push the directory
+        self.dm.pushDir(p1, posixpath.join(dvpath, 'push1'))
+
+        # verify
+        self.assert_(
+            self.dm.dirExists(posixpath.join(dvpath, 'push1', 'sub.1')))
+        self.assert_(self.dm.dirExists(
+            posixpath.join(dvpath, 'push1', 'sub.1', 'sub.2')))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_push2.py
@@ -0,0 +1,39 @@
+# 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/.
+
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class Push2TestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """ This tests copying a directory structure with files to the device
+        """
+        testroot = posixpath.join(self.dm.getDeviceRoot(), 'infratest')
+        self.dm.removeDir(testroot)
+        self.dm.mkDir(testroot)
+        path = posixpath.join(testroot, 'push2')
+        self.dm.pushDir(os.path.join('test-files', 'push2'), path)
+
+        # Let's walk the tree and make sure everything is there
+        # though it's kind of cheesy, we'll use the validate file to compare
+        # hashes - we use the client side hashing when testing the cat command
+        # specifically, so that makes this a little less cheesy, I guess.
+        self.assert_(
+            self.dm.dirExists(posixpath.join(testroot, 'push2', 'sub1')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub1', 'file1.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'file1.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub1', 'sub1.1', 'file2.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'sub1.1', 'file2.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub2', 'file3.txt'),
+            os.path.join('test-files', 'push2', 'sub2', 'file3.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'file4.bin'),
+            os.path.join('test-files', 'push2', 'file4.bin')))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_pushbinary.py
@@ -0,0 +1,20 @@
+# 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/.
+
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class PushBinaryTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """This tests copying a binary file.
+        """
+        testroot = self.dm.getDeviceRoot()
+        self.dm.removeFile(posixpath.join(testroot, 'mybinary.zip'))
+        self.assert_(self.dm.pushFile(
+            os.path.join('test-files', 'mybinary.zip'),
+            posixpath.join(testroot, 'mybinary.zip')))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_pushsmalltext.py
@@ -0,0 +1,20 @@
+# 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/.
+
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class PushSmallTextTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """This tests copying a small text file.
+        """
+        testroot = self.dm.getDeviceRoot()
+        self.dm.removeFile(posixpath.join(testroot, 'smalltext.txt'))
+        self.assert_(self.dm.pushFile(
+            os.path.join('test-files', 'smalltext.txt'),
+            posixpath.join(testroot, 'smalltext.txt')))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_unzip.py
@@ -0,0 +1,60 @@
+# 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/.
+
+import os
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class UnzipTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """ This tests unzipping a file on the device.
+        """
+        testroot = posixpath.join(self.dm.getDeviceRoot(), 'infratest')
+        self.dm.removeDir(testroot)
+        self.dm.mkDir(testroot)
+        self.assert_(self.dm.pushFile(
+            os.path.join('test-files', 'mybinary.zip'),
+            posixpath.join(testroot, 'mybinary.zip')))
+        self.assertNotEqual(self.dm.unpackFile(
+            posixpath.join(testroot, 'mybinary.zip')), None)
+        # the mybinary.zip file has the zipped up contents of test-files/push2
+        # so we validate it the same as test_push2.
+        self.assert_(self.dm.dirExists(
+            posixpath.join(testroot, 'push2', 'sub1')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub1', 'file1.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'file1.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub1', 'sub1.1', 'file2.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'sub1.1', 'file2.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub2', 'file3.txt'),
+            os.path.join('test-files', 'push2', 'sub2', 'file3.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'file4.bin'),
+            os.path.join('test-files', 'push2', 'file4.bin')))
+
+        # test dest_dir param
+        newdir = posixpath.join(testroot, 'newDir')
+        self.dm.mkDir(newdir)
+
+        self.assertNotEqual(self.dm.unpackFile(
+            posixpath.join(testroot, 'mybinary.zip'), newdir), None)
+
+        self.assert_(self.dm.dirExists(posixpath.join(newdir, 'push2', 'sub1')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(newdir, 'push2', 'sub1', 'file1.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'file1.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(newdir, 'push2', 'sub1', 'sub1.1', 'file2.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'sub1.1', 'file2.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(newdir, 'push2', 'sub2', 'file3.txt'),
+            os.path.join('test-files', 'push2', 'sub2', 'file3.txt')))
+        self.assert_(self.dm.validateFile(
+            posixpath.join(newdir, 'push2', 'file4.bin'),
+            os.path.join('test-files', 'push2', 'file4.bin')))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/manifest.ini
@@ -0,0 +1,1 @@
+[sut.py]
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+import socket
+import mozdevice
+from threading import Thread
+import unittest
+
+class BasicTest(unittest.TestCase):
+
+    def _serve_thread(self):
+        need_connection = True
+        while self.commands:
+            (command, response) = self.commands.pop(0)
+            if need_connection:
+                conn, addr = self._sock.accept()
+                need_connection = False
+            conn.send("$>\x00")
+            data = conn.recv(1024).strip()
+            self.assertEqual(data, command)
+            conn.send("%s\n" % response)
+            conn.send("$>\x00")
+
+    def _serve(self, commands):
+        self.commands = commands
+        thread = Thread(target=self._serve_thread)
+        thread.start()
+        return thread
+
+    def test_init(self):
+        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self._sock.bind(("127.0.0.1", 0))
+        self._sock.listen(1)
+
+        thread = self._serve([("testroot", "/mnt/sdcard"),
+                              ("cd /mnt/sdcard/tests", ""),
+                              ("cwd", "/mnt/sdcard/tests")])
+
+        port = self._sock.getsockname()[1]
+        d = mozdevice.DroidSUT("127.0.0.1", port=port)
+        thread.join()
+
+if __name__ == '__main__':
+    unittest.main()