Backed out changeset e73241bcb49a (bug 1340584) for Windows build failures a=backout CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Thu, 16 Mar 2017 10:25:15 -0700
changeset 398634 cfe7fdc401e0b4eb8eb9c77f9b3da85b7ad23450
parent 398633 e73241bcb49a399d1de1e512d0334eeece0dcffd
child 398635 34554df9f50cb34482838c1200fea11cb87b9095
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1340584
milestone55.0a1
backs oute73241bcb49a399d1de1e512d0334eeece0dcffd
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset e73241bcb49a (bug 1340584) for Windows build failures a=backout CLOSED TREE MozReview-Commit-ID: 22csfCgl7Wb
build/mobile/remoteautomation.py
config/rules.mk
js/src/jit-test/jit_test.py
js/src/tests/lib/jittests.py
layout/tools/reftest/mach_commands.py
layout/tools/reftest/mach_test_package_commands.py
layout/tools/reftest/reftestcommandline.py
layout/tools/reftest/remotereftest.py
testing/mach_commands.py
testing/mochitest/mochitest_options.py
testing/mochitest/runrobocop.py
testing/mozbase/docs/devicemanagement.rst
testing/mozbase/docs/index.rst
testing/mozbase/docs/mozdevice.rst
testing/mozbase/docs/mozversion.rst
testing/mozbase/moz.build
testing/mozbase/mozdevice/mozdevice/Zeroconf.py
testing/mozbase/mozdevice/mozdevice/__init__.py
testing/mozbase/mozdevice/mozdevice/devicemanager.py
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
testing/mozbase/mozdevice/mozdevice/dmcli.py
testing/mozbase/mozdevice/mozdevice/droid.py
testing/mozbase/mozdevice/mozdevice/sutini.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/setup-tools.sh
testing/mozbase/mozdevice/sut_tests/test-files/mytext.txt
testing/mozbase/mozdevice/sut_tests/test-files/smalltext.txt
testing/mozbase/mozdevice/sut_tests/test-files/test_script.sh
testing/mozbase/mozdevice/sut_tests/test_datachannel.py
testing/mozbase/mozdevice/sut_tests/test_exec.py
testing/mozbase/mozdevice/sut_tests/test_exec_env.py
testing/mozbase/mozdevice/sut_tests/test_fileExists.py
testing/mozbase/mozdevice/sut_tests/test_getdir.py
testing/mozbase/mozdevice/sut_tests/test_info.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/tests/droidsut_launch.py
testing/mozbase/mozdevice/tests/manifest.ini
testing/mozbase/mozdevice/tests/sut.py
testing/mozbase/mozdevice/tests/sut_app.py
testing/mozbase/mozdevice/tests/sut_basic.py
testing/mozbase/mozdevice/tests/sut_chmod.py
testing/mozbase/mozdevice/tests/sut_copytree.py
testing/mozbase/mozdevice/tests/sut_fileExists.py
testing/mozbase/mozdevice/tests/sut_fileMethods.py
testing/mozbase/mozdevice/tests/sut_info.py
testing/mozbase/mozdevice/tests/sut_ip.py
testing/mozbase/mozdevice/tests/sut_kill.py
testing/mozbase/mozdevice/tests/sut_list.py
testing/mozbase/mozdevice/tests/sut_logcat.py
testing/mozbase/mozdevice/tests/sut_mkdir.py
testing/mozbase/mozdevice/tests/sut_movetree.py
testing/mozbase/mozdevice/tests/sut_ps.py
testing/mozbase/mozdevice/tests/sut_pull.py
testing/mozbase/mozdevice/tests/sut_push.py
testing/mozbase/mozdevice/tests/sut_remove.py
testing/mozbase/mozdevice/tests/sut_time.py
testing/mozbase/mozdevice/tests/sut_unpackfile.py
testing/mozbase/mozversion/mozversion/mozversion.py
testing/mozharness/configs/android/androidarm_4_3.py
testing/mozharness/configs/android/androidx86.py
testing/mozharness/mozharness/mozilla/testing/device.py
testing/mozharness/scripts/android_emulator_unittest.py
testing/remotecppunittests.py
testing/testsuite-targets.mk
testing/xpcshell/mach_commands.py
testing/xpcshell/remotexpcshelltests.py
testing/xpcshell/xpcshellcommandline.py
tools/lint/flake8.lint
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -322,16 +322,19 @@ class RemoteAutomation(Automation):
             Fetch the full remote log file using devicemanager, process them and
             return whether there were any new log entries since the last call.
             """
             if not self.dm.fileExists(self.proc):
                 return False
             try:
                 newLogContent = self.dm.pullFile(self.proc, self.stdoutlen)
             except DMError:
+                # we currently don't retry properly in the pullFile
+                # function in dmSUT, so an error here is not necessarily
+                # the end of the world
                 return False
             if not newLogContent:
                 return False
 
             self.stdoutlen += len(newLogContent)
 
             if self.messageLogger is None:
                 testStartFilenames = re.findall(r"TEST-START \| ([^\s]*)", newLogContent)
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -75,22 +75,28 @@ CPP_UNIT_TESTS_FILES = $(CPP_UNIT_TESTS)
 CPP_UNIT_TESTS_DEST = $(DIST)/cppunittests
 CPP_UNIT_TESTS_TARGET = target
 INSTALL_TARGETS += CPP_UNIT_TESTS
 endif
 
 run-cppunittests::
 	@$(PYTHON) $(MOZILLA_DIR)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
 
+cppunittests-remote: DM_TRANS?=adb
 cppunittests-remote:
-	$(PYTHON) -u $(MOZILLA_DIR)/testing/remotecppunittests.py \
-		--xre-path=$(DEPTH)/dist/bin \
-		--localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
-		--deviceIP=${TEST_DEVICE} \
-		$(CPP_UNIT_TESTS) $(EXTRA_TEST_ARGS); \
+	@if [ '${TEST_DEVICE}' != '' -o '$(DM_TRANS)' = 'adb' ]; then \
+		$(PYTHON) -u $(MOZILLA_DIR)/testing/remotecppunittests.py \
+			--xre-path=$(DEPTH)/dist/bin \
+			--localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
+			--dm_trans=$(DM_TRANS) \
+			--deviceIP=${TEST_DEVICE} \
+			$(CPP_UNIT_TESTS) $(EXTRA_TEST_ARGS); \
+	else \
+		echo 'please prepare your host with environment variables for TEST_DEVICE'; \
+	fi
 
 endif # COMPILE_ENVIRONMENT
 endif # CPP_UNIT_TESTS
 endif # ENABLE_TESTS
 
 
 #
 # Library rules
--- a/js/src/jit-test/jit_test.py
+++ b/js/src/jit-test/jit_test.py
@@ -135,16 +135,20 @@ def main(argv):
                   type='string', dest='device_ip',
                   help='IP address of remote device to test')
     op.add_option('--devicePort', action='store',
                   type=int, dest='device_port', default=20701,
                   help='port of remote device to test')
     op.add_option('--deviceSerial', action='store',
                   type='string', dest='device_serial', default=None,
                   help='ADB device serial number of remote device to test')
+    op.add_option('--deviceTransport', action='store',
+                  type='string', dest='device_transport', default='sut',
+                  help='The transport to use to communicate with device:'
+                  ' [adb|sut]; default=sut')
     op.add_option('--remoteTestRoot', dest='remote_test_root', action='store',
                   type='string', default='/data/local/tests',
                   help='The remote directory to use as test root'
                   ' (eg. /data/local/tests)')
     op.add_option('--localLib', dest='local_lib', action='store',
                   type='string',
                   help='The location of libraries to push -- preferably'
                   ' stripped')
--- a/js/src/tests/lib/jittests.py
+++ b/js/src/tests/lib/jittests.py
@@ -660,29 +660,38 @@ def push_libs(options, device):
 def push_progs(options, device, progs):
     for local_file in progs:
         remote_file = posixpath.join(options.remote_test_root,
                                      os.path.basename(local_file))
         device.pushFile(local_file, remote_file)
 
 def run_tests_remote(tests, num_tests, prefix, options):
     # Setup device with everything needed to run our tests.
-    from mozdevice import devicemanagerADB
+    from mozdevice import devicemanagerADB, devicemanagerSUT
 
-    if options.device_ip:
-        dm = devicemanagerADB.DeviceManagerADB(
+    if options.device_transport == 'adb':
+        if options.device_ip:
+            dm = devicemanagerADB.DeviceManagerADB(
+                options.device_ip, options.device_port,
+                deviceSerial=options.device_serial,
+                packageName=None,
+                deviceRoot=options.remote_test_root)
+        else:
+            dm = devicemanagerADB.DeviceManagerADB(
+                deviceSerial=options.device_serial,
+                packageName=None,
+                deviceRoot=options.remote_test_root)
+    else:
+        dm = devicemanagerSUT.DeviceManagerSUT(
             options.device_ip, options.device_port,
-            deviceSerial=options.device_serial,
-            packageName=None,
             deviceRoot=options.remote_test_root)
-    else:
-        dm = devicemanagerADB.DeviceManagerADB(
-            deviceSerial=options.device_serial,
-            packageName=None,
-            deviceRoot=options.remote_test_root)
+        if options.device_ip == None:
+            print('Error: you must provide a device IP to connect to via the'
+                  ' --device option')
+            sys.exit(1)
 
     # Update the test root to point to our test directory.
     jit_tests_dir = posixpath.join(options.remote_test_root, 'jit-tests')
     options.remote_test_root = posixpath.join(jit_tests_dir, 'jit-tests')
 
     # Push js shell and libraries.
     if dm.dirExists(jit_tests_dir):
         dm.removeDir(jit_tests_dir)
--- a/layout/tools/reftest/mach_commands.py
+++ b/layout/tools/reftest/mach_commands.py
@@ -129,16 +129,17 @@ class ReftestRunner(MozbuildObject):
         if not args.symbolsPath:
             args.symbolsPath = os.path.join(self.topobjdir, "crashreporter-symbols")
         if not args.xrePath:
             args.xrePath = os.environ.get("MOZ_HOST_BIN")
         if not args.app:
             args.app = self.substs["ANDROID_PACKAGE_NAME"]
         if not args.utilityPath:
             args.utilityPath = args.xrePath
+        args.dm_trans = "adb"
         args.ignoreWindowSize = True
         args.printDeviceInfo = False
 
         from mozrunner.devices.android_device import grant_runtime_permissions
         grant_runtime_permissions(self)
 
         # A symlink and some path manipulations are required so that test
         # manifests can be found both locally and remotely (via a url)
--- a/layout/tools/reftest/mach_test_package_commands.py
+++ b/layout/tools/reftest/mach_test_package_commands.py
@@ -46,16 +46,17 @@ def run_reftest_desktop(context, args):
 
 def run_reftest_android(context, args):
     from remotereftest import run_test_harness
 
     args.app = args.app or 'org.mozilla.fennec'
     args.utilityPath = context.hostutils
     args.xrePath = context.hostutils
     args.httpdPath = context.module_dir
+    args.dm_trans = 'adb'
     args.ignoreWindowSize = True
     args.printDeviceInfo = False
 
     config = context.mozharness_config
     if config:
         args.remoteWebServer = config['remote_webserver']
         args.httpPort = config['emulator']['http_port']
         args.sslPort = config['emulator']['ssl_port']
--- a/layout/tools/reftest/reftestcommandline.py
+++ b/layout/tools/reftest/reftestcommandline.py
@@ -444,16 +444,24 @@ class RemoteArgumentsParser(ReftestArgum
 
         self.add_argument("--pidfile",
                           action="store",
                           type=str,
                           dest="pidFile",
                           default="",
                           help="name of the pidfile to generate")
 
+        self.add_argument("--dm_trans",
+                          action="store",
+                          type=str,
+                          dest="dm_trans",
+                          default="sut",
+                          help="the transport to use to communicate with device: "
+                               "[adb|sut]; default=sut")
+
         self.add_argument("--remoteTestRoot",
                           action="store",
                           type=str,
                           dest="remoteTestRoot",
                           help="remote directory to use as test root "
                                "(eg. /mnt/sdcard/tests or /data/local/tests)")
 
         self.add_argument("--httpd-path",
--- a/layout/tools/reftest/remotereftest.py
+++ b/layout/tools/reftest/remotereftest.py
@@ -326,28 +326,36 @@ class RemoteReftest(RefTest):
                 os.remove(self.pidFile)
                 os.remove(self.pidFile + ".xpcshell.pid")
             except:
                 print ("Warning: cleaning up pidfile '%s' was unsuccessful "
                        "from the test harness" % self.pidFile)
 
 
 def run_test_harness(parser, options):
+    if options.dm_trans == 'sut' and options.deviceIP is None:
+        print ("Error: If --dm_trans = sut, you must provide a device IP to "
+               "connect to via the --deviceIP option")
+        return 1
+
     dm_args = {
         'deviceRoot': options.remoteTestRoot,
         'host': options.deviceIP,
         'port': options.devicePort,
     }
 
-    dm_args['adbPath'] = options.adb_path
-    if not dm_args['host']:
-        dm_args['deviceSerial'] = options.deviceSerial
+    dm_cls = mozdevice.DroidSUT
+    if options.dm_trans == 'adb':
+        dm_args['adbPath'] = options.adb_path
+        if not dm_args['host']:
+            dm_args['deviceSerial'] = options.deviceSerial
+        dm_cls = mozdevice.DroidADB
 
     try:
-        dm = mozdevice.DroidADB(**dm_args)
+        dm = dm_cls(**dm_args)
     except mozdevice.DMError:
         traceback.print_exc()
         print ("Automation Error: exception while initializing devicemanager.  "
                "Most likely the device is not in a testable state.")
         return 1
 
     automation = RemoteAutomation(None)
     automation.setDeviceManager(dm)
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -409,16 +409,17 @@ class MachCommands(MachCommandBase):
 
         parser = remotecppunittests.RemoteCPPUnittestOptions()
         commandline.add_logging_group(parser)
         options, args = parser.parse_args()
 
         options.symbols_path = symbols_path
         options.manifest_path = manifest_path
         options.xre_path = self.bindir
+        options.dm_trans = "adb"
         options.local_lib = self.bindir.replace('bin', 'fennec')
         for file in os.listdir(os.path.join(self.topobjdir, "dist")):
             if file.endswith(".apk") and file.startswith("fennec"):
                 options.local_apk = os.path.join(self.topobjdir, "dist", file)
                 log.info("using APK: " + options.local_apk)
                 break
 
         try:
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -6,17 +6,17 @@ from abc import ABCMeta, abstractmethod,
 from argparse import ArgumentParser, SUPPRESS
 from distutils.util import strtobool
 from itertools import chain
 from urlparse import urlparse
 import json
 import os
 import tempfile
 
-from mozdevice import DroidADB
+from mozdevice import DroidADB, DroidSUT
 from mozprofile import DEFAULT_PORTS
 import mozinfo
 import mozlog
 import moznetwork
 
 
 here = os.path.abspath(os.path.dirname(__file__))
 
@@ -868,16 +868,22 @@ class AndroidArguments(ArgumentContainer
           "help": "ip address of remote device to test",
           "default": None,
           }],
         [["--deviceSerial"],
          {"dest": "deviceSerial",
           "help": "ip address of remote device to test",
           "default": None,
           }],
+        [["--dm_trans"],
+         {"choices": ["adb", "sut"],
+          "default": "adb",
+          "help": "The transport to use for communication with the device [default: adb].",
+          "suppress": True,
+          }],
         [["--adbpath"],
          {"dest": "adbPath",
           "default": None,
           "help": "Path to adb binary.",
           "suppress": True,
           }],
         [["--devicePort"],
          {"dest": "devicePort",
@@ -946,23 +952,31 @@ class AndroidArguments(ArgumentContainer
 
     def validate(self, parser, options, context):
         """Validate android options."""
 
         if build_obj:
             options.log_mach = '-'
 
         device_args = {'deviceRoot': options.remoteTestRoot}
-        device_args['adbPath'] = options.adbPath
-        if options.deviceIP:
+        if options.dm_trans == "adb":
+            device_args['adbPath'] = options.adbPath
+            if options.deviceIP:
+                device_args['host'] = options.deviceIP
+                device_args['port'] = options.devicePort
+            elif options.deviceSerial:
+                device_args['deviceSerial'] = options.deviceSerial
+            options.dm = DroidADB(**device_args)
+        elif options.dm_trans == 'sut':
+            if options.deviceIP is None:
+                parser.error(
+                    "If --dm_trans = sut, you must provide a device IP")
             device_args['host'] = options.deviceIP
             device_args['port'] = options.devicePort
-        elif options.deviceSerial:
-            device_args['deviceSerial'] = options.deviceSerial
-        options.dm = DroidADB(**device_args)
+            options.dm = DroidSUT(**device_args)
 
         if not options.remoteTestRoot:
             options.remoteTestRoot = options.dm.deviceRoot
 
         if options.remoteWebServer is None:
             if os.name != "nt":
                 options.remoteWebServer = moznetwork.get_ip()
             else:
--- a/testing/mochitest/runrobocop.py
+++ b/testing/mochitest/runrobocop.py
@@ -97,17 +97,17 @@ class RobocopTestRunner(MochitestDesktop
         # Add Android version (SDK level) to mozinfo so that manifest entries
         # can be conditional on android_version.
         androidVersion = self.dm.shellCheckOutput(
             ['getprop', 'ro.build.version.sdk'])
         self.log.info(
             "Android sdk version '%s'; will use this to filter manifests" %
             str(androidVersion))
         mozinfo.info['android_version'] = androidVersion
-        if self.options.robocopApk:
+        if (self.options.dm_trans == 'adb' and self.options.robocopApk):
             self.dm._checkCmd(["install", "-r", self.options.robocopApk])
             self.log.debug("Robocop APK %s installed" %
                            self.options.robocopApk)
         # Display remote diagnostics; if running in mach, keep output terse.
         if self.options.log_mach is None:
             self.printDeviceInfo()
         self.setupLocalPaths()
         self.buildProfile()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/docs/devicemanagement.rst
@@ -0,0 +1,11 @@
+Device management
+-----------------
+
+Mozbase provides a module called `mozdevice` for the purposes of
+running automated tests or scripts on a device (e.g. an Android- or
+FirefoxOS-based phone) connected to a workstation.
+
+.. toctree::
+   :maxdepth: 3
+
+   mozdevice
--- a/testing/mozbase/docs/index.rst
+++ b/testing/mozbase/docs/index.rst
@@ -41,16 +41,17 @@ want to do then dive in!
 .. toctree::
    :maxdepth: 2
 
    manifestparser
    gettinginfo
    setuprunning
    mozhttpd
    loggingreporting
+   devicemanagement
 
 Indices and tables
 ==================
 
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
 
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/docs/mozdevice.rst
@@ -0,0 +1,254 @@
+:mod:`mozdevice` --- Interact with remote devices
+=================================================
+
+Mozdevice provides several interfaces to interact with a remote device
+such as an Android- or FirefoxOS-based phone. It allows you to push
+files to these types of devices, launch processes, and more. There are
+currently two available interfaces:
+
+* :ref:`DeviceManager`: Works either via ADB or a custom TCP protocol
+  (the latter requires an agent application running on the device).
+* :ref:`ADB`: Uses the Android Debugger Protocol explicitly
+
+In general, new code should use the ADB abstraction where possible as
+it is simpler and more reliable.
+
+.. automodule:: mozdevice
+
+.. _DeviceManager:
+
+DeviceManager interface
+-----------------------
+.. autoclass:: DeviceManager
+
+Here's an example script which lists the files in '/mnt/sdcard' and sees if a
+process called 'org.mozilla.fennec' is running. In this example, we're
+instantiating the DeviceManagerADB implementation, but we could just
+as easily have used DeviceManagerSUT (assuming the device had an agent
+running speaking the SUT protocol).
+
+::
+
+  import mozdevice
+
+  dm = mozdevice.DeviceManagerADB()
+  print dm.listFiles("/mnt/sdcard")
+  if dm.processExist("org.mozilla.fennec"):
+      print "Fennec is running"
+
+Informational methods
+`````````````````````
+.. automethod:: DeviceManager.getInfo(self, directive=None)
+.. automethod:: DeviceManager.getCurrentTime(self)
+.. automethod:: DeviceManager.getIP
+.. automethod:: DeviceManager.saveScreenshot
+.. automethod:: DeviceManager.recordLogcat
+.. automethod:: DeviceManager.getLogcat
+
+File management methods
+```````````````````````
+.. autoattribute:: DeviceManager.deviceRoot
+.. automethod:: DeviceManager.getDeviceRoot(self)
+.. automethod:: DeviceManager.pushFile(self, localFilename, remoteFilename, retryLimit=1)
+.. automethod:: DeviceManager.pushDir(self, localDirname, remoteDirname, retryLimit=1)
+.. automethod:: DeviceManager.pullFile(self, remoteFilename)
+.. automethod:: DeviceManager.getFile(self, remoteFilename, localFilename)
+.. automethod:: DeviceManager.getDirectory(self, remoteDirname, localDirname, checkDir=True)
+.. automethod:: DeviceManager.validateFile(self, remoteFilename, localFilename)
+.. automethod:: DeviceManager.mkDir(self, remoteDirname)
+.. automethod:: DeviceManager.mkDirs(self, filename)
+.. automethod:: DeviceManager.dirExists(self, dirpath)
+.. automethod:: DeviceManager.fileExists(self, filepath)
+.. automethod:: DeviceManager.listFiles(self, rootdir)
+.. automethod:: DeviceManager.removeFile(self, filename)
+.. automethod:: DeviceManager.removeDir(self, remoteDirname)
+.. automethod:: DeviceManager.chmodDir(self, remoteDirname, mask="777")
+.. automethod:: DeviceManager.getTempDir(self)
+
+Process management methods
+``````````````````````````
+.. automethod:: DeviceManager.shell(self, cmd, outputfile, env=None, cwd=None, timeout=None, root=False)
+.. automethod:: DeviceManager.shellCheckOutput(self, cmd, env=None, cwd=None, timeout=None, root=False)
+.. automethod:: DeviceManager.getProcessList(self)
+.. automethod:: DeviceManager.processExist(self, processName)
+.. automethod:: DeviceManager.killProcess(self, processName)
+
+System control methods
+``````````````````````
+.. automethod:: DeviceManager.reboot(self, ipAddr=None, port=30000)
+
+Application management methods
+``````````````````````````````
+.. automethod:: DeviceManager.uninstallAppAndReboot(self, appName, installPath=None)
+.. automethod:: DeviceManager.installApp(self, appBundlePath, destPath=None)
+.. automethod:: DeviceManager.uninstallApp(self, appName, installPath=None)
+.. automethod:: DeviceManager.updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000)
+
+DeviceManagerADB implementation
+```````````````````````````````
+
+.. autoclass:: mozdevice.DeviceManagerADB
+
+DeviceManagerADB has several methods that are not present in all
+DeviceManager implementations. Please do not use them in code that
+is meant to be interoperable.
+
+.. automethod:: DeviceManagerADB.forward
+.. automethod:: DeviceManagerADB.remount
+.. automethod:: DeviceManagerADB.devices
+
+DeviceManagerSUT implementation
+```````````````````````````````
+
+.. autoclass:: mozdevice.DeviceManagerSUT
+
+DeviceManagerSUT has several methods that are only used in specific
+tests and are not present in all DeviceManager implementations. Please
+do not use them in code that is meant to be interoperable.
+
+.. automethod:: DeviceManagerSUT.unpackFile
+.. automethod:: DeviceManagerSUT.adjustResolution
+
+Android extensions
+``````````````````
+
+For Android, we provide two variants of the `DeviceManager` interface
+with extensions useful for that platform. These classes are called
+DroidADB and DroidSUT. They inherit all methods from DeviceManagerADB
+and DeviceManagerSUT. Here is the interface for DroidADB:
+
+.. automethod:: mozdevice.DroidADB.launchApplication
+.. automethod:: mozdevice.DroidADB.launchFennec
+.. automethod:: mozdevice.DroidADB.getInstalledApps
+.. automethod:: mozdevice.DroidADB.getAppRoot
+
+These methods are also found in the DroidSUT class.
+
+.. _ADB:
+
+ADB Interface
+-------------
+
+The following classes provide a basic interface to interact with the
+Android Debug Tool (adb) and Android-based devices.  It is intended to
+provide the basis for a replacement for DeviceManager and
+DeviceManagerADB.
+
+ADBCommand
+``````````
+
+.. autoclass:: mozdevice.ADBCommand
+
+.. automethod:: ADBCommand.command(self, cmds, timeout=None)
+.. automethod:: ADBCommand.command_output(self, cmds, timeout=None)
+
+ADBHost
+```````
+.. autoclass:: mozdevice.ADBHost
+
+.. automethod:: ADBHost.command(self, cmds, timeout=None)
+.. automethod:: ADBHost.command_output(self, cmds, timeout=None)
+.. automethod:: ADBHost.start_server(self, timeout=None)
+.. automethod:: ADBHost.kill_server(self, timeout=None)
+.. automethod:: ADBHost.devices(self, timeout=None)
+
+ADBDevice
+`````````
+.. autoclass:: mozdevice.ADBDevice
+
+Host Command methods
+++++++++++++++++++++
+.. automethod:: ADBDevice.command(self, cmds, timeout=None)
+.. automethod:: ADBDevice.command_output(self, cmds, timeout=None)
+
+Device Shell methods
+++++++++++++++++++++
+.. automethod:: ADBDevice.shell(self, cmd, env=None, cwd=None, timeout=None, root=False)
+.. automethod:: ADBDevice.shell_bool(self, cmd, env=None, cwd=None, timeout=None, root=False)
+.. automethod:: ADBDevice.shell_output(self, cmd, env=None, cwd=None, timeout=None, root=False)
+
+Informational methods
++++++++++++++++++++++
+.. automethod:: ADBDevice.clear_logcat
+.. automethod:: ADBDevice.get_battery_percentage
+.. automethod:: ADBDevice.get_info
+.. automethod:: ADBDevice.get_logcat
+.. automethod:: ADBDevice.get_prop
+.. automethod:: ADBDevice.get_state
+
+System control methods
+++++++++++++++++++++++
+.. automethod:: ADBDevice.is_device_ready
+.. automethod:: ADBDevice.reboot
+
+File management methods
++++++++++++++++++++++++
+.. automethod:: ADBDevice.chmod
+.. automethod:: ADBDevice.cp
+.. automethod:: ADBDevice.exists
+.. automethod:: ADBDevice.is_dir
+.. automethod:: ADBDevice.is_file
+.. automethod:: ADBDevice.list_files
+.. automethod:: ADBDevice.mkdir
+.. automethod:: ADBDevice.mv
+.. automethod:: ADBDevice.push
+.. automethod:: ADBDevice.rm
+.. automethod:: ADBDevice.rmdir
+.. autoattribute:: ADBDevice.test_root
+
+Process management methods
+++++++++++++++++++++++++++
+.. automethod:: ADBDevice.get_process_list
+.. automethod:: ADBDevice.kill
+.. automethod:: ADBDevice.pkill
+.. automethod:: ADBDevice.process_exist
+
+ADBAndroid
+``````````
+.. autoclass:: ADBAndroid
+
+Informational methods
++++++++++++++++++++++
+.. automethod:: ADBAndroid.get_battery_percentage
+
+System control methods
+++++++++++++++++++++++
+.. automethod:: ADBAndroid.is_device_ready
+.. automethod:: ADBAndroid.power_on
+
+Application management methods
+++++++++++++++++++++++++++++++
+.. automethod:: ADBAndroid.install_app
+.. automethod:: ADBAndroid.is_app_installed
+.. automethod:: ADBAndroid.launch_application
+.. automethod:: ADBAndroid.launch_fennec
+.. automethod:: ADBAndroid.stop_application
+.. automethod:: ADBAndroid.uninstall_app
+.. automethod:: ADBAndroid.update_app
+
+ADBB2G
+``````
+.. autoclass:: ADBB2G
+
+Informational methods
++++++++++++++++++++++
+.. automethod:: ADBB2G.get_battery_percentage
+.. automethod:: ADBB2G.get_info
+.. automethod:: ADBB2G.get_memory_total
+
+ADBProcess
+``````````
+.. autoclass:: mozdevice.ADBProcess
+
+ADBError
+````````
+.. autoexception:: mozdevice.ADBError
+
+ADBRootError
+````````````
+.. autoexception:: mozdevice.ADBRootError
+
+ADBTimeoutError
+```````````````
+.. autoexception:: mozdevice.ADBTimeoutError
+
--- a/testing/mozbase/docs/mozversion.rst
+++ b/testing/mozbase/docs/mozversion.rst
@@ -2,17 +2,17 @@
 =================================================
 
 `mozversion <https://github.com/mozilla/mozbase/tree/master/mozversion>`_
 provides version information such as the application name and the changesets
 that it has been built from. This is commonly used in reporting or for
 conditional logic based on the application under test.
 
 Note that mozversion can report the version of remote devices (e.g. Firefox OS)
-but it requires the mozdevice dependency in that case. You can require it
+but it requires the :mod:`mozdevice` dependency in that case. You can require it
 along with mozversion by using the extra *device* dependency:
 
 .. code-block:: bash
 
   pip install mozversion[device]
 
 
 API Usage
--- a/testing/mozbase/moz.build
+++ b/testing/mozbase/moz.build
@@ -2,16 +2,17 @@
 # vim: set filetype=python:
 # 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/.
 
 PYTHON_UNITTEST_MANIFESTS += [
     'manifestparser/tests/manifest.ini',
     'mozcrash/tests/manifest.ini',
+    'mozdevice/tests/manifest.ini',
     'mozfile/tests/manifest.ini',
     'mozhttpd/tests/manifest.ini',
     'mozinfo/tests/manifest.ini',
     'mozinstall/tests/manifest.ini',
     'mozlog/tests/manifest.ini',
     'moznetwork/tests/manifest.ini',
     'mozprocess/tests/manifest.ini',
     'mozprofile/tests/manifest.ini',
new file mode 100755
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/Zeroconf.py
@@ -0,0 +1,1560 @@
+""" Multicast DNS Service Discovery for Python, v0.12
+    Copyright (C) 2003, Paul Scott-Murphy
+
+    This module provides a framework for the use of DNS Service Discovery
+    using IP multicast.  It has been tested against the JRendezvous
+    implementation from <a href="http://strangeberry.com">StrangeBerry</a>,
+    and against the mDNSResponder from Mac OS X 10.3.8.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+    
+"""
+
+"""0.12 update - allow selection of binding interface
+         typo fix - Thanks A. M. Kuchlingi
+         removed all use of word 'Rendezvous' - this is an API change"""
+
+"""0.11 update - correction to comments for addListener method
+                 support for new record types seen from OS X
+                  - IPv6 address
+                  - hostinfo
+                 ignore unknown DNS record types
+                 fixes to name decoding
+                 works alongside other processes using port 5353 (e.g. on Mac OS X)
+                 tested against Mac OS X 10.3.2's mDNSResponder
+                 corrections to removal of list entries for service browser"""
+
+"""0.10 update - Jonathon Paisley contributed these corrections:
+                 always multicast replies, even when query is unicast
+                 correct a pointer encoding problem
+                 can now write records in any order
+                 traceback shown on failure
+                 better TXT record parsing
+                 server is now separate from name
+                 can cancel a service browser
+
+                 modified some unit tests to accommodate these changes"""
+
+"""0.09 update - remove all records on service unregistration
+                 fix DOS security problem with readName"""
+
+"""0.08 update - changed licensing to LGPL"""
+
+"""0.07 update - faster shutdown on engine
+                 pointer encoding of outgoing names
+                 ServiceBrowser now works
+                 new unit tests"""
+
+"""0.06 update - small improvements with unit tests
+                 added defined exception types
+                 new style objects
+                 fixed hostname/interface problem
+                 fixed socket timeout problem
+                 fixed addServiceListener() typo bug
+                 using select() for socket reads
+                 tested on Debian unstable with Python 2.2.2"""
+
+"""0.05 update - ensure case insensitivty on domain names
+                 support for unicast DNS queries"""
+
+"""0.04 update - added some unit tests
+                 added __ne__ adjuncts where required
+                 ensure names end in '.local.'
+                 timeout on receiving socket for clean shutdown"""
+
+__author__ = "Paul Scott-Murphy"
+__email__ = "paul at scott dash murphy dot com"
+__version__ = "0.12"
+
+import string
+import time
+import struct
+import socket
+import threading
+import select
+import traceback
+
+__all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]
+
+# hook for threads
+
+globals()['_GLOBAL_DONE'] = 0
+
+# Some timing constants
+
+_UNREGISTER_TIME = 125
+_CHECK_TIME = 175
+_REGISTER_TIME = 225
+_LISTENER_TIME = 200
+_BROWSER_TIME = 500
+
+# Some DNS constants
+    
+_MDNS_ADDR = '224.0.0.251'
+_MDNS_PORT = 5353;
+_DNS_PORT = 53;
+_DNS_TTL = 60 * 60; # one hour default TTL
+
+_MAX_MSG_TYPICAL = 1460 # unused
+_MAX_MSG_ABSOLUTE = 8972
+
+_FLAGS_QR_MASK = 0x8000 # query response mask
+_FLAGS_QR_QUERY = 0x0000 # query
+_FLAGS_QR_RESPONSE = 0x8000 # response
+
+_FLAGS_AA = 0x0400 # Authorative answer
+_FLAGS_TC = 0x0200 # Truncated
+_FLAGS_RD = 0x0100 # Recursion desired
+_FLAGS_RA = 0x8000 # Recursion available
+
+_FLAGS_Z = 0x0040 # Zero
+_FLAGS_AD = 0x0020 # Authentic data
+_FLAGS_CD = 0x0010 # Checking disabled
+
+_CLASS_IN = 1
+_CLASS_CS = 2
+_CLASS_CH = 3
+_CLASS_HS = 4
+_CLASS_NONE = 254
+_CLASS_ANY = 255
+_CLASS_MASK = 0x7FFF
+_CLASS_UNIQUE = 0x8000
+
+_TYPE_A = 1
+_TYPE_NS = 2
+_TYPE_MD = 3
+_TYPE_MF = 4
+_TYPE_CNAME = 5
+_TYPE_SOA = 6
+_TYPE_MB = 7
+_TYPE_MG = 8
+_TYPE_MR = 9
+_TYPE_NULL = 10
+_TYPE_WKS = 11
+_TYPE_PTR = 12
+_TYPE_HINFO = 13
+_TYPE_MINFO = 14
+_TYPE_MX = 15
+_TYPE_TXT = 16
+_TYPE_AAAA = 28
+_TYPE_SRV = 33
+_TYPE_ANY =  255
+
+# Mapping constants to names
+
+_CLASSES = { _CLASS_IN : "in",
+             _CLASS_CS : "cs",
+             _CLASS_CH : "ch",
+             _CLASS_HS : "hs",
+             _CLASS_NONE : "none",
+             _CLASS_ANY : "any" }
+
+_TYPES = { _TYPE_A : "a",
+           _TYPE_NS : "ns",
+           _TYPE_MD : "md",
+           _TYPE_MF : "mf",
+           _TYPE_CNAME : "cname",
+           _TYPE_SOA : "soa",
+           _TYPE_MB : "mb",
+           _TYPE_MG : "mg",
+           _TYPE_MR : "mr",
+           _TYPE_NULL : "null",
+           _TYPE_WKS : "wks",
+           _TYPE_PTR : "ptr",
+           _TYPE_HINFO : "hinfo",
+           _TYPE_MINFO : "minfo",
+           _TYPE_MX : "mx",
+           _TYPE_TXT : "txt",
+           _TYPE_AAAA : "quada",
+           _TYPE_SRV : "srv",
+           _TYPE_ANY : "any" }
+
+# utility functions
+
+def currentTimeMillis():
+    """Current system time in milliseconds"""
+    return time.time() * 1000
+
+# Exceptions
+
+class NonLocalNameException(Exception):
+    pass
+
+class NonUniqueNameException(Exception):
+    pass
+
+class NamePartTooLongException(Exception):
+    pass
+
+class AbstractMethodException(Exception):
+    pass
+
+class BadTypeInNameException(Exception):
+    pass
+
+# implementation classes
+
+class DNSEntry(object):
+    """A DNS entry"""
+    
+    def __init__(self, name, type, clazz):
+        self.key = string.lower(name)
+        self.name = name
+        self.type = type
+        self.clazz = clazz & _CLASS_MASK
+        self.unique = (clazz & _CLASS_UNIQUE) != 0
+
+    def __eq__(self, other):
+        """Equality test on name, type, and class"""
+        if isinstance(other, DNSEntry):
+            return self.name == other.name and self.type == other.type and self.clazz == other.clazz
+        return 0
+
+    def __ne__(self, other):
+        """Non-equality test"""
+        return not self.__eq__(other)
+
+    def getClazz(self, clazz):
+        """Class accessor"""
+        try:
+            return _CLASSES[clazz]
+        except:
+            return "?(%s)" % (clazz)
+
+    def getType(self, type):
+        """Type accessor"""
+        try:
+            return _TYPES[type]
+        except:
+            return "?(%s)" % (type)
+
+    def toString(self, hdr, other):
+        """String representation with additional information"""
+        result = "%s[%s,%s" % (hdr, self.getType(self.type), self.getClazz(self.clazz))
+        if self.unique:
+            result += "-unique,"
+        else:
+            result += ","
+        result += self.name
+        if other is not None:
+            result += ",%s]" % (other)
+        else:
+            result += "]"
+        return result
+
+class DNSQuestion(DNSEntry):
+    """A DNS question entry"""
+    
+    def __init__(self, name, type, clazz):
+        if not name.endswith(".local."):
+            raise NonLocalNameException
+        DNSEntry.__init__(self, name, type, clazz)
+
+    def answeredBy(self, rec):
+        """Returns true if the question is answered by the record"""
+        return self.clazz == rec.clazz and (self.type == rec.type or self.type == _TYPE_ANY) and self.name == rec.name
+
+    def __repr__(self):
+        """String representation"""
+        return DNSEntry.toString(self, "question", None)
+
+
+class DNSRecord(DNSEntry):
+    """A DNS record - like a DNS entry, but has a TTL"""
+    
+    def __init__(self, name, type, clazz, ttl):
+        DNSEntry.__init__(self, name, type, clazz)
+        self.ttl = ttl
+        self.created = currentTimeMillis()
+
+    def __eq__(self, other):
+        """Tests equality as per DNSRecord"""
+        if isinstance(other, DNSRecord):
+            return DNSEntry.__eq__(self, other)
+        return 0
+
+    def suppressedBy(self, msg):
+        """Returns true if any answer in a message can suffice for the
+        information held in this record."""
+        for record in msg.answers:
+            if self.suppressedByAnswer(record):
+                return 1
+        return 0
+
+    def suppressedByAnswer(self, other):
+        """Returns true if another record has same name, type and class,
+        and if its TTL is at least half of this record's."""
+        if self == other and other.ttl > (self.ttl / 2):
+            return 1
+        return 0
+
+    def getExpirationTime(self, percent):
+        """Returns the time at which this record will have expired
+        by a certain percentage."""
+        return self.created + (percent * self.ttl * 10)
+
+    def getRemainingTTL(self, now):
+        """Returns the remaining TTL in seconds."""
+        return max(0, (self.getExpirationTime(100) - now) / 1000)
+
+    def isExpired(self, now):
+        """Returns true if this record has expired."""
+        return self.getExpirationTime(100) <= now
+
+    def isStale(self, now):
+        """Returns true if this record is at least half way expired."""
+        return self.getExpirationTime(50) <= now
+
+    def resetTTL(self, other):
+        """Sets this record's TTL and created time to that of
+        another record."""
+        self.created = other.created
+        self.ttl = other.ttl
+
+    def write(self, out):
+        """Abstract method"""
+        raise AbstractMethodException
+
+    def toString(self, other):
+        """String representation with addtional information"""
+        arg = "%s/%s,%s" % (self.ttl, self.getRemainingTTL(currentTimeMillis()), other)
+        return DNSEntry.toString(self, "record", arg)
+
+class DNSAddress(DNSRecord):
+    """A DNS address record"""
+    
+    def __init__(self, name, type, clazz, ttl, address):
+        DNSRecord.__init__(self, name, type, clazz, ttl)
+        self.address = address
+
+    def write(self, out):
+        """Used in constructing an outgoing packet"""
+        out.writeString(self.address, len(self.address))
+
+    def __eq__(self, other):
+        """Tests equality on address"""
+        if isinstance(other, DNSAddress):
+            return self.address == other.address
+        return 0
+
+    def __repr__(self):
+        """String representation"""
+        try:
+            return socket.inet_ntoa(self.address)
+        except:
+            return self.address
+
+class DNSHinfo(DNSRecord):
+    """A DNS host information record"""
+
+    def __init__(self, name, type, clazz, ttl, cpu, os):
+        DNSRecord.__init__(self, name, type, clazz, ttl)
+        self.cpu = cpu
+        self.os = os
+
+    def write(self, out):
+        """Used in constructing an outgoing packet"""
+        out.writeString(self.cpu, len(self.cpu))
+        out.writeString(self.os, len(self.os))
+
+    def __eq__(self, other):
+        """Tests equality on cpu and os"""
+        if isinstance(other, DNSHinfo):
+            return self.cpu == other.cpu and self.os == other.os
+        return 0
+
+    def __repr__(self):
+        """String representation"""
+        return self.cpu + " " + self.os
+    
+class DNSPointer(DNSRecord):
+    """A DNS pointer record"""
+    
+    def __init__(self, name, type, clazz, ttl, alias):
+        DNSRecord.__init__(self, name, type, clazz, ttl)
+        self.alias = alias
+
+    def write(self, out):
+        """Used in constructing an outgoing packet"""
+        out.writeName(self.alias)
+
+    def __eq__(self, other):
+        """Tests equality on alias"""
+        if isinstance(other, DNSPointer):
+            return self.alias == other.alias
+        return 0
+
+    def __repr__(self):
+        """String representation"""
+        return self.toString(self.alias)
+
+class DNSText(DNSRecord):
+    """A DNS text record"""
+    
+    def __init__(self, name, type, clazz, ttl, text):
+        DNSRecord.__init__(self, name, type, clazz, ttl)
+        self.text = text
+
+    def write(self, out):
+        """Used in constructing an outgoing packet"""
+        out.writeString(self.text, len(self.text))
+
+    def __eq__(self, other):
+        """Tests equality on text"""
+        if isinstance(other, DNSText):
+            return self.text == other.text
+        return 0
+
+    def __repr__(self):
+        """String representation"""
+        if len(self.text) > 10:
+            return self.toString(self.text[:7] + "...")
+        else:
+            return self.toString(self.text)
+
+class DNSService(DNSRecord):
+    """A DNS service record"""
+    
+    def __init__(self, name, type, clazz, ttl, priority, weight, port, server):
+        DNSRecord.__init__(self, name, type, clazz, ttl)
+        self.priority = priority
+        self.weight = weight
+        self.port = port
+        self.server = server
+
+    def write(self, out):
+        """Used in constructing an outgoing packet"""
+        out.writeShort(self.priority)
+        out.writeShort(self.weight)
+        out.writeShort(self.port)
+        out.writeName(self.server)
+
+    def __eq__(self, other):
+        """Tests equality on priority, weight, port and server"""
+        if isinstance(other, DNSService):
+            return self.priority == other.priority and self.weight == other.weight and self.port == other.port and self.server == other.server
+        return 0
+
+    def __repr__(self):
+        """String representation"""
+        return self.toString("%s:%s" % (self.server, self.port))
+
+class DNSIncoming(object):
+    """Object representation of an incoming DNS packet"""
+    
+    def __init__(self, data):
+        """Constructor from string holding bytes of packet"""
+        self.offset = 0
+        self.data = data
+        self.questions = []
+        self.answers = []
+        self.numQuestions = 0
+        self.numAnswers = 0
+        self.numAuthorities = 0
+        self.numAdditionals = 0
+        
+        self.readHeader()
+        self.readQuestions()
+        self.readOthers()
+
+    def readHeader(self):
+        """Reads header portion of packet"""
+        format = '!HHHHHH'
+        length = struct.calcsize(format)
+        info = struct.unpack(format, self.data[self.offset:self.offset+length])
+        self.offset += length
+
+        self.id = info[0]
+        self.flags = info[1]
+        self.numQuestions = info[2]
+        self.numAnswers = info[3]
+        self.numAuthorities = info[4]
+        self.numAdditionals = info[5]
+
+    def readQuestions(self):
+        """Reads questions section of packet"""
+        format = '!HH'
+        length = struct.calcsize(format)
+        for i in range(0, self.numQuestions):
+            name = self.readName()
+            info = struct.unpack(format, self.data[self.offset:self.offset+length])
+            self.offset += length
+            
+            question = DNSQuestion(name, info[0], info[1])
+            self.questions.append(question)
+
+    def readInt(self):
+        """Reads an integer from the packet"""
+        format = '!I'
+        length = struct.calcsize(format)
+        info = struct.unpack(format, self.data[self.offset:self.offset+length])
+        self.offset += length
+        return info[0]
+
+    def readCharacterString(self):
+        """Reads a character string from the packet"""
+        length = ord(self.data[self.offset])
+        self.offset += 1
+        return self.readString(length)
+
+    def readString(self, len):
+        """Reads a string of a given length from the packet"""
+        format = '!' + str(len) + 's'
+        length =  struct.calcsize(format)
+        info = struct.unpack(format, self.data[self.offset:self.offset+length])
+        self.offset += length
+        return info[0]
+
+    def readUnsignedShort(self):
+        """Reads an unsigned short from the packet"""
+        format = '!H'
+        length = struct.calcsize(format)
+        info = struct.unpack(format, self.data[self.offset:self.offset+length])
+        self.offset += length
+        return info[0]
+
+    def readOthers(self):
+        """Reads the answers, authorities and additionals section of the packet"""
+        format = '!HHiH'
+        length = struct.calcsize(format)
+        n = self.numAnswers + self.numAuthorities + self.numAdditionals
+        for i in range(0, n):
+            domain = self.readName()
+            info = struct.unpack(format, self.data[self.offset:self.offset+length])
+            self.offset += length
+
+            rec = None
+            if info[0] == _TYPE_A:
+                rec = DNSAddress(domain, info[0], info[1], info[2], self.readString(4))
+            elif info[0] == _TYPE_CNAME or info[0] == _TYPE_PTR:
+                rec = DNSPointer(domain, info[0], info[1], info[2], self.readName())
+            elif info[0] == _TYPE_TXT:
+                rec = DNSText(domain, info[0], info[1], info[2], self.readString(info[3]))
+            elif info[0] == _TYPE_SRV:
+                rec = DNSService(domain, info[0], info[1], info[2], self.readUnsignedShort(), self.readUnsignedShort(), self.readUnsignedShort(), self.readName())
+            elif info[0] == _TYPE_HINFO:
+                rec = DNSHinfo(domain, info[0], info[1], info[2], self.readCharacterString(), self.readCharacterString())
+            elif info[0] == _TYPE_AAAA:
+                rec = DNSAddress(domain, info[0], info[1], info[2], self.readString(16))
+            else:
+                # Try to ignore types we don't know about
+                # this may mean the rest of the name is
+                # unable to be parsed, and may show errors
+                # so this is left for debugging.  New types
+                # encountered need to be parsed properly.
+                #
+                #print "UNKNOWN TYPE = " + str(info[0])
+                #raise BadTypeInNameException
+                pass
+
+            if rec is not None:
+                self.answers.append(rec)
+                
+    def isQuery(self):
+        """Returns true if this is a query"""
+        return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_QUERY
+
+    def isResponse(self):
+        """Returns true if this is a response"""
+        return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_RESPONSE
+
+    def readUTF(self, offset, len):
+        """Reads a UTF-8 string of a given length from the packet"""
+        result = self.data[offset:offset+len].decode('utf-8')
+        return result
+        
+    def readName(self):
+        """Reads a domain name from the packet"""
+        result = ''
+        off = self.offset
+        next = -1
+        first = off
+
+        while 1:
+            len = ord(self.data[off])
+            off += 1
+            if len == 0:
+                break
+            t = len & 0xC0
+            if t == 0x00:
+                result = ''.join((result, self.readUTF(off, len) + '.'))
+                off += len
+            elif t == 0xC0:
+                if next < 0:
+                    next = off + 1
+                off = ((len & 0x3F) << 8) | ord(self.data[off])
+                if off >= first:
+                    raise "Bad domain name (circular) at " + str(off)
+                first = off
+            else:
+                raise "Bad domain name at " + str(off)
+
+        if next >= 0:
+            self.offset = next
+        else:
+            self.offset = off
+
+        return result
+    
+        
+class DNSOutgoing(object):
+    """Object representation of an outgoing packet"""
+    
+    def __init__(self, flags, multicast = 1):
+        self.finished = 0
+        self.id = 0
+        self.multicast = multicast
+        self.flags = flags
+        self.names = {}
+        self.data = []
+        self.size = 12
+        
+        self.questions = []
+        self.answers = []
+        self.authorities = []
+        self.additionals = []
+
+    def addQuestion(self, record):
+        """Adds a question"""
+        self.questions.append(record)
+
+    def addAnswer(self, inp, record):
+        """Adds an answer"""
+        if not record.suppressedBy(inp):
+            self.addAnswerAtTime(record, 0)
+
+    def addAnswerAtTime(self, record, now):
+        """Adds an answer if if does not expire by a certain time"""
+        if record is not None:
+            if now == 0 or not record.isExpired(now):
+                self.answers.append((record, now))
+
+    def addAuthorativeAnswer(self, record):
+        """Adds an authoritative answer"""
+        self.authorities.append(record)
+
+    def addAdditionalAnswer(self, record):
+        """Adds an additional answer"""
+        self.additionals.append(record)
+
+    def writeByte(self, value):
+        """Writes a single byte to the packet"""
+        format = '!c'
+        self.data.append(struct.pack(format, chr(value)))
+        self.size += 1
+
+    def insertShort(self, index, value):
+        """Inserts an unsigned short in a certain position in the packet"""
+        format = '!H'
+        self.data.insert(index, struct.pack(format, value))
+        self.size += 2
+        
+    def writeShort(self, value):
+        """Writes an unsigned short to the packet"""
+        format = '!H'
+        self.data.append(struct.pack(format, value))
+        self.size += 2
+
+    def writeInt(self, value):
+        """Writes an unsigned integer to the packet"""
+        format = '!I'
+        self.data.append(struct.pack(format, value))
+        self.size += 4
+
+    def writeString(self, value, length):
+        """Writes a string to the packet"""
+        format = '!' + str(length) + 's'
+        self.data.append(struct.pack(format, value))
+        self.size += length
+
+    def writeUTF(self, s):
+        """Writes a UTF-8 string of a given length to the packet"""
+        utfstr = s.encode('utf-8')
+        length = len(utfstr)
+        if length > 64:
+            raise NamePartTooLongException
+        self.writeByte(length)
+        self.writeString(utfstr, length)
+
+    def writeName(self, name):
+        """Writes a domain name to the packet"""
+
+        try:
+            # Find existing instance of this name in packet
+            #
+            index = self.names[name]
+        except KeyError:
+            # No record of this name already, so write it
+            # out as normal, recording the location of the name
+            # for future pointers to it.
+            #
+            self.names[name] = self.size
+            parts = name.split('.')
+            if parts[-1] == '':
+                parts = parts[:-1]
+            for part in parts:
+                self.writeUTF(part)
+            self.writeByte(0)
+            return
+
+        # An index was found, so write a pointer to it
+        #
+        self.writeByte((index >> 8) | 0xC0)
+        self.writeByte(index)
+
+    def writeQuestion(self, question):
+        """Writes a question to the packet"""
+        self.writeName(question.name)
+        self.writeShort(question.type)
+        self.writeShort(question.clazz)
+
+    def writeRecord(self, record, now):
+        """Writes a record (answer, authoritative answer, additional) to
+        the packet"""
+        self.writeName(record.name)
+        self.writeShort(record.type)
+        if record.unique and self.multicast:
+            self.writeShort(record.clazz | _CLASS_UNIQUE)
+        else:
+            self.writeShort(record.clazz)
+        if now == 0:
+            self.writeInt(record.ttl)
+        else:
+            self.writeInt(record.getRemainingTTL(now))
+        index = len(self.data)
+        # Adjust size for the short we will write before this record
+        #
+        self.size += 2
+        record.write(self)
+        self.size -= 2
+        
+        length = len(''.join(self.data[index:]))
+        self.insertShort(index, length) # Here is the short we adjusted for
+
+    def packet(self):
+        """Returns a string containing the packet's bytes
+
+        No further parts should be added to the packet once this
+        is done."""
+        if not self.finished:
+            self.finished = 1
+            for question in self.questions:
+                self.writeQuestion(question)
+            for answer, time in self.answers:
+                self.writeRecord(answer, time)
+            for authority in self.authorities:
+                self.writeRecord(authority, 0)
+            for additional in self.additionals:
+                self.writeRecord(additional, 0)
+        
+            self.insertShort(0, len(self.additionals))
+            self.insertShort(0, len(self.authorities))
+            self.insertShort(0, len(self.answers))
+            self.insertShort(0, len(self.questions))
+            self.insertShort(0, self.flags)
+            if self.multicast:
+                self.insertShort(0, 0)
+            else:
+                self.insertShort(0, self.id)
+        return ''.join(self.data)
+
+
+class DNSCache(object):
+    """A cache of DNS entries"""
+    
+    def __init__(self):
+        self.cache = {}
+
+    def add(self, entry):
+        """Adds an entry"""
+        try:
+            list = self.cache[entry.key]
+        except:
+            list = self.cache[entry.key] = []
+        list.append(entry)
+
+    def remove(self, entry):
+        """Removes an entry"""
+        try:
+            list = self.cache[entry.key]
+            list.remove(entry)
+        except:
+            pass
+
+    def get(self, entry):
+        """Gets an entry by key.  Will return None if there is no
+        matching entry."""
+        try:
+            list = self.cache[entry.key]
+            return list[list.index(entry)]
+        except:
+            return None
+
+    def getByDetails(self, name, type, clazz):
+        """Gets an entry by details.  Will return None if there is
+        no matching entry."""
+        entry = DNSEntry(name, type, clazz)
+        return self.get(entry)
+
+    def entriesWithName(self, name):
+        """Returns a list of entries whose key matches the name."""
+        try:
+            return self.cache[name]
+        except:
+            return []
+
+    def entries(self):
+        """Returns a list of all entries"""
+        def add(x, y): return x+y
+        try:
+            return reduce(add, self.cache.values())
+        except:
+            return []
+
+
+class Engine(threading.Thread):
+    """An engine wraps read access to sockets, allowing objects that
+    need to receive data from sockets to be called back when the
+    sockets are ready.
+
+    A reader needs a handle_read() method, which is called when the socket
+    it is interested in is ready for reading.
+
+    Writers are not implemented here, because we only send short
+    packets.
+    """
+
+    def __init__(self, zeroconf):
+        threading.Thread.__init__(self)
+        self.zeroconf = zeroconf
+        self.readers = {} # maps socket to reader
+        self.timeout = 5
+        self.condition = threading.Condition()
+        self.daemon = True
+        self.start()
+
+    def run(self):
+        while not globals()['_GLOBAL_DONE']:
+            rs = self.getReaders()
+            if len(rs) == 0:
+                # No sockets to manage, but we wait for the timeout
+                # or addition of a socket
+                #
+                self.condition.acquire()
+                self.condition.wait(self.timeout)
+                self.condition.release()
+            else:
+                try:
+                    rr, wr, er = select.select(rs, [], [], self.timeout)
+                    for socket in rr:
+                        try:
+                            self.readers[socket].handle_read()
+                        except:
+                            # Ignore errors that occur on shutdown
+                            pass
+                except:
+                    pass
+
+    def getReaders(self):
+        result = []
+        self.condition.acquire()
+        result = self.readers.keys()
+        self.condition.release()
+        return result
+    
+    def addReader(self, reader, socket):
+        self.condition.acquire()
+        self.readers[socket] = reader
+        self.condition.notify()
+        self.condition.release()
+
+    def delReader(self, socket):
+        self.condition.acquire()
+        del(self.readers[socket])
+        self.condition.notify()
+        self.condition.release()
+
+    def notify(self):
+        self.condition.acquire()
+        self.condition.notify()
+        self.condition.release()
+
+class Listener(object):
+    """A Listener is used by this module to listen on the multicast
+    group to which DNS messages are sent, allowing the implementation
+    to cache information as it arrives.
+
+    It requires registration with an Engine object in order to have
+    the read() method called when a socket is availble for reading."""
+    
+    def __init__(self, zeroconf):
+        self.zeroconf = zeroconf
+        self.zeroconf.engine.addReader(self, self.zeroconf.socket)
+
+    def handle_read(self):
+        data, (addr, port) = self.zeroconf.socket.recvfrom(_MAX_MSG_ABSOLUTE)
+        self.data = data
+        msg = DNSIncoming(data)
+        if msg.isQuery():
+            # Always multicast responses
+            #
+            if port == _MDNS_PORT:
+                self.zeroconf.handleQuery(msg, _MDNS_ADDR, _MDNS_PORT)
+            # If it's not a multicast query, reply via unicast
+            # and multicast
+            #
+            elif port == _DNS_PORT:
+                self.zeroconf.handleQuery(msg, addr, port)
+                self.zeroconf.handleQuery(msg, _MDNS_ADDR, _MDNS_PORT)
+        else:
+            self.zeroconf.handleResponse(msg)
+
+
+class Reaper(threading.Thread):
+    """A Reaper is used by this module to remove cache entries that
+    have expired."""
+    
+    def __init__(self, zeroconf):
+        threading.Thread.__init__(self)
+        self.daemon = True
+        self.zeroconf = zeroconf
+        self.start()
+
+    def run(self):
+        while 1:
+            self.zeroconf.wait(10 * 1000)
+            if globals()['_GLOBAL_DONE']:
+                return
+            now = currentTimeMillis()
+            for record in self.zeroconf.cache.entries():
+                if record.isExpired(now):
+                    self.zeroconf.updateRecord(now, record)
+                    self.zeroconf.cache.remove(record)
+
+
+class ServiceBrowser(threading.Thread):
+    """Used to browse for a service of a specific type.
+
+    The listener object will have its addService() and
+    removeService() methods called when this browser
+    discovers changes in the services availability."""
+    
+    def __init__(self, zeroconf, type, listener):
+        """Creates a browser for a specific type"""
+        threading.Thread.__init__(self)
+        self.zeroconf = zeroconf
+        self.type = type
+        self.listener = listener
+        self.services = {}
+        self.nextTime = currentTimeMillis()
+        self.delay = _BROWSER_TIME
+        self.list = []
+        self.daemon = True
+
+        self.done = 0
+
+        self.zeroconf.addListener(self, DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN))
+        self.start()
+
+    def updateRecord(self, zeroconf, now, record):
+        """Callback invoked by Zeroconf when new information arrives.
+
+        Updates information required by browser in the Zeroconf cache."""
+        if record.type == _TYPE_PTR and record.name == self.type:
+            expired = record.isExpired(now)
+            try:
+                oldrecord = self.services[record.alias.lower()]
+                if not expired:
+                    oldrecord.resetTTL(record)
+                else:
+                    del(self.services[record.alias.lower()])
+                    callback = lambda x: self.listener.removeService(x, self.type, record.alias)
+                    self.list.append(callback)
+                    return
+            except:
+                if not expired:
+                    self.services[record.alias.lower()] = record
+                    callback = lambda x: self.listener.addService(x, self.type, record.alias)
+                    self.list.append(callback)
+
+            expires = record.getExpirationTime(75)
+            if expires < self.nextTime:
+                self.nextTime = expires
+
+    def cancel(self):
+        self.done = 1
+        self.zeroconf.notifyAll()
+
+    def run(self):
+        while 1:
+            event = None
+            now = currentTimeMillis()
+            if len(self.list) == 0 and self.nextTime > now:
+                self.zeroconf.wait(self.nextTime - now)
+            if globals()['_GLOBAL_DONE'] or self.done:
+                return
+            now = currentTimeMillis()
+
+            if self.nextTime <= now:
+                out = DNSOutgoing(_FLAGS_QR_QUERY)
+                out.addQuestion(DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN))
+                for record in self.services.values():
+                    if not record.isExpired(now):
+                        out.addAnswerAtTime(record, now)
+                self.zeroconf.send(out)
+                self.nextTime = now + self.delay
+                self.delay = min(20 * 1000, self.delay * 2)
+
+            if len(self.list) > 0:
+                event = self.list.pop(0)
+
+            if event is not None:
+                event(self.zeroconf)
+                
+
+class ServiceInfo(object):
+    """Service information"""
+    
+    def __init__(self, type, name, address=None, port=None, weight=0, priority=0, properties=None, server=None):
+        """Create a service description.
+
+        type: fully qualified service type name
+        name: fully qualified service name
+        address: IP address as unsigned short, network byte order
+        port: port that the service runs on
+        weight: weight of the service
+        priority: priority of the service
+        properties: dictionary of properties (or a string holding the bytes for the text field)
+        server: fully qualified name for service host (defaults to name)"""
+
+        if not name.endswith(type):
+            raise BadTypeInNameException
+        self.type = type
+        self.name = name
+        self.address = address
+        self.port = port
+        self.weight = weight
+        self.priority = priority
+        if server:
+            self.server = server
+        else:
+            self.server = name
+        self.setProperties(properties)
+
+    def setProperties(self, properties):
+        """Sets properties and text of this info from a dictionary"""
+        if isinstance(properties, dict):
+            self.properties = properties
+            list = []
+            result = ''
+            for key in properties:
+                value = properties[key]
+                if value is None:
+                    suffix = ''.encode('utf-8')
+                elif isinstance(value, str):
+                    suffix = value.encode('utf-8')
+                elif isinstance(value, int):
+                    if value:
+                        suffix = 'true'
+                    else:
+                        suffix = 'false'
+                else:
+                    suffix = ''.encode('utf-8')
+                list.append('='.join((key, suffix)))
+            for item in list:
+                result = ''.join((result, struct.pack('!c', chr(len(item))), item))
+            self.text = result
+        else:
+            self.text = properties
+
+    def setText(self, text):
+        """Sets properties and text given a text field"""
+        self.text = text
+        try:
+            result = {}
+            end = len(text)
+            index = 0
+            strs = []
+            while index < end:
+                length = ord(text[index])
+                index += 1
+                strs.append(text[index:index+length])
+                index += length
+            
+            for s in strs:
+                eindex = s.find('=')
+                if eindex == -1:
+                    # No equals sign at all
+                    key = s
+                    value = 0
+                else:
+                    key = s[:eindex]
+                    value = s[eindex+1:]
+                    if value == 'true':
+                        value = 1
+                    elif value == 'false' or not value:
+                        value = 0
+
+                # Only update non-existent properties
+                if key and result.get(key) == None:
+                    result[key] = value
+
+            self.properties = result
+        except:
+            traceback.print_exc()
+            self.properties = None
+            
+    def getType(self):
+        """Type accessor"""
+        return self.type
+
+    def getName(self):
+        """Name accessor"""
+        if self.type is not None and self.name.endswith("." + self.type):
+            return self.name[:len(self.name) - len(self.type) - 1]
+        return self.name
+
+    def getAddress(self):
+        """Address accessor"""
+        return self.address
+
+    def getPort(self):
+        """Port accessor"""
+        return self.port
+
+    def getPriority(self):
+        """Pirority accessor"""
+        return self.priority
+
+    def getWeight(self):
+        """Weight accessor"""
+        return self.weight
+
+    def getProperties(self):
+        """Properties accessor"""
+        return self.properties
+
+    def getText(self):
+        """Text accessor"""
+        return self.text
+
+    def getServer(self):
+        """Server accessor"""
+        return self.server
+
+    def updateRecord(self, zeroconf, now, record):
+        """Updates service information from a DNS record"""
+        if record is not None and not record.isExpired(now):
+            if record.type == _TYPE_A:
+                if record.name == self.name:
+                    self.address = record.address
+            elif record.type == _TYPE_SRV:
+                if record.name == self.name:
+                    self.server = record.server
+                    self.port = record.port
+                    self.weight = record.weight
+                    self.priority = record.priority
+                    self.address = None
+                    self.updateRecord(zeroconf, now, zeroconf.cache.getByDetails(self.server, _TYPE_A, _CLASS_IN))
+            elif record.type == _TYPE_TXT:
+                if record.name == self.name:
+                    self.setText(record.text)
+
+    def request(self, zeroconf, timeout):
+        """Returns true if the service could be discovered on the
+        network, and updates this object with details discovered.
+        """
+        now = currentTimeMillis()
+        delay = _LISTENER_TIME
+        next = now + delay
+        last = now + timeout
+        result = 0
+        try:
+            zeroconf.addListener(self, DNSQuestion(self.name, _TYPE_ANY, _CLASS_IN))
+            while self.server is None or self.address is None or self.text is None:
+                if last <= now:
+                    return 0
+                if next <= now:
+                    out = DNSOutgoing(_FLAGS_QR_QUERY)
+                    out.addQuestion(DNSQuestion(self.name, _TYPE_SRV, _CLASS_IN))
+                    out.addAnswerAtTime(zeroconf.cache.getByDetails(self.name, _TYPE_SRV, _CLASS_IN), now)
+                    out.addQuestion(DNSQuestion(self.name, _TYPE_TXT, _CLASS_IN))
+                    out.addAnswerAtTime(zeroconf.cache.getByDetails(self.name, _TYPE_TXT, _CLASS_IN), now)
+                    if self.server is not None:
+                        out.addQuestion(DNSQuestion(self.server, _TYPE_A, _CLASS_IN))
+                        out.addAnswerAtTime(zeroconf.cache.getByDetails(self.server, _TYPE_A, _CLASS_IN), now)
+                    zeroconf.send(out)
+                    next = now + delay
+                    delay = delay * 2
+
+                zeroconf.wait(min(next, last) - now)
+                now = currentTimeMillis()
+            result = 1
+        finally:
+            zeroconf.removeListener(self)
+            
+        return result
+
+    def __eq__(self, other):
+        """Tests equality of service name"""
+        if isinstance(other, ServiceInfo):
+            return other.name == self.name
+        return 0
+
+    def __ne__(self, other):
+        """Non-equality test"""
+        return not self.__eq__(other)
+
+    def __repr__(self):
+        """String representation"""
+        result = "service[%s,%s:%s," % (self.name, socket.inet_ntoa(self.getAddress()), self.port)
+        if self.text is None:
+            result += "None"
+        else:
+            if len(self.text) < 20:
+                result += self.text
+            else:
+                result += self.text[:17] + "..."
+        result += "]"
+        return result
+                
+
+class Zeroconf(object):
+    """Implementation of Zeroconf Multicast DNS Service Discovery
+
+    Supports registration, unregistration, queries and browsing.
+    """
+    def __init__(self, bindaddress=None):
+        """Creates an instance of the Zeroconf class, establishing
+        multicast communications, listening and reaping threads."""
+        globals()['_GLOBAL_DONE'] = 0
+        if bindaddress is None:
+            self.intf = socket.gethostbyname(socket.gethostname())
+        else:
+            self.intf = bindaddress
+        self.group = ('', _MDNS_PORT)
+        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        try:
+            self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+            self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
+        except:
+            # SO_REUSEADDR should be equivalent to SO_REUSEPORT for
+            # multicast UDP sockets (p 731, "TCP/IP Illustrated,
+            # Volume 2"), but some BSD-derived systems require
+            # SO_REUSEPORT to be specified explicity.  Also, not all
+            # versions of Python have SO_REUSEPORT available.  So
+            # if you're on a BSD-based system, and haven't upgraded
+            # to Python 2.3 yet, you may find this library doesn't
+            # work as expected.
+            #
+            pass
+        self.socket.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_TTL, 255)
+        self.socket.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_LOOP, 1)
+        try:
+            self.socket.bind(self.group)
+        except:
+            # Some versions of linux raise an exception even though
+            # the SO_REUSE* options have been set, so ignore it
+            #
+            pass
+        self.socket.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.intf) + socket.inet_aton('0.0.0.0'))
+        self.socket.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'))
+
+        self.listeners = []
+        self.browsers = []
+        self.services = {}
+
+        self.cache = DNSCache()
+
+        self.condition = threading.Condition()
+        
+        self.engine = Engine(self)
+        self.listener = Listener(self)
+        self.reaper = Reaper(self)
+
+    def isLoopback(self):
+        return self.intf.startswith("127.0.0.1")
+
+    def isLinklocal(self):
+        return self.intf.startswith("169.254.")
+
+    def wait(self, timeout):
+        """Calling thread waits for a given number of milliseconds or
+        until notified."""
+        self.condition.acquire()
+        self.condition.wait(timeout/1000)
+        self.condition.release()
+
+    def notifyAll(self):
+        """Notifies all waiting threads"""
+        self.condition.acquire()
+        self.condition.notifyAll()
+        self.condition.release()
+
+    def getServiceInfo(self, type, name, timeout=3000):
+        """Returns network's service information for a particular
+        name and type, or None if no service matches by the timeout,
+        which defaults to 3 seconds."""
+        info = ServiceInfo(type, name)
+        if info.request(self, timeout):
+            return info
+        return None
+
+    def addServiceListener(self, type, listener):
+        """Adds a listener for a particular service type.  This object
+        will then have its updateRecord method called when information
+        arrives for that type."""
+        self.removeServiceListener(listener)
+        self.browsers.append(ServiceBrowser(self, type, listener))
+
+    def removeServiceListener(self, listener):
+        """Removes a listener from the set that is currently listening."""
+        for browser in self.browsers:
+            if browser.listener == listener:
+                browser.cancel()
+                del(browser)
+
+    def registerService(self, info, ttl=_DNS_TTL):
+        """Registers service information to the network with a default TTL
+        of 60 seconds.  Zeroconf will then respond to requests for
+        information for that service.  The name of the service may be
+        changed if needed to make it unique on the network."""
+        self.checkService(info)
+        self.services[info.name.lower()] = info
+        now = currentTimeMillis()
+        nextTime = now
+        i = 0
+        while i < 3:
+            if now < nextTime:
+                self.wait(nextTime - now)
+                now = currentTimeMillis()
+                continue
+            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
+            out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, _CLASS_IN, ttl, info.name), 0)
+            out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, _CLASS_IN, ttl, info.priority, info.weight, info.port, info.server), 0)
+            out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, ttl, info.text), 0)
+            if info.address:
+                out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A, _CLASS_IN, ttl, info.address), 0)
+            self.send(out)
+            i += 1
+            nextTime += _REGISTER_TIME
+
+    def unregisterService(self, info):
+        """Unregister a service."""
+        try:
+            del(self.services[info.name.lower()])
+        except:
+            pass
+        now = currentTimeMillis()
+        nextTime = now
+        i = 0
+        while i < 3:
+            if now < nextTime:
+                self.wait(nextTime - now)
+                now = currentTimeMillis()
+                continue
+            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
+            out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, _CLASS_IN, 0, info.name), 0)
+            out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, _CLASS_IN, 0, info.priority, info.weight, info.port, info.name), 0)
+            out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, 0, info.text), 0)
+            if info.address:
+                out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A, _CLASS_IN, 0, info.address), 0)
+            self.send(out)
+            i += 1
+            nextTime += _UNREGISTER_TIME
+
+    def unregisterAllServices(self):
+        """Unregister all registered services."""
+        if len(self.services) > 0:
+            now = currentTimeMillis()
+            nextTime = now
+            i = 0
+            while i < 3:
+                if now < nextTime:
+                    self.wait(nextTime - now)
+                    now = currentTimeMillis()
+                    continue
+                out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
+                for info in self.services.values():
+                    out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, _CLASS_IN, 0, info.name), 0)
+                    out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, _CLASS_IN, 0, info.priority, info.weight, info.port, info.server), 0)
+                    out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, 0, info.text), 0)
+                    if info.address:
+                        out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A, _CLASS_IN, 0, info.address), 0)
+                self.send(out)
+                i += 1
+                nextTime += _UNREGISTER_TIME
+
+    def checkService(self, info):
+        """Checks the network for a unique service name, modifying the
+        ServiceInfo passed in if it is not unique."""
+        now = currentTimeMillis()
+        nextTime = now
+        i = 0
+        while i < 3:
+            for record in self.cache.entriesWithName(info.type):
+                if record.type == _TYPE_PTR and not record.isExpired(now) and record.alias == info.name:
+                    if (info.name.find('.') < 0):
+                        info.name = info.name + ".[" + info.address + ":" + info.port + "]." + info.type
+                        self.checkService(info)
+                        return
+                    raise NonUniqueNameException
+            if now < nextTime:
+                self.wait(nextTime - now)
+                now = currentTimeMillis()
+                continue
+            out = DNSOutgoing(_FLAGS_QR_QUERY | _FLAGS_AA)
+            self.debug = out
+            out.addQuestion(DNSQuestion(info.type, _TYPE_PTR, _CLASS_IN))
+            out.addAuthorativeAnswer(DNSPointer(info.type, _TYPE_PTR, _CLASS_IN, _DNS_TTL, info.name))
+            self.send(out)
+            i += 1
+            nextTime += _CHECK_TIME
+
+    def addListener(self, listener, question):
+        """Adds a listener for a given question.  The listener will have
+        its updateRecord method called when information is available to
+        answer the question."""
+        now = currentTimeMillis()
+        self.listeners.append(listener)
+        if question is not None:
+            for record in self.cache.entriesWithName(question.name):
+                if question.answeredBy(record) and not record.isExpired(now):
+                    listener.updateRecord(self, now, record)
+        self.notifyAll()
+
+    def removeListener(self, listener):
+        """Removes a listener."""
+        try:
+            self.listeners.remove(listener)
+            self.notifyAll()
+        except:
+            pass
+
+    def updateRecord(self, now, rec):
+        """Used to notify listeners of new information that has updated
+        a record."""
+        for listener in self.listeners:
+            listener.updateRecord(self, now, rec)
+        self.notifyAll()
+
+    def handleResponse(self, msg):
+        """Deal with incoming response packets.  All answers
+        are held in the cache, and listeners are notified."""
+        now = currentTimeMillis()
+        for record in msg.answers:
+            expired = record.isExpired(now)
+            if record in self.cache.entries():
+                if expired:
+                    self.cache.remove(record)
+                else:
+                    entry = self.cache.get(record)
+                    if entry is not None:
+                        entry.resetTTL(record)
+                        record = entry
+            else:
+                self.cache.add(record)
+                
+            self.updateRecord(now, record)
+
+    def handleQuery(self, msg, addr, port):
+        """Deal with incoming query packets.  Provides a response if
+        possible."""
+        out = None
+
+        # Support unicast client responses
+        #
+        if port != _MDNS_PORT:
+            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA, 0)
+            for question in msg.questions:
+                out.addQuestion(question)
+        
+        for question in msg.questions:
+            if question.type == _TYPE_PTR:
+                for service in self.services.values():
+                    if question.name == service.type:
+                        if out is None:
+                            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
+                        out.addAnswer(msg, DNSPointer(service.type, _TYPE_PTR, _CLASS_IN, _DNS_TTL, service.name))
+            else:
+                try:
+                    if out is None:
+                        out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
+                    
+                    # Answer A record queries for any service addresses we know
+                    if question.type == _TYPE_A or question.type == _TYPE_ANY:
+                        for service in self.services.values():
+                            if service.server == question.name.lower():
+                                out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address))
+                    
+                    service = self.services.get(question.name.lower(), None)
+                    if not service: continue
+                    
+                    if question.type == _TYPE_SRV or question.type == _TYPE_ANY:
+                        out.addAnswer(msg, DNSService(question.name, _TYPE_SRV, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.priority, service.weight, service.port, service.server))
+                    if question.type == _TYPE_TXT or question.type == _TYPE_ANY:
+                        out.addAnswer(msg, DNSText(question.name, _TYPE_TXT, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.text))
+                    if question.type == _TYPE_SRV:
+                        out.addAdditionalAnswer(DNSAddress(service.server, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address))
+                except:
+                    traceback.print_exc()
+                
+        if out is not None and out.answers:
+            out.id = msg.id
+            self.send(out, addr, port)
+
+    def send(self, out, addr = _MDNS_ADDR, port = _MDNS_PORT):
+        """Sends an outgoing packet."""
+        # This is a quick test to see if we can parse the packets we generate
+        #temp = DNSIncoming(out.packet())
+        try:
+            bytes_sent = self.socket.sendto(out.packet(), 0, (addr, port))
+        except:
+            # Ignore this, it may be a temporary loss of network connection
+            pass
+
+    def close(self):
+        """Ends the background threads, and prevent this instance from
+        servicing further queries."""
+        if globals()['_GLOBAL_DONE'] == 0:
+            globals()['_GLOBAL_DONE'] = 1
+            self.notifyAll()
+            self.engine.notify()
+            self.unregisterAllServices()
+            self.socket.setsockopt(socket.SOL_IP, socket.IP_DROP_MEMBERSHIP, socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'))
+            self.socket.close()
+            
+# Test a few module features, including service registration, service
+# query (for Zoe), and service unregistration.
+
+if __name__ == '__main__':    
+    print "Multicast DNS Service Discovery for Python, version", __version__
+    r = Zeroconf()
+    print "1. Testing registration of a service..."
+    desc = {'version':'0.10','a':'test value', 'b':'another value'}
+    info = ServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.", socket.inet_aton("127.0.0.1"), 1234, 0, 0, desc)
+    print "   Registering service..."
+    r.registerService(info)
+    print "   Registration done."
+    print "2. Testing query of service information..."
+    print "   Getting ZOE service:", str(r.getServiceInfo("_http._tcp.local.", "ZOE._http._tcp.local."))
+    print "   Query done."
+    print "3. Testing query of own service..."
+    print "   Getting self:", str(r.getServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local."))
+    print "   Query done."
+    print "4. Testing unregister of service information..."
+    r.unregisterService(info)
+    print "   Unregister done."
+    r.close()
--- a/testing/mozbase/mozdevice/mozdevice/__init__.py
+++ b/testing/mozbase/mozdevice/mozdevice/__init__.py
@@ -1,14 +1,15 @@
 # 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 adb import ADBError, ADBRootError, ADBTimeoutError, ADBProcess, ADBCommand, ADBHost, ADBDevice
 from adb_android import ADBAndroid
 from adb_b2g import ADBB2G
-from devicemanager import DeviceManager, DMError
+from devicemanager import DeviceManager, DMError, ZeroconfListener
 from devicemanagerADB import DeviceManagerADB
-from droid import DroidADB
+from devicemanagerSUT import DeviceManagerSUT
+from droid import DroidADB, DroidSUT, DroidConnectByHWID
 
 __all__ = ['ADBError', 'ADBRootError', 'ADBTimeoutError', 'ADBProcess', 'ADBCommand', 'ADBHost',
-           'ADBDevice', 'ADBAndroid', 'ADBB2G', 'DeviceManager', 'DMError',
-           'DeviceManagerADB', 'DroidADB']
+           'ADBDevice', 'ADBAndroid', 'ADBB2G', 'DeviceManager', 'DMError', 'ZeroconfListener',
+           'DeviceManagerADB', 'DeviceManagerSUT', 'DroidADB', 'DroidSUT', 'DroidConnectByHWID']
--- a/testing/mozbase/mozdevice/mozdevice/devicemanager.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanager.py
@@ -41,18 +41,17 @@ def abstractmethod(method):
 class DeviceManager(object):
     """
     Represents a connection to a device. Once an implementation of this class
     is successfully instantiated, you may do things like list/copy files to
     the device, launch processes on the device, and install or remove
     applications from the device.
 
     Never instantiate this class directly! Instead, instantiate an
-    implementation of it like DeviceManagerADB. New projects should strongly
-    consider using adb.py as an alternative.
+    implementation of it like DeviceManagerADB or DeviceManagerSUT.
     """
 
     _logcatNeedsRoot = True
     default_timeout = 300
     short_timeout = 30
 
     def __init__(self, logLevel=None, deviceRoot=None):
         try:
@@ -478,17 +477,20 @@ class DeviceManager(object):
         """
 
     @abstractmethod
     def reboot(self, wait=False, ipAddr=None):
         """
         Reboots the device.
 
         :param wait: block on device to come back up before returning
-        :param ipAddr: deprecated; do not use
+        :param ipAddr: if specified, try to make the device connect to this
+                       specific IP address after rebooting (only works with
+                       SUT; if None, we try to determine a reasonable address
+                       ourselves)
         """
 
     @abstractmethod
     def installApp(self, appBundlePath, destPath=None):
         """
         Installs an application onto the device.
 
         :param appBundlePath: path to the application bundle on the device
@@ -521,17 +523,20 @@ class DeviceManager(object):
         Updates the application on the device and reboots.
 
         :param appBundlePath: path to the application bundle on the device
         :param processName: used to end the process if the applicaiton is
                             currently running (optional)
         :param destPath: Destination directory to where the application should
                          be installed (optional)
         :param wait: block on device to come back up before returning
-        :param ipAddr: deprecated; do not use
+        :param ipAddr: if specified, try to make the device connect to this
+                       specific IP address after rebooting (only works with
+                       SUT; if None and wait is True, we try to determine a
+                       reasonable address ourselves)
         """
 
     @staticmethod
     def _writePNG(buf, width, height):
         """
         Method for writing a PNG from a buffer, used by getScreenshot on older devices,
         """
         # Based on: http://code.activestate.com/recipes/577443-write-a-png-image-in-native-python/
@@ -600,19 +605,19 @@ class DeviceManager(object):
 
             quotedCmd.append(arg)
 
         return " ".join(quotedCmd)
 
 
 def _pop_last_line(file_obj):
     """
-    Utility function to get the last line from a file. Function also removes
-    it from the file. Intended to strip off the return code from a shell
-    command.
+    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_obj.seek(0, 2)
     length = file_obj.tell() + 1
     while bytes_from_end < length:
         file_obj.seek((-1) * bytes_from_end, 2)
         data = file_obj.read()
 
@@ -629,8 +634,41 @@ def _pop_last_line(file_obj):
             file_obj.seek(0, 2)
             file_obj.write('\0')
 
             return data
 
         bytes_from_end += 1
 
     return None
+
+
+class ZeroconfListener(object):
+
+    def __init__(self, hwid, evt):
+        self.hwid = hwid
+        self.evt = evt
+
+    # Format is 'SUTAgent [hwid:015d2bc2825ff206] [ip:10_242_29_221]._sutagent._tcp.local.'
+    def addService(self, zeroconf, type, name):
+        # print "Found _sutagent service broadcast:", name
+        if not name.startswith("SUTAgent"):
+            return
+
+        sutname = name.split('.')[0]
+        m = re.search('\[hwid:([^\]]*)\]', sutname)
+        if m is None:
+            return
+
+        hwid = m.group(1)
+
+        m = re.search('\[ip:([0-9_]*)\]', sutname)
+        if m is None:
+            return
+
+        ip = m.group(1).replace("_", ".")
+
+        if self.hwid == hwid:
+            self.ip = ip
+            self.evt.set()
+
+    def removeService(self, zeroconf, type, name):
+        pass
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -228,17 +228,19 @@ class DeviceManagerADB(DeviceManager):
     def _connectRemoteADB(self):
         self._checkCmd(["connect", self.host + ":" + str(self.port)])
 
     def _disconnectRemoteADB(self):
         self._checkCmd(["disconnect", self.host + ":" + str(self.port)])
 
     def pushFile(self, localname, destname, retryLimit=None, createDir=True):
         # you might expect us to put the file *in* the directory in this case,
-        # but that would be inconsistent with historical behavior.
+        # but that would be different behaviour from devicemanagerSUT. Throw
+        # an exception so we have the same behaviour between the two
+        # implementations
         retryLimit = retryLimit or self.retryLimit
         if self.dirExists(destname):
             raise DMError("Attempted to push a file (%s) to a directory (%s)!" %
                           (localname, destname))
         if not os.access(localname, os.F_OK):
             raise DMError("File not found: %s" % localname)
 
         proc = self._runCmd(["push", os.path.realpath(localname), destname],
@@ -406,16 +408,17 @@ class DeviceManagerADB(DeviceManager):
         """
         if cmd[0] == "am":
             self._checkCmd(["shell"] + cmd)
             return outputFile
 
         acmd = ["-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:
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
@@ -0,0 +1,975 @@
+# 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 datetime
+import logging
+import moznetwork
+import select
+import socket
+import time
+import os
+import re
+import posixpath
+import subprocess
+import StringIO
+from devicemanager import DeviceManager, DMError, _pop_last_line
+import errno
+from distutils.version import StrictVersion
+
+
+class DeviceManagerSUT(DeviceManager):
+    """
+    Implementation of DeviceManager interface that speaks to a device over
+    TCP/IP using the "system under test" protocol. A software agent such as
+    Negatus (http://github.com/mozilla/Negatus) or the Mozilla Android SUTAgent
+    app must be present and listening for connections for this to work.
+    """
+
+    _base_prompt = '$>'
+    _base_prompt_re = '\$\>'
+    _prompt_sep = '\x00'
+    _prompt_regex = '.*(' + _base_prompt_re + _prompt_sep + ')'
+    _agentErrorRE = re.compile('^##AGENT-WARNING##\ ?(.*)')
+
+    reboot_timeout = 600
+    reboot_settling_time = 60
+
+    def __init__(self, host, port=20701, retryLimit=5, deviceRoot=None,
+                 logLevel=logging.ERROR, **kwargs):
+        DeviceManager.__init__(self, logLevel=logLevel,
+                               deviceRoot=deviceRoot)
+        self.host = host
+        self.port = port
+        self.retryLimit = retryLimit
+        self._sock = None
+        self._everConnected = False
+
+        # Get version
+        verstring = self._runCmds([{'cmd': 'ver'}])
+        ver_re = re.match('(\S+) Version (\S+)', verstring)
+        self.agentProductName = ver_re.group(1)
+        self.agentVersion = ver_re.group(2)
+
+    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):
+        """
+        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, retryLimit=None):
+        """
+        Wrapper for _doCmds that loops up to 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.
+
+        retryLimit = retryLimit or self.retryLimit
+        retries = 0
+        while retries < retryLimit:
+            try:
+                self._doCmds(cmdlist, outputfile, timeout)
+                return
+            except DMError as 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
+                self._logger.debug(err)
+                retries += 1
+                # if we lost the connection or failed to establish one, wait a bit
+                if retries < retryLimit and not self._sock:
+                    sleep_time = 5 * retries
+                    self._logger.info('Could not connect; sleeping for %d seconds.' % sleep_time)
+                    time.sleep(sleep_time)
+
+        raise DMError("Remote Device Error: unable to connect to %s after %s attempts" %
+                      (self.host, retryLimit))
+
+    def _runCmds(self, cmdlist, timeout=None, retryLimit=None):
+        """
+        Similar to _sendCmds, but just returns any output as a string instead of
+        writing to a file
+        """
+        retryLimit = retryLimit or self.retryLimit
+        outputfile = StringIO.StringIO()
+        self._sendCmds(cmdlist, outputfile, timeout, retryLimit=retryLimit)
+        outputfile.seek(0)
+        return outputfile.read()
+
+    def _doCmds(self, cmdlist, outputfile, timeout):
+        promptre = re.compile(self._prompt_regex + '$')
+        shouldCloseSocket = False
+
+        if not timeout:
+            # We are asserting that all commands will complete in this time unless
+            # otherwise specified
+            timeout = self.default_timeout
+
+        if not self._sock:
+            try:
+                if self._everConnected:
+                    self._logger.info("reconnecting socket")
+                self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            except socket.error as msg:
+                self._sock = None
+                raise DMError("Automation Error: unable to create socket: " + str(msg))
+
+            try:
+                self._sock.settimeout(float(timeout))
+                self._sock.connect((self.host, int(self.port)))
+                self._everConnected = True
+            except socket.error as msg:
+                self._sock = None
+                raise DMError("Remote Device Error: Unable to connect socket: " + str(msg))
+
+            # consume prompt
+            try:
+                self._sock.recv(1024)
+            except socket.error as msg:
+                self._sock.close()
+                self._sock = None
+                raise DMError(
+                    "Remote Device Error: Did not get prompt after connecting: " + str(msg),
+                    fatal=True)
+
+            # future recv() timeouts are handled by select() calls
+            self._sock.settimeout(None)
+
+        for cmd in cmdlist:
+            cmdline = '%s\r\n' % cmd['cmd']
+
+            try:
+                sent = self._sock.send(cmdline)
+                if sent != len(cmdline):
+                    raise DMError("Remote Device Error: our cmd was %s bytes and we "
+                                  "only sent %s" % (len(cmdline), sent))
+                if cmd.get('data'):
+                    totalsent = 0
+                    while totalsent < len(cmd['data']):
+                        sent = self._sock.send(cmd['data'][totalsent:])
+                        self._logger.debug("sent %s bytes of data payload" % sent)
+                        if sent == 0:
+                            raise DMError("Socket connection broken when sending data")
+                        totalsent += sent
+
+                self._logger.debug("sent cmd: %s" % cmd['cmd'])
+            except socket.error as msg:
+                self._sock.close()
+                self._sock = None
+                self._logger.error("Remote Device Error: Error sending data"
+                                   " to socket. cmd=%s; err=%s" % (cmd['cmd'], 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']):
+                foundPrompt = False
+                data = ""
+                timer = 0
+                select_timeout = 1
+                commandFailed = False
+
+                while not foundPrompt:
+                    socketClosed = False
+                    errStr = ''
+                    temp = ''
+                    self._logger.debug("recv'ing...")
+
+                    # Get our response
+                    try:
+                        # Wait up to a second for socket to become ready for reading...
+                        if select.select([self._sock], [], [], select_timeout)[0]:
+                            temp = self._sock.recv(1024)
+                            self._logger.debug(u"response: %s" % temp.decode('utf8', 'replace'))
+                            timer = 0
+                            if not temp:
+                                socketClosed = True
+                                errStr = 'connection closed'
+                        timer += select_timeout
+                        if timer > timeout:
+                            self._sock.close()
+                            self._sock = None
+                            raise DMError("Automation Error: Timeout in command %s" %
+                                          cmd['cmd'], fatal=True)
+                    except socket.error as err:
+                        socketClosed = True
+                        errStr = str(err)
+                        # This error shows up with we have our tegra rebooted.
+                        if err[0] == errno.ECONNRESET:
+                            errStr += ' - possible reboot'
+
+                    if socketClosed:
+                        self._sock.close()
+                        self._sock = None
+                        raise DMError(
+                            "Automation Error: Error receiving data from socket. "
+                            "cmd=%s; err=%s" % (cmd, errStr))
+
+                    data += temp
+
+                    # If something goes wrong in the agent it will send back a string that
+                    # starts with '##AGENT-WARNING##'
+                    if not commandFailed:
+                        errorMatch = self._agentErrorRE.match(data)
+                        if errorMatch:
+                            # We still need to consume the prompt, so raise an error after
+                            # draining the rest of the buffer.
+                            commandFailed = True
+
+                    for line in data.splitlines():
+                        if promptre.match(line):
+                            foundPrompt = 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 commandFailed:
+                    raise DMError("Automation Error: Error processing command '%s'; err='%s'" %
+                                  (cmd['cmd'], errorMatch.group(1)), fatal=True)
+
+                # Write any remaining data to outputfile
+                outputfile.write(data)
+
+        if shouldCloseSocket:
+            try:
+                self._sock.close()
+                self._sock = None
+            except:
+                self._sock = None
+                raise DMError("Automation Error: Error closing socket")
+
+    def _setupDeviceRoot(self, deviceRoot):
+        if not deviceRoot:
+            deviceRoot = "%s/tests" % self._runCmds(
+                [{'cmd': 'testroot'}]).strip()
+        self.mkDir(deviceRoot)
+
+        return deviceRoot
+
+    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)
+
+        # execcwd/execcwdsu currently unsupported in Negatus; see bug 824127.
+        if cwd and self.agentProductName == 'SUTAgentNegatus':
+            raise DMError("Negatus does not support execcwd/execcwdsu")
+
+        haveExecSu = (self.agentProductName == 'SUTAgentNegatus' or
+                      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"
+
+        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)
+
+        # 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
+        raise DMError(
+            "Automation Error: Error finding end of line/return value when running '%s'" % cmdline)
+
+    def pushFile(self, localname, destname, retryLimit=None, createDir=True):
+        retryLimit = retryLimit or self.retryLimit
+        if createDir:
+            self.mkDirs(destname)
+
+        try:
+            filesize = os.path.getsize(localname)
+            with open(localname, 'rb') as f:
+                remoteHash = self._runCmds([{'cmd': 'push ' + destname + ' ' + str(filesize),
+                                             'data': f.read()}], retryLimit=retryLimit).strip()
+        except OSError:
+            raise DMError("DeviceManager: Error reading file to push")
+
+        self._logger.debug("push returned: %s" % remoteHash)
+
+        localHash = self._getLocalHash(localname)
+
+        if localHash != remoteHash:
+            raise DMError("Automation Error: Push File failed to Validate! (localhash: %s, "
+                          "remotehash: %s)" % (localHash, remoteHash))
+
+    def mkDir(self, name):
+        if not self.dirExists(name):
+            self._runCmds([{'cmd': 'mkdr ' + name}])
+
+    def pushDir(self, localDir, remoteDir, retryLimit=None, timeout=None):
+        retryLimit = retryLimit or self.retryLimit
+        self._logger.info("pushing directory: %s to %s" % (localDir, remoteDir))
+
+        existentDirectories = []
+        for root, dirs, files in os.walk(localDir, followlinks=True):
+            _, subpath = root.split(localDir)
+            subpath = subpath.lstrip('/')
+            remoteRoot = posixpath.join(remoteDir, subpath)
+            for f in files:
+                remoteName = posixpath.join(remoteRoot, f)
+
+                if subpath == "":
+                    remoteRoot = remoteDir
+
+                parent = os.path.dirname(remoteName)
+                if parent not in existentDirectories:
+                    self.mkDirs(remoteName)
+                    existentDirectories.append(parent)
+
+                self.pushFile(os.path.join(root, f), remoteName,
+                              retryLimit=retryLimit, createDir=False)
+
+    def dirExists(self, remotePath):
+        ret = self._runCmds([{'cmd': 'isdir ' + remotePath}]).strip()
+        if not ret:
+            raise DMError('Automation Error: DeviceManager isdir returned null')
+
+        return ret == 'TRUE'
+
+    def fileExists(self, filepath):
+        # Because we always have / style paths we make this a lot easier with some
+        # assumptions
+        filepath = posixpath.normpath(filepath)
+        # / should always exist but we can use this to check for things like
+        # having access to the filesystem
+        if filepath == '/':
+            return self.dirExists(filepath)
+        (containingpath, filename) = posixpath.split(filepath)
+        return filename in self.listFiles(containingpath)
+
+    def listFiles(self, rootdir):
+        rootdir = posixpath.normpath(rootdir)
+        if not self.dirExists(rootdir):
+            return []
+        data = self._runCmds([{'cmd': 'cd ' + rootdir}, {'cmd': 'ls'}])
+
+        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
+
+    def removeFile(self, filename):
+        self._logger.info("removing file: " + filename)
+        if self.fileExists(filename):
+            self._runCmds([{'cmd': 'rm ' + filename}])
+
+    def removeDir(self, remoteDir):
+        if self.dirExists(remoteDir):
+            self._runCmds([{'cmd': 'rmdr ' + remoteDir}])
+
+    def moveTree(self, source, destination):
+        self._runCmds([{'cmd': 'mv %s %s' % (source, destination)}])
+
+    def copyTree(self, source, destination):
+        self._runCmds([{'cmd': 'dd if=%s of=%s' % (source, destination)}])
+
+    def getProcessList(self):
+        data = self._runCmds([{'cmd': 'ps'}])
+
+        processTuples = []
+        for line in data.splitlines():
+            if line:
+                pidproc = line.strip().split()
+                try:
+                    if (len(pidproc) == 2):
+                        processTuples += [[pidproc[0], pidproc[1]]]
+                    elif (len(pidproc) == 3):
+                        # android returns <userID> <procID> <procName>
+                        processTuples += [[int(pidproc[1]), pidproc[2], int(pidproc[0])]]
+                    else:
+                        # unexpected format
+                        raise ValueError
+                except ValueError:
+                    self._logger.error("Unable to parse process list (bug 805969)")
+                    self._logger.error("Line: %s\nFull output of process list:\n%s" % (line, data))
+                    raise DMError("Invalid process line: %s" % line)
+
+        return processTuples
+
+    def fireProcess(self, appname, failIfRunning=False, maxWaitTime=30):
+        """
+        Starts a process
+
+        returns: pid
+
+        DEPRECATED: Use shell() or launchApplication() for new code
+        """
+        if not appname:
+            raise DMError("Automation Error: fireProcess called with no command to run")
+
+        self._logger.info("FIRE PROC: '%s'" % appname)
+
+        if (self.processExist(appname) is None):
+            self._logger.warning("process %s appears to be running already\n" % appname)
+            if (failIfRunning):
+                raise DMError("Automation Error: Process is already running")
+
+        self._runCmds([{'cmd': 'exec ' + appname}])
+
+        # The 'exec' command may wait for the process to start and end, so checking
+        # for the process here may result in process = None.
+        # The normal case is to launch the process and return right away
+        # There is one case with robotium (am instrument) where exec returns at the end
+        pid = None
+        waited = 0
+        while pid is None and waited < maxWaitTime:
+            pid = self.processExist(appname)
+            if pid:
+                break
+            time.sleep(1)
+            waited += 1
+
+        self._logger.debug("got pid: %s for process: %s" % (pid, appname))
+        return pid
+
+    def launchProcess(self, cmd, outputFile="process.txt", cwd='', env='', failIfRunning=False):
+        """
+        Launches a process, redirecting output to standard out
+
+        Returns output filename
+
+        WARNING: Does not work how you expect on Android! The application's
+        own output will be flushed elsewhere.
+
+        DEPRECATED: Use shell() or launchApplication() for new code
+        """
+        if not cmd:
+            self._logger.warning("launchProcess called without command to run")
+            return None
+
+        if cmd[0] == 'am' and hasattr(self, '_getExtraAmStartArgs'):
+            cmd = cmd[:2] + self._getExtraAmStartArgs() + cmd[2:]
+
+        cmdline = subprocess.list2cmdline(cmd)
+        if outputFile == "process.txt" or outputFile is None:
+            outputFile += "%s/process.txt" % self.deviceRoot
+            cmdline += " > " + outputFile
+
+        # Prepend our env to the command
+        cmdline = '%s %s' % (self._formatEnvString(env), cmdline)
+
+        # fireProcess may trigger an exception, but we won't handle it
+        if cmd[0] == "am":
+            # Robocop tests spawn "am instrument". sutAgent's exec ensures that
+            # am has started before returning, so there is no point in having
+            # fireProcess wait for it to start. Also, since "am" does not show
+            # up in the process list while the test is running, waiting for it
+            # in fireProcess is difficult.
+            self.fireProcess(cmdline, failIfRunning, 0)
+        else:
+            self.fireProcess(cmdline, failIfRunning)
+        return outputFile
+
+    def killProcess(self, appname, sig=None):
+        if sig:
+            pid = self.processExist(appname)
+            if pid and pid > 0:
+                try:
+                    self.shellCheckOutput(['kill', '-%d' % sig, str(pid)],
+                                          root=True)
+                except DMError as err:
+                    self._logger.warning("unable to kill -%d %s (pid %s)" %
+                                         (sig, appname, str(pid)))
+                    self._logger.debug(err)
+                    raise err
+            else:
+                self._logger.warning("unable to kill -%d %s -- not running?" %
+                                     (sig, appname))
+        else:
+            retries = 0
+            while retries < self.retryLimit:
+                try:
+                    if self.processExist(appname):
+                        self._runCmds([{'cmd': 'kill ' + appname}])
+                    return
+                except DMError as err:
+                    retries += 1
+                    self._logger.warning("try %d of %d failed to kill %s" %
+                                         (retries, self.retryLimit, appname))
+                    self._logger.debug(err)
+                    if retries >= self.retryLimit:
+                        raise err
+
+    def getTempDir(self):
+        return self._runCmds([{'cmd': 'tmpd'}]).strip()
+
+    def pullFile(self, remoteFile, offset=None, length=None):
+        # 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 = 'DeviceManager: pull unsuccessful: %s' % error_msg
+            self._logger.error(err_str)
+            self._sock = None
+            raise DMError(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 = ""
+                if select.select([self._sock], [], [], self.default_timeout)[0]:
+                    data = self._sock.recv(to_recv)
+                if not data:
+                    # timed out waiting for response or error response
+                    err(error_msg)
+
+                return data
+            except:
+                err(error_msg)
+
+        def read_until_char(c, buf, error_msg):
+            """ read until 'c' is found; buffer rest """
+            while c not in buf:
+                data = uread(1024, error_msg)
+                buf += data
+            return buf.partition(c)
+
+        def read_exact(total_to_recv, buf, error_msg):
+            """ read exact number of 'total_to_recv' bytes """
+            while len(buf) < total_to_recv:
+                to_recv = min(total_to_recv - len(buf), 1024)
+                data = uread(to_recv, error_msg)
+                buf += data
+            return buf
+
+        prompt = self._base_prompt + self._prompt_sep
+        buf = ''
+
+        # expected return value:
+        # <filename>,<filesize>\n<filedata>
+        # or, if error,
+        # <filename>,-1\n<error message>
+
+        # just send the command first, we read the response inline below
+        if offset is not None and length is not None:
+            cmd = 'pull %s %d %d' % (remoteFile, offset, length)
+        elif offset is not None:
+            cmd = 'pull %s %d' % (remoteFile, offset)
+        else:
+            cmd = 'pull %s' % remoteFile
+
+        self._runCmds([{'cmd': cmd}])
+
+        # read metadata; buffer the rest
+        metadata, sep, buf = read_until_char('\n', buf, 'could not find metadata')
+        if not metadata:
+            return None
+        self._logger.debug('metadata: %s' % metadata)
+
+        filename, sep, filesizestr = metadata.partition(',')
+        if sep == '':
+            err('could not find file size in returned metadata')
+        try:
+            filesize = int(filesizestr)
+        except ValueError:
+            err('invalid file size in returned metadata')
+
+        if filesize == -1:
+            # read error message
+            error_str, sep, buf = read_until_char('\n', buf, 'could not find error message')
+            if not error_str:
+                err("blank error message")
+            # prompt should follow
+            read_exact(len(prompt), buf, 'could not find prompt')
+            # failures are expected, so don't use "Remote Device Error" or we'll RETRY
+            raise DMError("DeviceManager: pulling file '%s' unsuccessful: %s" %
+                          (remoteFile, error_str))
+
+        # read file data
+        total_to_recv = filesize + len(prompt)
+        buf = read_exact(total_to_recv, buf, 'could not get all file data')
+        if buf[-len(prompt):] != prompt:
+            err('no prompt found after file data--DeviceManager may be out of sync with agent')
+            return buf
+        return buf[:-len(prompt)]
+
+    def getFile(self, remoteFile, localFile):
+        data = self.pullFile(remoteFile)
+
+        fhandle = open(localFile, 'wb')
+        fhandle.write(data)
+        fhandle.close()
+        if not self.validateFile(remoteFile, localFile):
+            raise DMError("Automation Error: Failed to validate file when downloading %s" %
+                          remoteFile)
+
+    def getDirectory(self, remoteDir, localDir, checkDir=True):
+        self._logger.info("getting files in '%s'" % remoteDir)
+        if checkDir and not self.dirExists(remoteDir):
+            raise DMError("Automation Error: Error getting directory: %s not a directory" %
+                          remoteDir)
+
+        filelist = self.listFiles(remoteDir)
+        self._logger.debug(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)
+            if self.dirExists(remotePath):
+                self.getDirectory(remotePath, localPath, False)
+            else:
+                self.getFile(remotePath, localPath)
+
+    def validateFile(self, remoteFile, localFile):
+        remoteHash = self._getRemoteHash(remoteFile)
+        localHash = self._getLocalHash(localFile)
+
+        if (remoteHash is None):
+            return False
+
+        if (remoteHash == localHash):
+            return True
+
+        return False
+
+    def _getRemoteHash(self, filename):
+        data = self._runCmds([{'cmd': 'hash ' + filename}]).strip()
+        self._logger.debug("remote hash returned: '%s'" % data)
+        return data
+
+    def unpackFile(self, filePath, destDir=None):
+        """
+        Unzips a bundle to a location on the device
+
+        If destDir is not specified, the bundle is extracted in the same directory
+        """
+        # if no destDir is passed in just set it to filePath's folder
+        if not destDir:
+            destDir = posixpath.dirname(filePath)
+
+        if destDir[-1] != '/':
+            destDir += '/'
+
+        self._runCmds([{'cmd': 'unzp %s %s' % (filePath, destDir)}])
+
+    def _getRebootServerSocket(self, ipAddr):
+        serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+        serverSocket.settimeout(60.0)
+        serverSocket.bind((ipAddr, 0))
+        serverSocket.listen(1)
+        self._logger.debug('Created reboot callback server at %s:%d' %
+                           serverSocket.getsockname())
+        return serverSocket
+
+    def _waitForRebootPing(self, serverSocket):
+        conn = None
+        data = None
+        startTime = datetime.datetime.now()
+        waitTime = datetime.timedelta(seconds=self.reboot_timeout)
+        while not data and datetime.datetime.now() - startTime < waitTime:
+            self._logger.info("Waiting for reboot callback ping from device...")
+            try:
+                if not conn:
+                    conn, _ = serverSocket.accept()
+                # Receiving any data is good enough.
+                data = conn.recv(1024)
+                if data:
+                    self._logger.info("Received reboot callback ping from device!")
+                    conn.sendall('OK')
+                conn.close()
+            except socket.timeout:
+                pass
+            except socket.error as e:
+                if e.errno != errno.EAGAIN and e.errno != errno.EWOULDBLOCK:
+                    raise
+
+        if not data:
+            raise DMError('Timed out waiting for reboot callback.')
+
+        self._logger.info("Sleeping for %s seconds to wait for device "
+                          "to 'settle'" % self.reboot_settling_time)
+        time.sleep(self.reboot_settling_time)
+
+    def reboot(self, ipAddr=None, port=30000, wait=False):
+        # port ^^^ is here for backwards compatibility only, we now
+        # determine a port automatically and safely
+        wait = (wait or ipAddr)
+
+        cmd = 'rebt'
+
+        self._logger.info("Rebooting device")
+
+        # if we're waiting, create a listening server and pass information on
+        # it to the device before rebooting (we do this instead of just polling
+        # to make sure the device actually rebooted -- yes, there are probably
+        # simpler ways of doing this like polling uptime, but this is what we're
+        # doing for now)
+        if wait:
+            if not ipAddr:
+                ipAddr = moznetwork.get_ip()
+            serverSocket = self._getRebootServerSocket(ipAddr)
+            # The update.info command tells the SUTAgent to send a TCP message
+            # after restarting.
+            destname = '/data/data/com.mozilla.SUTAgentAndroid/files/update.info'
+            data = "%s,%s\rrebooting\r" % serverSocket.getsockname()
+            self._runCmds([{'cmd': 'push %s %s' % (destname, len(data)),
+                            'data': data}])
+            cmd += " %s %s" % serverSocket.getsockname()
+
+        # actually reboot device
+        self._runCmds([{'cmd': cmd}])
+        # if we're waiting, wait for a callback ping from the agent before
+        # continuing (and throw an exception if we don't receive said ping)
+        if wait:
+            self._waitForRebootPing(serverSocket)
+
+    def getInfo(self, directive=None):
+        data = None
+        result = {}
+        collapseSpaces = re.compile('  +')
+
+        directives = ['os', 'id', 'uptime', 'uptimemillis', 'systime', 'screen',
+                      'rotation', 'memory', 'process', 'disk', 'power', 'sutuserinfo',
+                      'temperature']
+        if (directive in directives):
+            directives = [directive]
+
+        for d in directives:
+            data = self._runCmds([{'cmd': 'info ' + d}])
+
+            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
+
+        self._logger.debug("results: %s" % result)
+        return result
+
+    def installApp(self, appBundlePath, destPath=None):
+        cmd = 'inst ' + appBundlePath
+        if destPath:
+            cmd += ' ' + destPath
+
+        data = self._runCmds([{'cmd': cmd}])
+
+        if 'installation complete [0]' not in data:
+            raise DMError("Remove Device Error: Error installing app. Error message: %s" % data)
+
+    def uninstallApp(self, appName, installPath=None):
+        cmd = 'uninstall ' + appName
+        if installPath:
+            cmd += ' ' + installPath
+        data = self._runCmds([{'cmd': cmd}])
+
+        status = data.split('\n')[0].strip()
+        self._logger.debug("uninstallApp: '%s'" % status)
+        if status == 'Success':
+            return
+        raise DMError("Remote Device Error: uninstall failed for %s" % appName)
+
+    def uninstallAppAndReboot(self, appName, installPath=None):
+        cmd = 'uninst ' + appName
+        if installPath:
+            cmd += ' ' + installPath
+        data = self._runCmds([{'cmd': cmd}])
+
+        self._logger.debug("uninstallAppAndReboot: %s" % data)
+        return
+
+    def updateApp(self, appBundlePath, processName=None, destPath=None,
+                  ipAddr=None, port=30000, wait=False):
+        # port ^^^ is here for backwards compatibility only, we now
+        # determine a port automatically and safely
+        wait = (wait or ipAddr)
+
+        cmd = 'updt '
+        if processName is None:
+            # Then we pass '' for processName
+            cmd += "'' " + appBundlePath
+        else:
+            cmd += processName + ' ' + appBundlePath
+
+        if destPath:
+            cmd += " " + destPath
+
+        if wait:
+            if not ipAddr:
+                ipAddr = moznetwork.get_ip()
+            serverSocket = self._getRebootServerSocket(ipAddr)
+            cmd += " %s %s" % serverSocket.getsockname()
+
+        self._logger.debug("updateApp using command: " % cmd)
+
+        self._runCmds([{'cmd': cmd}])
+
+        if wait:
+            self._waitForRebootPing(serverSocket)
+
+    def getCurrentTime(self):
+        return int(self._runCmds([{'cmd': 'clok'}]).strip())
+
+    def _formatEnvString(self, env):
+        """
+        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)
+        """
+        if (env is None or env == ''):
+            return ''
+
+        retVal = '"%s"' % ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems()))
+        if (retVal == '""'):
+            return ''
+
+        return retVal
+
+    def adjustResolution(self, width=1680, height=1050, type='hdmi'):
+        """
+        Adjust the screen resolution on the device, REBOOT REQUIRED
+
+        NOTE: this only works on a tegra ATM
+
+        supported resolutions: 640x480, 800x600, 1024x768, 1152x864, 1200x1024, 1440x900,
+        1680x1050, 1920x1080
+        """
+        if self.getInfo('os')['os'][0].split()[0] != 'harmony-eng':
+            self._logger.warning("unable to adjust screen resolution on non Tegra device")
+            return False
+
+        results = self.getInfo('screen')
+        parts = results['screen'][0].split(':')
+        self._logger.debug("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
+
+        self._logger.debug("adjusting screen resolution to %s, %s and rebooting" % (width, height))
+
+        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)}])
+
+    def chmodDir(self, remoteDir, **kwargs):
+        self._runCmds([{'cmd': "chmod " + remoteDir}])
--- a/testing/mozbase/mozdevice/mozdevice/dmcli.py
+++ b/testing/mozbase/mozdevice/mozdevice/dmcli.py
@@ -94,16 +94,19 @@ class DMCli(object):
                          'rmdir': {'function': self.rmdir,
                                    'args': [{'name': 'remote_dir'}],
                                    'help': 'recursively remove directory from device'
                                    },
                          'screencap': {'function': self.screencap,
                                        'args': [{'name': 'png_file'}],
                                        'help': 'capture screenshot of device in action'
                                        },
+                         'sutver': {'function': self.sutver,
+                                    'help': 'SUTAgent\'s product name and version (SUT only)'
+                                    },
                          'clearlogcat': {'function': self.clearlogcat,
                                          'help': 'clear the logcat'
                                          },
                          'reboot': {'function': self.reboot,
                                     'help': 'reboot the device',
                                     'args': [{'name': '--wait',
                                               'action': 'store_true',
                                               'help': 'Wait for device to come back up'
@@ -142,17 +145,21 @@ class DMCli(object):
         mozlog.commandline.add_logging_group(self.parser)
 
     def run(self, args=sys.argv[1:]):
         args = self.parser.parse_args()
 
         mozlog.commandline.setup_logging(
             'mozdevice', args, {'mach': sys.stdout})
 
-        self.dm = self.getDevice(hwid=args.hwid,
+        if args.dmtype == "sut" and not args.host and not args.hwid:
+            self.parser.error("Must specify device ip in TEST_DEVICE or "
+                              "with --host option with SUT")
+
+        self.dm = self.getDevice(dmtype=args.dmtype, hwid=args.hwid,
                                  host=args.host, port=args.port,
                                  verbose=args.verbose)
 
         ret = args.func(args)
         if ret is None:
             ret = 0
 
         sys.exit(ret)
@@ -163,18 +170,23 @@ class DMCli(object):
                             default=bool(os.environ.get('VERBOSE')))
         parser.add_argument("--host", action="store",
                             help="Device hostname (only if using TCP/IP, "
                             "defaults to TEST_DEVICE environment "
                             "variable if present)",
                             default=os.environ.get('TEST_DEVICE'))
         parser.add_argument("-p", "--port", action="store",
                             type=int,
-                            help="Custom device port (if using "
+                            help="Custom device port (if using SUTAgent or "
                             "adb-over-tcp)", default=None)
+        parser.add_argument("-m", "--dmtype", action="store",
+                            help="DeviceManager type (adb or sut, defaults "
+                            "to DM_TRANS environment variable, if "
+                            "present, or adb)",
+                            default=os.environ.get('DM_TRANS', 'adb'))
         parser.add_argument("-d", "--hwid", action="store",
                             help="HWID", default=None)
         parser.add_argument("--package-name", action="store",
                             help="Packagename (if using DeviceManagerADB)",
                             default=None)
 
     def add_commands(self, parser):
         subparsers = parser.add_subparsers(title="Commands", metavar="<command>")
@@ -188,30 +200,43 @@ class DMCli(object):
                     # kwargs = { k: v for k,v in arg.items() if k is not 'name' }
                     kwargs = {}
                     for (k, v) in arg.items():
                         if k is not 'name':
                             kwargs[k] = v
                     subparser.add_argument(arg['name'], **kwargs)
             subparser.set_defaults(func=commandprops['function'])
 
-    def getDevice(self, hwid=None, host=None, port=None,
+    def getDevice(self, dmtype="adb", hwid=None, host=None, port=None,
                   packagename=None, verbose=False):
         '''
         Returns a device with the specified parameters
         '''
         logLevel = logging.ERROR
         if verbose:
             logLevel = logging.DEBUG
 
-        if host and not port:
-            port = 5555
-        return mozdevice.DroidADB(packageName=packagename,
-                                  host=host, port=port,
-                                  logLevel=logLevel)
+        if hwid:
+            return mozdevice.DroidConnectByHWID(hwid, logLevel=logLevel)
+
+        if dmtype == "adb":
+            if host and not port:
+                port = 5555
+            return mozdevice.DroidADB(packageName=packagename,
+                                      host=host, port=port,
+                                      logLevel=logLevel)
+        elif dmtype == "sut":
+            if not host:
+                self.parser.error("Must specify host with SUT!")
+            if not port:
+                port = 20701
+            return mozdevice.DroidSUT(host=host, port=port,
+                                      logLevel=logLevel)
+        else:
+            self.parser.error("Unknown device manager type: %s" % type)
 
     def deviceroot(self, args):
         print self.dm.deviceRoot
 
     def push(self, args):
         (src, dest) = (args.local_file, args.remote_file)
         if os.path.isdir(src):
             self.dm.pushDir(src, dest)
@@ -309,16 +334,23 @@ class DMCli(object):
         self.dm.mkDir(args.remote_dir)
 
     def rmdir(self, args):
         self.dm.removeDir(args.remote_dir)
 
     def screencap(self, args):
         self.dm.saveScreenshot(args.png_file)
 
+    def sutver(self, args):
+        if args.dmtype == 'sut':
+            print '%s Version %s' % (self.dm.agentProductName,
+                                     self.dm.agentVersion)
+        else:
+            print 'Must use SUT transport to get SUT version.'
+
     def isfile(self, args):
         if self.dm.fileExists(args.remote_file):
             print "TRUE"
             return
         print "FALSE"
         return errno.ENOENT
 
     def launchfennec(self, args):
--- a/testing/mozbase/mozdevice/mozdevice/droid.py
+++ b/testing/mozbase/mozdevice/mozdevice/droid.py
@@ -1,19 +1,24 @@
 # 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 StringIO
+import moznetwork
 import re
+import threading
 import time
 
 import version_codes
 
+from Zeroconf import Zeroconf, ServiceBrowser
+from devicemanager import ZeroconfListener
 from devicemanagerADB import DeviceManagerADB
+from devicemanagerSUT import DeviceManagerSUT
 from devicemanager import DMError
 
 
 class DroidMixin(object):
     """Mixin to extend DeviceManager with Android-specific functionality"""
 
     _stopApplicationNeedsRoot = True
 
@@ -162,35 +167,98 @@ class DroidADB(DeviceManagerADB, DroidMi
             data = self.shellCheckOutput(
                 ["dumpsys", "window", "windows"], timeout=60)
         except:
             # dumpsys seems to intermittently fail (seen on 4.3 emulator), producing
             # no output.
             return ""
         # "dumpsys window windows" produces many lines of input. The top/foreground
         # activity is indicated by something like:
-        #   mFocusedApp=AppWindowToken{483e6db0 token=HistoryRecord{484dcad8 com.mozilla.something/.something}} # noqa
+        #   mFocusedApp=AppWindowToken{483e6db0 token=HistoryRecord{484dcad8 com.mozilla.SUTAgentAndroid/.SUTAgentAndroid}} # noqa
         # or, on other devices:
         #   FocusedApplication: name='AppWindowToken{41a65340 token=ActivityRecord{418fbd68 org.mozilla.fennec_mozdev/org.mozilla.gecko.BrowserApp}}', dispatchingTimeout=5000.000ms # noqa
         # Extract this line, ending in the forward slash:
         m = re.search('mFocusedApp(.+)/', data)
         if not m:
             m = re.search('FocusedApplication(.+)/', data)
         if m:
             line = m.group(0)
             # Extract package name: string of non-whitespace ending in forward slash
             m = re.search('(\S+)/$', line)
             if m:
                 package = m.group(1)
         if not package:
             # On some Android 4.4 devices, when the home screen is displayed,
             # dumpsys reports "mFocusedApp=null". Guard against this case and
             # others where the focused app can not be determined by returning
-            # an empty string.
+            # an empty string -- same as sutagent.
             package = ""
         return package
 
     def getAppRoot(self, packageName):
         """
         Returns the root directory for the specified android application
         """
         # relying on convention
         return '/data/data/%s' % packageName
+
+
+class DroidSUT(DeviceManagerSUT, DroidMixin):
+
+    def _getExtraAmStartArgs(self):
+        # in versions of android in jellybean and beyond, the agent may run as
+        # a different process than the one that started the app. In this case,
+        # we need to get back the original user serial number and then pass
+        # that to the 'am start' command line
+        if not hasattr(self, '_userSerial'):
+            infoDict = self.getInfo(directive="sutuserinfo")
+            if infoDict.get('sutuserinfo') and \
+                    len(infoDict['sutuserinfo']) > 0:
+                userSerialString = infoDict['sutuserinfo'][0]
+                # user serial always an integer, see:
+                # http://developer.android.com/reference/android/os/UserManager.html#getSerialNumberForUser%28android.os.UserHandle%29
+                m = re.match('User Serial:([0-9]+)', userSerialString)
+                if m:
+                    self._userSerial = m.group(1)
+                else:
+                    self._userSerial = None
+            else:
+                self._userSerial = None
+
+        if self._userSerial is not None:
+            return ["--user", self._userSerial]
+
+        return []
+
+    def getTopActivity(self):
+        return self._runCmds([{'cmd': "activity"}]).strip()
+
+    def getAppRoot(self, packageName):
+        return self._runCmds([{'cmd': 'getapproot %s' % packageName}]).strip()
+
+
+def DroidConnectByHWID(hwid, timeout=30, **kwargs):
+    """Try to connect to the given device by waiting for it to show up using
+    mDNS with the given timeout."""
+    zc = Zeroconf(moznetwork.get_ip())
+
+    evt = threading.Event()
+    listener = ZeroconfListener(hwid, evt)
+    sb = ServiceBrowser(zc, "_sutagent._tcp.local.", listener)
+    foundIP = None
+    if evt.wait(timeout):
+        # we found the hwid
+        foundIP = listener.ip
+    sb.cancel()
+    zc.close()
+
+    if foundIP is not None:
+        return DroidSUT(foundIP, **kwargs)
+    print "Connected via SUT to %s [at %s]" % (hwid, foundIP)
+
+    # try connecting via adb
+    try:
+        sut = DroidADB(deviceSerial=hwid, **kwargs)
+    except:
+        return None
+
+    print "Connected via ADB to %s" % (hwid)
+    return sut
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/mozdevice/sutini.py
@@ -0,0 +1,126 @@
+# 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 ConfigParser
+import StringIO
+import os
+import sys
+import tempfile
+
+from mozdevice.droid import DroidSUT
+from mozdevice.devicemanager import DMError
+
+USAGE = '%s <host>'
+INI_PATH_JAVA = '/data/data/com.mozilla.SUTAgentAndroid/files/SUTAgent.ini'
+INI_PATH_NEGATUS = '/data/local/SUTAgent.ini'
+SCHEMA = {'Registration Server': (('IPAddr', ''),
+                                  ('PORT', '28001'),
+                                  ('HARDWARE', ''),
+                                  ('POOL', '')),
+          'Network Settings': (('SSID', ''),
+                               ('AUTH', ''),
+                               ('ENCR', ''),
+                               ('EAP', ''))}
+
+
+def get_cfg(d, ini_path):
+    cfg = ConfigParser.RawConfigParser()
+    try:
+        cfg.readfp(StringIO.StringIO(d.pullFile(ini_path)), 'SUTAgent.ini')
+    except DMError:
+        # assume this is due to a missing file...
+        pass
+    return cfg
+
+
+def put_cfg(d, cfg, ini_path):
+    print 'Writing modified SUTAgent.ini...'
+    t = tempfile.NamedTemporaryFile(delete=False)
+    cfg.write(t)
+    t.close()
+    try:
+        d.pushFile(t.name, ini_path)
+    except DMError, e:
+        print e
+    else:
+        print 'Done.'
+    finally:
+        os.unlink(t.name)
+
+
+def set_opt(cfg, s, o, dflt):
+    prompt = '  %s' % o
+    try:
+        curval = cfg.get(s, o)
+    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+        curval = ''
+    if curval:
+        dflt = curval
+    prompt += ': '
+    if dflt:
+        prompt += '[%s] ' % dflt
+    newval = raw_input(prompt)
+    if not newval:
+        newval = dflt
+    if newval == curval:
+        return False
+    cfg.set(s, o, newval)
+    return True
+
+
+def bool_query(prompt, dflt):
+    while True:
+        i = raw_input('%s [%s] ' % (prompt, 'y' if dflt else 'n')).lower()
+        if not i or i[0] in ('y', 'n'):
+            break
+        print 'Enter y or n.'
+    return (not i and dflt) or (i and i[0] == 'y')
+
+
+def edit_sect(cfg, sect, opts):
+    changed_vals = False
+    if bool_query('Edit section %s?' % sect, False):
+        if not cfg.has_section(sect):
+            cfg.add_section(sect)
+        print '%s settings:' % sect
+        for opt, dflt in opts:
+            changed_vals |= set_opt(cfg, sect, opt, dflt)
+        print
+    else:
+        if cfg.has_section(sect) and bool_query('Delete section %s?' % sect,
+                                                False):
+            cfg.remove_section(sect)
+            changed_vals = True
+    return changed_vals
+
+
+def main():
+    try:
+        host = sys.argv[1]
+    except IndexError:
+        print USAGE % sys.argv[0]
+        sys.exit(1)
+    try:
+        d = DroidSUT(host, retryLimit=1)
+    except DMError, e:
+        print e
+        sys.exit(1)
+    # check if using Negatus and change path accordingly
+    ini_path = INI_PATH_JAVA
+    if 'Negatus' in d.agentProductName:
+        ini_path = INI_PATH_NEGATUS
+    cfg = get_cfg(d, ini_path)
+    if not cfg.sections():
+        print 'Empty or missing ini file.'
+    changed_vals = False
+    for sect, opts in SCHEMA.iteritems():
+        changed_vals |= edit_sect(cfg, sect, opts)
+    if changed_vals:
+        put_cfg(d, cfg, ini_path)
+    else:
+        print 'No changes.'
+
+
+if __name__ == '__main__':
+    main()
--- a/testing/mozbase/mozdevice/setup.py
+++ b/testing/mozbase/mozdevice/setup.py
@@ -26,10 +26,11 @@ setup(name=PACKAGE_NAME,
       packages=['mozdevice'],
       include_package_data=True,
       zip_safe=False,
       install_requires=deps,
       entry_points="""
       # -*- Entry points: -*-
       [console_scripts]
       dm = mozdevice.dmcli:cli
+      sutini = mozdevice.sutini:main
       """,
       )
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 the `setup-tools.sh` script
+to install them. It requires `$ADB` to point to the `adb` binary on the system.
+
+* Make sure the SUTAgent on the device is running.
+
+* Run: python runtests.py
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/dmunit.py
@@ -0,0 +1,55 @@
+# 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 logging
+import types
+import unittest
+
+from mozdevice import devicemanager
+from mozdevice import devicemanagerSUT
+
+ip = ''
+port = 0
+heartbeat_port = 0
+log_level = logging.ERROR
+
+
+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,
+                                                    logLevel=log_level)
+        self.dmerror = devicemanager.DMError
+        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,96 @@
+# 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 logging
+import os
+import re
+import sys
+import unittest
+
+import dmunit
+import genfiles
+
+
+def main(ip, port, heartbeat_port, scripts, directory, isTestDevice, verbose):
+    dmunit.ip = ip
+    dmunit.port = port
+    dmunit.heartbeat_port = heartbeat_port
+    if verbose:
+        dmunit.log_level = logging.DEBUG
+
+    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("--heartbeat", action="store", type="int",
+                      dest="heartbeat_port", help="Port for heartbeat/data "
+                      "channel, defaults to 20700", default=20700)
+
+    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)
+
+    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
+                      help="Verbose DeviceManager output", default=False)
+
+    (options, args) = parser.parse_args()
+
+    main(options.ip, options.port, options.heartbeat_port, options.scripts,
+         options.dir, options.isTestDevice, options.verbose)
new file mode 100755
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/setup-tools.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ ! -f busybox-armv6l ]
+then
+    wget http://busybox.net/downloads/binaries/1.19.0/busybox-armv6l
+fi
+$ADB remount
+$ADB push busybox-armv6l /system/bin/busybox
+
+$ADB shell 'cd /system/bin; chmod 555 busybox; for x in `./busybox --list`; do ln -s ./busybox $x; done'
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test-files/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-files/test_script.sh
@@ -0,0 +1,1 @@
+echo $THE_ANSWER
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_datachannel.py
@@ -0,0 +1,53 @@
+# 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 time import strptime
+
+from dmunit import DeviceManagerTestCase, heartbeat_port
+
+
+class DataChannelTestCase(DeviceManagerTestCase):
+
+    runs_on_test_device = False
+
+    def runTest(self):
+        """This tests the heartbeat and the data channel.
+        """
+        ip = self.dm.host
+
+        # 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, heartbeat_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))
+                capturedHeader = True
+
+            # Check for standard heartbeat messsage
+            m = re.match(r"(.*?) Thump thump - (.*)", data)
+            if m is 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")
+            numbeats = numbeats + 1
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_exec.py
@@ -0,0 +1,24 @@
+# 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 posixpath
+from StringIO import StringIO
+
+from dmunit import DeviceManagerTestCase
+
+
+class ExecTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """Simple exec test, does not use env vars."""
+        out = StringIO()
+        filename = posixpath.join(self.dm.deviceRoot, 'test_exec_file')
+        # Make sure the file was not already there
+        self.dm.removeFile(filename)
+        self.dm.shell(['dd', 'if=/dev/zero', 'of=%s' % filename, 'bs=1024',
+                       'count=1'], out)
+        # Check that the file has been created
+        self.assertTrue(self.dm.fileExists(filename))
+        # Clean up
+        self.dm.removeFile(filename)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_exec_env.py
@@ -0,0 +1,32 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+import posixpath
+from StringIO import StringIO
+
+from dmunit import DeviceManagerTestCase
+
+
+class ExecEnvTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """Exec test with env vars."""
+        # Push the file
+        localfile = os.path.join('test-files', 'test_script.sh')
+        remotefile = posixpath.join(self.dm.deviceRoot, 'test_script.sh')
+        self.dm.pushFile(localfile, remotefile)
+
+        # Run the cmd
+        out = StringIO()
+        self.dm.shell(['sh', remotefile], out, env={'THE_ANSWER': 42})
+
+        # Rewind the output file
+        out.seek(0)
+        # Make sure first line is 42
+        line = out.readline()
+        self.assertTrue(int(line) == 42)
+
+        # Clean up
+        self.dm.removeFile(remotefile)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_fileExists.py
@@ -0,0 +1,37 @@
+# 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 tempfile
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class FileExistsTestCase(DeviceManagerTestCase):
+    """This tests the "fileExists" command.
+    """
+
+    def testOnRoot(self):
+        self.assertTrue(self.dm.fileExists('/'))
+
+    def testOnNonexistent(self):
+        self.assertFalse(self.dm.fileExists('/doesNotExist'))
+
+    def testOnRegularFile(self):
+        remote_path = posixpath.join(self.dm.deviceRoot, 'testFile')
+        self.assertFalse(self.dm.fileExists(remote_path))
+        with tempfile.NamedTemporaryFile() as f:
+            self.dm.pushFile(f.name, remote_path)
+        self.assertTrue(self.dm.fileExists(remote_path))
+        self.dm.removeFile(remote_path)
+
+    def testOnDirectory(self):
+        remote_path = posixpath.join(self.dm.deviceRoot, 'testDir')
+        remote_path_file = posixpath.join(remote_path, 'testFile')
+        self.assertFalse(self.dm.fileExists(remote_path))
+        with tempfile.NamedTemporaryFile() as f:
+            self.dm.pushFile(f.name, remote_path_file)
+        self.assertTrue(self.dm.fileExists(remote_path))
+        self.dm.removeFile(remote_path_file)
+        self.dm.removeDir(remote_path)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_getdir.py
@@ -0,0 +1,51 @@
+# 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 mozdevice.devicemanager import DMError
+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.deviceRoot, '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'))
+        self.dm.getDirectory(posixpath.join(testroot, 'push1'),
+                             os.path.join(self.localdestdir, 'push1'))
+        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')))
+        self.assertRaises(DMError, self.dm.getDirectory,
+                          '/dummy', os.path.join(self.localdestdir, '/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,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/.
+
+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')
+        for c in cmds:
+            data = self.dm.getInfo(c)
+            print c + 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_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.assertTrue(promptre.match(data))
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_ps.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/.
+
+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>], ...]
+
+        self.assertNotEqual(len(proclist), 0)
+
+        for item in proclist:
+            self.assertIsInstance(item[0], int)
+            self.assertIsInstance(item[1], str)
+            self.assertGreater(len(item[1]), 0)
+            if len(item) > 2:
+                self.assertIsInstance(item[2], int)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_pull.py
@@ -0,0 +1,34 @@
+# 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
+from mozdevice.devicemanager import DMError
+
+
+class PullTestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """Tests the "pull" command with a binary file.
+        """
+        orig = hashlib.md5()
+        new = hashlib.md5()
+        local_test_file = os.path.join('test-files', 'mybinary.zip')
+        orig.update(file(local_test_file, 'r').read())
+
+        testroot = self.dm.deviceRoot
+        remote_test_file = posixpath.join(testroot, 'mybinary.zip')
+        self.dm.removeFile(remote_test_file)
+        self.dm.pushFile(local_test_file, remote_test_file)
+        new.update(self.dm.pullFile(remote_test_file))
+        # Use hexdigest() instead of digest() since values are printed
+        # if assert fails
+        self.assertEqual(orig.hexdigest(), new.hexdigest())
+
+        remote_missing_file = posixpath.join(testroot, 'doesnotexist')
+        self.dm.removeFile(remote_missing_file)  # Just to be sure
+        self.assertRaises(DMError, self.dm.pullFile, remote_missing_file)
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/sut_tests/test_push1.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
+import posixpath
+
+from dmunit import DeviceManagerTestCase
+
+
+class Push1TestCase(DeviceManagerTestCase):
+
+    def runTest(self):
+        """This tests copying a directory structure to the device.
+        """
+        dvroot = self.dm.deviceRoot
+        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()
+
+        self.dm.pushDir(p1, posixpath.join(dvpath, 'push1'))
+
+        self.assertTrue(
+            self.dm.dirExists(posixpath.join(dvpath, 'push1', 'sub.1')))
+        self.assertTrue(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.deviceRoot, '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.assertTrue(
+            self.dm.dirExists(posixpath.join(testroot, 'push2', 'sub1')))
+        self.assertTrue(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub1', 'file1.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'file1.txt')))
+        self.assertTrue(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub1', 'sub1.1', 'file2.txt'),
+            os.path.join('test-files', 'push2', 'sub1', 'sub1.1', 'file2.txt')))
+        self.assertTrue(self.dm.validateFile(
+            posixpath.join(testroot, 'push2', 'sub2', 'file3.txt'),
+            os.path.join('test-files', 'push2', 'sub2', 'file3.txt')))
+        self.assertTrue(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,19 @@
+# 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.deviceRoot
+        self.dm.removeFile(posixpath.join(testroot, 'mybinary.zip'))
+        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,19 @@
+# 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.deviceRoot
+        self.dm.removeFile(posixpath.join(testroot, 'smalltext.txt'))
+        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/tests/droidsut_launch.py
@@ -0,0 +1,38 @@
+from sut import MockAgent
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+
+class LaunchTest(unittest.TestCase):
+
+    def test_nouserserial(self):
+        a = MockAgent(self, commands=[("ps",
+                                       "10029	549	com.android.launcher\n"
+                                       "10066	1198	com.twitter.android"),
+                                      ("info sutuserinfo", ""),
+                                      ("exec am start -W -n "
+                                       "org.mozilla.fennec/org.mozilla.gecko.BrowserApp -a "
+                                       "android.intent.action.VIEW",
+                                       "OK\nreturn code [0]")])
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+        d.launchFennec("org.mozilla.fennec")
+        a.wait()
+
+    def test_userserial(self):
+        a = MockAgent(self, commands=[("ps",
+                                       "10029	549	com.android.launcher\n"
+                                       "10066	1198	com.twitter.android"),
+                                      ("info sutuserinfo", "User Serial:0"),
+                                      ("exec am start --user 0 -W -n "
+                                       "org.mozilla.fennec/org.mozilla.gecko.BrowserApp -a "
+                                       "android.intent.action.VIEW",
+                                       "OK\nreturn code [0]")])
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+        d.launchFennec("org.mozilla.fennec")
+        a.wait()
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/manifest.ini
@@ -0,0 +1,24 @@
+[DEFAULT]
+skip-if = os == 'win'
+subsuite = mozbase, os == "linux"
+
+[sut_app.py]
+[sut_basic.py]
+[sut_chmod.py]
+[sut_copytree.py]
+[sut_fileExists.py]
+[sut_fileMethods.py]
+[sut_info.py]
+[sut_ip.py]
+[sut_kill.py]
+[sut_list.py]
+[sut_logcat.py]
+[sut_mkdir.py]
+[sut_movetree.py]
+[sut_ps.py]
+[sut_push.py]
+[sut_pull.py]
+[sut_remove.py]
+[sut_time.py]
+[sut_unpackfile.py]
+[droidsut_launch.py]
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+import datetime
+import socket
+import time
+
+from threading import Thread
+
+
+class MockAgent(object):
+
+    MAX_WAIT_TIME_SECONDS = 10
+    SOCKET_TIMEOUT_SECONDS = 5
+
+    def __init__(self, tester, start_commands=None, commands=[]):
+        if start_commands:
+            self.commands = start_commands
+        else:
+            self.commands = [("ver", "SUTAgentAndroid Version 1.14")]
+        self.commands = self.commands + commands
+
+        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self._sock.bind(("127.0.0.1", 0))
+        self._sock.listen(1)
+
+        self.tester = tester
+
+        self.thread = Thread(target=self._serve_thread)
+        self.thread.start()
+
+        self.should_stop = False
+
+    @property
+    def port(self):
+        return self._sock.getsockname()[1]
+
+    def _serve_thread(self):
+        conn = None
+        while self.commands:
+            if not conn:
+                conn, addr = self._sock.accept()
+                conn.settimeout(self.SOCKET_TIMEOUT_SECONDS)
+                conn.send("$>\x00")
+            (command, response) = self.commands.pop(0)
+            data = ''
+            timeout = datetime.datetime.now() + datetime.timedelta(
+                seconds=self.MAX_WAIT_TIME_SECONDS)
+            # The data might come in chunks, particularly if we are expecting
+            # multiple lines, as with push commands.
+            while (len(data) < len(command) and
+                   datetime.datetime.now() < timeout):
+                try:
+                    data += conn.recv(1024)
+                except socket.timeout:
+                    # We handle timeouts in the main loop.
+                    pass
+            self.tester.assertEqual(data.strip(), command)
+            # send response and prompt separately to test for bug 789496
+            # FIXME: Improve the mock agent, since overloading the meaning
+            # of 'response' is getting confusing.
+            if response is None:  # code for "shut down"
+                conn.shutdown(socket.SHUT_RDWR)
+                conn.close()
+                conn = None
+            elif type(response) is int:  # code for "time out"
+                max_timeout = 15.0
+                timeout = 0.0
+                interval = 0.1
+                while not self.should_stop and timeout < max_timeout:
+                    time.sleep(interval)
+                    timeout += interval
+                if timeout >= max_timeout:
+                    raise Exception("Maximum timeout reached! This should not "
+                                    "happen")
+                return
+            else:
+                # pull is handled specially, as we just pass back the full
+                # command line
+                if "pull" in command:
+                    conn.send(response)
+                else:
+                    conn.send("%s\n" % response)
+                conn.send("$>\x00")
+
+    def wait(self):
+        self.thread.join()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_app.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestApp(unittest.TestCase):
+
+    def test_getAppRoot(self):
+        command = [("getapproot org.mozilla.firefox",
+                    "/data/data/org.mozilla.firefox")]
+
+        m = MockAgent(self, commands=command)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+
+        self.assertEqual(command[0][1], d.getAppRoot('org.mozilla.firefox'))
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_basic.py
@@ -0,0 +1,75 @@
+from sut import MockAgent
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+
+class BasicTest(unittest.TestCase):
+
+    def test_init(self):
+        """Tests DeviceManager initialization."""
+        a = MockAgent(self)
+
+        mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+        # all testing done in device's constructor
+        a.wait()
+
+    def test_init_err(self):
+        """Tests error handling during initialization."""
+        a = MockAgent(self, start_commands=[("ver", "##AGENT-WARNING## No version")])
+        self.assertRaises(mozdevice.DMError,
+                          lambda: mozdevice.DroidSUT("127.0.0.1",
+                                                     port=a.port,
+                                                     logLevel=logging.DEBUG))
+        a.wait()
+
+    def test_timeout_normal(self):
+        """Tests DeviceManager timeout, normal case."""
+        a = MockAgent(self, commands=[("isdir /mnt/sdcard/tests", "TRUE"),
+                                      ("cd /mnt/sdcard/tests", ""),
+                                      ("ls", "test.txt"),
+                                      ("rm /mnt/sdcard/tests/test.txt",
+                                       "Removed the file")])
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+        ret = d.removeFile('/mnt/sdcard/tests/test.txt')
+        self.assertEqual(ret, None)  # if we didn't throw an exception, we're ok
+        a.wait()
+
+    def test_timeout_timeout(self):
+        """Tests DeviceManager timeout, timeout case."""
+        a = MockAgent(self, commands=[("isdir /mnt/sdcard/tests", "TRUE"),
+                                      ("cd /mnt/sdcard/tests", ""),
+                                      ("ls", "test.txt"),
+                                      ("rm /mnt/sdcard/tests/test.txt", 0)])
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+        d.default_timeout = 1
+        exceptionThrown = False
+        try:
+            d.removeFile('/mnt/sdcard/tests/test.txt')
+        except mozdevice.DMError:
+            exceptionThrown = True
+        self.assertEqual(exceptionThrown, True)
+        a.should_stop = True
+        a.wait()
+
+    def test_shell(self):
+        """Tests shell command"""
+        for cmd in [("exec foobar", False), ("execsu foobar", True)]:
+            for retcode in [1, 2]:
+                a = MockAgent(self, commands=[(cmd[0],
+                                               "\nreturn code [%s]" % retcode)])
+                d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+                exceptionThrown = False
+                try:
+                    d.shellCheckOutput(["foobar"], root=cmd[1])
+                except mozdevice.DMError:
+                    exceptionThrown = True
+                expectedException = (retcode != 0)
+                self.assertEqual(exceptionThrown, expectedException)
+
+                a.wait()
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_chmod.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestChmod(unittest.TestCase):
+
+    def test_chmod(self):
+
+        command = [('chmod /mnt/sdcard/test',
+                    'Changing permissions for /storage/emulated/legacy/Test\n'
+                    '        <empty>\n'
+                    'chmod /storage/emulated/legacy/Test ok\n')]
+        m = MockAgent(self, commands=command)
+        d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=logging.DEBUG)
+
+        self.assertEqual(None, d.chmodDir('/mnt/sdcard/test'))
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_copytree.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# 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 mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class CopyTreeTest(unittest.TestCase):
+
+    def test_copyFile(self):
+        commands = [('dd if=/mnt/sdcard/tests/test.txt of=/mnt/sdcard/tests/test2.txt', ''),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'test.txt\ntest2.txt')]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+
+        self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/test.txt',
+                                          '/mnt/sdcard/tests/test2.txt'))
+        expected = (commands[3][1].strip()).split('\n')
+        self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests'))
+
+    def test_copyDir(self):
+        commands = [('dd if=/mnt/sdcard/tests/foo of=/mnt/sdcard/tests/bar', ''),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'foo\nbar')]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
+                               logLevel=logging.DEBUG)
+
+        self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/foo',
+                                          '/mnt/sdcard/tests/bar'))
+        expected = (commands[3][1].strip()).split('\n')
+        self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests'))
+
+    def test_copyNonEmptyDir(self):
+        commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'),
+                    ('dd if=/mnt/sdcard/tests/foo of=/mnt/sdcard/tests/foo2', ''),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'foo\nfoo2'),
+                    ('isdir /mnt/sdcard/tests/foo2', 'TRUE'),
+                    ('cd /mnt/sdcard/tests/foo2', ''),
+                    ('ls', 'bar')]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
+                               logLevel=logging.DEBUG)
+
+        self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar'))
+        self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/foo',
+                                          '/mnt/sdcard/tests/foo2'))
+        expected = (commands[4][1].strip()).split('\n')
+        self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests'))
+        self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar'))
+
+if __name__ == "__main__":
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_fileExists.py
@@ -0,0 +1,32 @@
+import unittest
+
+import mozunit
+
+import mozdevice
+from sut import MockAgent
+
+
+class FileExistsTest(unittest.TestCase):
+
+    commands = [('isdir /', 'TRUE'),
+                ('cd /', ''),
+                ('ls', 'init')]
+
+    def test_onRoot(self):
+        root_commands = [('isdir /', 'TRUE')]
+        a = MockAgent(self, commands=root_commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+        self.assertTrue(d.fileExists('/'))
+
+    def test_onNonexistent(self):
+        a = MockAgent(self, commands=self.commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+        self.assertFalse(d.fileExists('/doesNotExist'))
+
+    def test_onRegularFile(self):
+        a = MockAgent(self, commands=self.commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+        self.assertTrue(d.fileExists('/init'))
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_fileMethods.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+import hashlib
+import mozdevice
+import logging
+import shutil
+import tempfile
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestFileMethods(unittest.TestCase):
+    """ Class to test misc file methods """
+
+    content = "What is the answer to the life, universe and everything? 42"
+    h = hashlib.md5()
+    h.update(content)
+    temp_hash = h.hexdigest()
+
+    def test_validateFile(self):
+
+        with tempfile.NamedTemporaryFile() as f:
+            f.write(self.content)
+            f.flush()
+
+            # Test Valid Hashes
+            commands_valid = [("hash /sdcard/test/file", self.temp_hash)]
+
+            m = MockAgent(self, commands=commands_valid)
+            d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+            self.assertTrue(d.validateFile('/sdcard/test/file', f.name))
+
+            # Test invalid hashes
+            commands_invalid = [("hash /sdcard/test/file", "0this0hash0is0completely0invalid")]
+
+            m = MockAgent(self, commands=commands_invalid)
+            d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+            self.assertFalse(d.validateFile('/sdcard/test/file', f.name))
+
+    def test_getFile(self):
+
+        fname = "/mnt/sdcard/file"
+        commands = [("pull %s" % fname, "%s,%s\n%s" % (fname, len(self.content), self.content)),
+                    ("hash %s" % fname, self.temp_hash)]
+
+        with tempfile.NamedTemporaryFile() as f:
+            m = MockAgent(self, commands=commands)
+            d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+            # No error means success
+            self.assertEqual(None, d.getFile(fname, f.name))
+
+    def test_getDirectory(self):
+
+        fname = "/mnt/sdcard/file"
+        commands = [("isdir /mnt/sdcard", "TRUE"),
+                    ("isdir /mnt/sdcard", "TRUE"),
+                    ("cd /mnt/sdcard", ""),
+                    ("ls", "file"),
+                    ("isdir %s" % fname, "FALSE"),
+                    ("pull %s" % fname, "%s,%s\n%s" % (fname, len(self.content), self.content)),
+                    ("hash %s" % fname, self.temp_hash)]
+
+        tmpdir = tempfile.mkdtemp()
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual(None, d.getDirectory("/mnt/sdcard", tmpdir))
+
+        # Cleanup
+        shutil.rmtree(tmpdir)
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_info.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import re
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestGetInfo(unittest.TestCase):
+
+    commands = {'os': ('info os', 'JDQ39'),
+                'id': ('info id', '11:22:33:44:55:66'),
+                'uptime': ('info uptime', '0 days 0 hours 7 minutes 0 seconds 0 ms'),
+                'uptimemillis': ('info uptimemillis', '666'),
+                'systime': ('info systime', '2013/04/2 12:42:00:007'),
+                'screen': ('info screen', 'X:768 Y:1184'),
+                'rotation': ('info rotation', 'ROTATION:0'),
+                'memory': ('info memory', 'PA:1351032832, FREE: 878645248'),
+                'process': ('info process', '1000    527     system\n'
+                            '10091   3443    org.mozilla.firefox\n'
+                            '10112   3137    com.mozilla.SUTAgentAndroid\n'
+                            '10035   807     com.android.launcher'),
+                'disk': ('info disk', '/data: 6084923392 total, 980922368 available\n'
+                         '/system: 867999744 total, 332333056 available\n'
+                         '/mnt/sdcard: 6084923392 total, 980922368 available'),
+                'power': ('info power', 'Power status:\n'
+                          '  AC power OFFLINE\n'
+                          '  Battery charge LOW DISCHARGING\n'
+                          '  Remaining charge:      20%\n'
+                          '  Battery Temperature:   25.2 (c)'),
+                'sutuserinfo': ('info sutuserinfo', 'User Serial:0'),
+                'temperature': ('info temperature', 'Temperature: unknown')
+                }
+
+    def test_getInfo(self):
+
+        for directive in self.commands.keys():
+            m = MockAgent(self, commands=[self.commands[directive]])
+            d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=logging.DEBUG)
+
+            expected = re.sub(r'\ +', ' ', self.commands[directive][1]).split('\n')
+            # Account for slightly different return format for 'process'
+            if directive is 'process':
+                expected = [[x] for x in expected]
+
+            self.assertEqual(d.getInfo(directive=directive)[directive], expected)
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_ip.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestGetIP(unittest.TestCase):
+    """ class to test IP methods """
+
+    commands = [('exec ifconfig eth0', 'eth0: ip 192.168.0.1 '
+                 'mask 255.255.255.0 flags [up broadcast running multicast]\n'
+                 'return code [0]'),
+                ('exec ifconfig wlan0', 'wlan0: ip 10.1.39.126\n'
+                 'mask 255.255.0.0 flags [up broadcast running multicast]\n'
+                 'return code [0]'),
+                ('exec ifconfig fake0', '##AGENT-WARNING## [ifconfig] '
+                 'command with arg(s) = [fake0] is currently not implemented.')
+                ]
+
+    def test_getIP_eth0(self):
+        m = MockAgent(self, commands=[self.commands[0]])
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual('192.168.0.1', d.getIP(interfaces=['eth0']))
+
+    def test_getIP_wlan0(self):
+        m = MockAgent(self, commands=[self.commands[1]])
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual('10.1.39.126', d.getIP(interfaces=['wlan0']))
+
+    def test_getIP_error(self):
+        m = MockAgent(self, commands=[self.commands[2]])
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertRaises(mozdevice.DMError, d.getIP, interfaces=['fake0'])
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_kill.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestKill(unittest.TestCase):
+
+    def test_killprocess(self):
+        commands = [("ps", "1000    1486    com.android.settings\n"
+                           "10016   420 com.android.location.fused\n"
+                           "10023   335 com.android.systemui\n"),
+                    ("kill com.android.settings",
+                     "Successfully killed com.android.settings\n")]
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        # No error raised means success
+        self.assertEqual(None,  d.killProcess("com.android.settings"))
+
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_list.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestListFiles(unittest.TestCase):
+    commands = [("isdir /mnt/sdcard", "TRUE"),
+                ("cd /mnt/sdcard", ""),
+                ("ls", "Android\nMusic\nPodcasts\nRingtones\nAlarms\n"
+                       "Notifications\nPictures\nMovies\nDownload\nDCIM\n")]
+
+    def test_listFiles(self):
+        m = MockAgent(self, commands=self.commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+
+        expected = (self.commands[2][1].strip()).split("\n")
+        self.assertEqual(expected, d.listFiles("/mnt/sdcard"))
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_logcat.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestLogCat(unittest.TestCase):
+    """ Class to test methods associated with logcat """
+
+    def test_getLogcat(self):
+
+        logcat_output = (
+            "07-17 00:51:10.377 I/SUTAgentAndroid( 2933): onCreate\r\n"
+            "07-17 00:51:10.457 D/dalvikvm( 2933): GC_CONCURRENT freed 351K, 17% free 2523K/3008K, paused 5ms+2ms, total 38ms\r\n"  # noqa
+            "07-17 00:51:10.497 I/SUTAgentAndroid( 2933): Caught exception creating file in /data/local/tmp: open failed: EACCES (Permission denied)\r\n"  # noqa
+            "07-17 00:51:10.507 E/SUTAgentAndroid( 2933): ERROR: Cannot access world writeable test root\r\n"  # noqa
+            "07-17 00:51:10.547 D/GeckoHealthRec( 3253): Initializing profile cache.\r\n"
+            "07-17 00:51:10.607 D/GeckoHealthRec( 3253): Looking for /data/data/org.mozilla.fennec/files/mozilla/c09kfhne.default/times.json\r\n"  # noqa
+            "07-17 00:51:10.637 D/GeckoHealthRec( 3253): Using times.json for profile creation time.\r\n"  # noqa
+            "07-17 00:51:10.707 D/GeckoHealthRec( 3253): Incorporating environment: times.json profile creation = 1374026758604\r\n"  # noqa
+            "07-17 00:51:10.507 D/GeckoHealthRec( 3253): Requested prefs.\r\n"
+            "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): \r\n"
+            "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Private Dirty Memory         3176 kb\r\n"  # noqa
+            "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Proportional Set Size Memory 5679 kb\r\n"  # noqa
+            "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Shared Dirty Memory          9216 kb\r\n"  # noqa
+            "07-17 06:55:21.627 I/SUTAgentAndroid( 3876): 127.0.0.1 : execsu /system/bin/logcat -v time -d dalvikvm:I "  # noqa
+            "ConnectivityService:S WifiMonitor:S WifiStateTracker:S wpa_supplicant:S NetworkStateTracker:S\r\n"  # noqa
+            "07-17 06:55:21.827 I/dalvikvm-heap( 3876): Grow heap (frag case) to 3.019MB for 102496-byte allocation\r\n"  # noqa
+            "return code [0]")
+
+        inp = ("execsu /system/bin/logcat -v time -d "
+               "dalvikvm:I ConnectivityService:S WifiMonitor:S "
+               "WifiStateTracker:S wpa_supplicant:S NetworkStateTracker:S")
+
+        commands = [(inp, logcat_output)]
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual(logcat_output[:-17].replace('\r\n', '\n').splitlines(True), d.getLogcat())
+
+    def test_recordLogcat(self):
+
+        commands = [("execsu /system/bin/logcat -c", "return code [0]")]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        # No error raised means success
+        self.assertEqual(None, d.recordLogcat())
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_mkdir.py
@@ -0,0 +1,81 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class MkDirsTest(unittest.TestCase):
+
+    def test_mkdirs(self):
+        subTests = [{'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'),
+                              ('info os', 'android'),
+                              ('isdir /mnt', 'TRUE'),
+                              ('isdir /mnt/sdcard', 'TRUE'),
+                              ('isdir /mnt/sdcard/baz', 'FALSE'),
+                              ('mkdr /mnt/sdcard/baz',
+                               '/mnt/sdcard/baz successfully created'),
+                              ('isdir /mnt/sdcard/baz/boop', 'FALSE'),
+                              ('mkdr /mnt/sdcard/baz/boop',
+                               '/mnt/sdcard/baz/boop successfully created')],
+                     'expectException': False},
+                    {'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'),
+                              ('info os', 'android'),
+                              ('isdir /mnt', 'TRUE'),
+                              ('isdir /mnt/sdcard', 'TRUE'),
+                              ('isdir /mnt/sdcard/baz', 'FALSE'),
+                              ('mkdr /mnt/sdcard/baz',
+                               "##AGENT-WARNING## "
+                               "Could not create the directory /mnt/sdcard/baz")],
+                     'expectException': True},
+                    ]
+        for subTest in subTests:
+            a = MockAgent(self, commands=subTest['cmds'])
+
+            exceptionThrown = False
+            try:
+                d = mozdevice.DroidSUT('127.0.0.1', port=a.port,
+                                       logLevel=logging.DEBUG)
+                d.mkDirs('/mnt/sdcard/baz/boop/bip')
+            except mozdevice.DMError:
+                exceptionThrown = True
+            self.assertEqual(exceptionThrown, subTest['expectException'])
+
+            a.wait()
+
+    def test_repeated_path_part(self):
+        """
+        Ensure that all dirs are created when last path part also found
+        earlier in the path (bug 826492).
+        """
+
+        cmds = [('isdir /mnt/sdcard/foo', 'FALSE'),
+                ('info os', 'android'),
+                ('isdir /mnt', 'TRUE'),
+                ('isdir /mnt/sdcard', 'TRUE'),
+                ('isdir /mnt/sdcard/foo', 'FALSE'),
+                ('mkdr /mnt/sdcard/foo',
+                 '/mnt/sdcard/foo successfully created')]
+        a = MockAgent(self, commands=cmds)
+        d = mozdevice.DroidSUT('127.0.0.1', port=a.port,
+                               logLevel=logging.DEBUG)
+        d.mkDirs('/mnt/sdcard/foo/foo')
+        a.wait()
+
+    def test_mkdirs_on_root(self):
+        cmds = [('isdir /', 'TRUE')]
+        a = MockAgent(self, commands=cmds)
+        d = mozdevice.DroidSUT('127.0.0.1', port=a.port,
+                               logLevel=logging.DEBUG)
+        d.mkDirs('/foo')
+
+        a.wait()
+
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_movetree.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# 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 mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class MoveTreeTest(unittest.TestCase):
+
+    def test_moveFile(self):
+        commands = [('mv /mnt/sdcard/tests/test.txt /mnt/sdcard/tests/test1.txt', ''),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'test1.txt'),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'test1.txt')]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/test.txt',
+                                          '/mnt/sdcard/tests/test1.txt'))
+        self.assertFalse(d.fileExists('/mnt/sdcard/tests/test.txt'))
+        self.assertTrue(d.fileExists('/mnt/sdcard/tests/test1.txt'))
+
+    def test_moveDir(self):
+        commands = [("mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/bar", ""),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'bar')]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
+                                          '/mnt/sdcard/tests/bar'))
+        self.assertTrue(d.fileExists('/mnt/sdcard/tests/bar'))
+
+    def test_moveNonEmptyDir(self):
+        commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'),
+                    ('mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/foo2', ''),
+                    ('isdir /mnt/sdcard/tests', 'TRUE'),
+                    ('cd /mnt/sdcard/tests', ''),
+                    ('ls', 'foo2'),
+                    ('isdir /mnt/sdcard/tests/foo2', 'TRUE'),
+                    ('cd /mnt/sdcard/tests/foo2', ''),
+                    ('ls', 'bar')]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
+                               logLevel=logging.DEBUG)
+
+        self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar'))
+        self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
+                                          '/mnt/sdcard/tests/foo2'))
+        self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2'))
+        self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar'))
+
+if __name__ == "__main__":
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_ps.py
@@ -0,0 +1,52 @@
+from sut import MockAgent
+import mozdevice
+import unittest
+
+import mozunit
+
+
+class PsTest(unittest.TestCase):
+
+    pscommands = [('ps',
+                   "10029	549	com.android.launcher\n"
+                   "10066	1198	com.twitter.android")]
+
+    bad_pscommands = [('ps',
+                       "abcdef	549	com.android.launcher\n"
+                       "10066	1198	com.twitter.android")]
+
+    def test_processList(self):
+        a = MockAgent(self,
+                      commands=self.pscommands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+        pslist = d.getProcessList()
+        self.assertEqual(len(pslist), 2)
+        self.assertEqual(pslist[0], [549, 'com.android.launcher', 10029])
+        self.assertEqual(pslist[1], [1198, 'com.twitter.android', 10066])
+
+        a.wait()
+
+    def test_badProcessList(self):
+        a = MockAgent(self,
+                      commands=self.bad_pscommands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+        exceptionTriggered = False
+        try:
+            d.getProcessList()
+        except mozdevice.DMError:
+            exceptionTriggered = True
+
+        self.assertTrue(exceptionTriggered)
+
+        a.wait()
+
+    def test_processExist(self):
+        for i in [('com.android.launcher', 549),
+                  ('com.fennec.android', None)]:
+            a = MockAgent(self, commands=self.pscommands)
+            d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+            self.assertEqual(d.processExist(i[0]), i[1])
+            a.wait()
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_pull.py
@@ -0,0 +1,49 @@
+from sut import MockAgent
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+
+class PullTest(unittest.TestCase):
+
+    def test_pull_success(self):
+        for count in [1, 4, 1024, 2048]:
+            cheeseburgers = ""
+            for i in range(count):
+                cheeseburgers += "cheeseburgers"
+
+            # pull file is kind of gross, make sure we can still execute commands after it's done
+            remoteName = "/mnt/sdcard/cheeseburgers"
+            a = MockAgent(self, commands=[("pull %s" % remoteName,
+                                           "%s,%s\n%s" % (remoteName,
+                                                          len(cheeseburgers),
+                                                          cheeseburgers)),
+                                          ("isdir /mnt/sdcard", "TRUE")])
+
+            d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
+                                   logLevel=logging.DEBUG)
+            pulledData = d.pullFile("/mnt/sdcard/cheeseburgers")
+            self.assertEqual(pulledData, cheeseburgers)
+            d.dirExists('/mnt/sdcard')
+
+    def test_pull_failure(self):
+
+        # this test simulates only receiving a few bytes of what we expect
+        # to be larger file
+        remoteName = "/mnt/sdcard/cheeseburgers"
+        a = MockAgent(self, commands=[("pull %s" % remoteName,
+                                       "%s,15\n%s" % (remoteName,
+                                                      "cheeseburgh"))])
+        d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
+                               logLevel=logging.DEBUG)
+        exceptionThrown = False
+        try:
+            d.pullFile("/mnt/sdcard/cheeseburgers")
+        except mozdevice.DMError:
+            exceptionThrown = True
+        self.assertTrue(exceptionThrown)
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_push.py
@@ -0,0 +1,90 @@
+from sut import MockAgent
+import mozfile
+import mozdevice
+import logging
+import unittest
+import hashlib
+import tempfile
+import os
+
+import mozunit
+
+
+class PushTest(unittest.TestCase):
+
+    def test_push(self):
+        pushfile = "1234ABCD"
+        mdsum = hashlib.md5()
+        mdsum.update(pushfile)
+        expectedResponse = mdsum.hexdigest()
+
+        # (good response, no exception), (bad response, exception)
+        for response in [(expectedResponse, False), ("BADHASH", True)]:
+            cmd = "push /mnt/sdcard/foobar %s\r\n%s" % (len(pushfile), pushfile)
+            a = MockAgent(self, commands=[("isdir /mnt/sdcard", "TRUE"),
+                                          (cmd, response[0])])
+            exceptionThrown = False
+            with tempfile.NamedTemporaryFile() as f:
+                try:
+                    f.write(pushfile)
+                    f.flush()
+                    d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+                    d.pushFile(f.name, '/mnt/sdcard/foobar')
+                except mozdevice.DMError:
+                    exceptionThrown = True
+                self.assertEqual(exceptionThrown, response[1])
+            a.wait()
+
+    def test_push_dir(self):
+        pushfile = "1234ABCD"
+        mdsum = hashlib.md5()
+        mdsum.update(pushfile)
+        expectedFileResponse = mdsum.hexdigest()
+
+        tempdir = tempfile.mkdtemp()
+        self.addCleanup(mozfile.remove, tempdir)
+        complex_path = os.path.join(tempdir, "baz")
+        os.mkdir(complex_path)
+        f = tempfile.NamedTemporaryFile(dir=complex_path)
+        f.write(pushfile)
+        f.flush()
+
+        subTests = [{'cmds': [("isdir /mnt/sdcard/baz", "TRUE"),
+                              ("push /mnt/sdcard/baz/%s %s\r\n%s" %
+                               (os.path.basename(f.name), len(pushfile),
+                                pushfile),
+                               expectedFileResponse)],
+                     'expectException': False},
+                    {'cmds': [("isdir /mnt/sdcard/baz", "TRUE"),
+                              ("push /mnt/sdcard/baz/%s %s\r\n%s" %
+                               (os.path.basename(f.name), len(pushfile),
+                                pushfile),
+                               "BADHASH")],
+                     'expectException': True},
+                    {'cmds': [("isdir /mnt/sdcard/baz", "FALSE"),
+                              ('info os', 'android'),
+                              ("isdir /mnt", "FALSE"),
+                              ("mkdr /mnt",
+                               "##AGENT-WARNING## Could not create the directory /mnt")],
+                     'expectException': True},
+
+                    ]
+
+        for subTest in subTests:
+            a = MockAgent(self, commands=subTest['cmds'])
+
+            exceptionThrown = False
+            try:
+                d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
+                                       logLevel=logging.DEBUG)
+                d.pushDir(tempdir, "/mnt/sdcard")
+            except mozdevice.DMError:
+                exceptionThrown = True
+            self.assertEqual(exceptionThrown, subTest['expectException'])
+
+            a.wait()
+
+        # FIXME: delete directory when done
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_remove.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestRemove(unittest.TestCase):
+
+    def test_removeDir(self):
+        commands = [("isdir /mnt/sdcard/test", "TRUE"),
+                    ("rmdr /mnt/sdcard/test", "Deleting file(s) from "
+                     "/storage/emulated/legacy/Moztest\n"
+                     "        <empty>\n"
+                     "Deleting directory "
+                     "/storage/emulated/legacy/Moztest\n")]
+
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        # No error implies we're all good
+        self.assertEqual(None, d.removeDir("/mnt/sdcard/test"))
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_time.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestGetCurrentTime(unittest.TestCase):
+
+    def test_getCurrentTime(self):
+        command = [('clok', '1349980200')]
+
+        m = MockAgent(self, commands=command)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        self.assertEqual(d.getCurrentTime(), int(command[0][1]))
+
+if __name__ == '__main__':
+    mozunit.main()
new file mode 100644
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_unpackfile.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+import mozdevice
+import logging
+import unittest
+
+import mozunit
+
+from sut import MockAgent
+
+
+class TestUnpack(unittest.TestCase):
+
+    def test_unpackFile(self):
+
+        commands = [("unzp /data/test/sample.zip /data/test/",
+                     "Checksum:          653400271\n"
+                     "1 of 1 successfully extracted\n")]
+        m = MockAgent(self, commands=commands)
+        d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+        # No error being thrown imples all is well
+        self.assertEqual(None, d.unpackFile("/data/test/sample.zip",
+                                            "/data/test/"))
+
+if __name__ == '__main__':
+    mozunit.main()
--- a/testing/mozbase/mozversion/mozversion/mozversion.py
+++ b/testing/mozbase/mozversion/mozversion/mozversion.py
@@ -178,31 +178,40 @@ class LocalB2GVersion(B2GVersion):
             with open(zip_path, 'rb') as zip_file:
                 self.get_gaia_info(zip_file)
         else:
             self._logger.warning('Error pulling gaia file')
 
 
 class RemoteB2GVersion(B2GVersion):
 
-    def __init__(self, sources=None, host=None,
+    def __init__(self, sources=None, dm_type='adb', host=None,
                  device_serial=None, adb_host=None, adb_port=None,
                  **kwargs):
         B2GVersion.__init__(self, sources, **kwargs)
 
         try:
             import mozdevice
         except ImportError:
             self._logger.critical("mozdevice is required to get the version"
                                   " of a remote device")
             raise
 
-        dm = mozdevice.DeviceManagerADB(deviceSerial=device_serial,
-                                        serverHost=adb_host,
-                                        serverPort=adb_port)
+        if dm_type == 'adb':
+            dm = mozdevice.DeviceManagerADB(deviceSerial=device_serial,
+                                            serverHost=adb_host,
+                                            serverPort=adb_port)
+        elif dm_type == 'sut':
+            if not host:
+                raise errors.RemoteAppNotFoundError(
+                    'A host for SUT must be supplied.')
+            dm = mozdevice.DeviceManagerSUT(host=host)
+        else:
+            raise errors.RemoteAppNotFoundError(
+                'Unknown device manager type: %s' % dm_type)
 
         if not sources:
             path = 'system/sources.xml'
             if dm.fileExists(path):
                 sources = StringIO(dm.pullFile(path))
             else:
                 self._logger.info('Unable to find %s' % path)
 
@@ -239,29 +248,30 @@ class RemoteB2GVersion(B2GVersion):
         if self._info.get('device_id', '').lower() == 'flame':
             for prop in ['ro.boot.bootloader', 't2m.sw.version']:
                 value = dm.shellCheckOutput(['getprop', prop])
                 if value:
                     self._info['device_firmware_version_base'] = value
                     break
 
 
-def get_version(binary=None, sources=None, host=None,
+def get_version(binary=None, sources=None, dm_type=None, host=None,
                 device_serial=None, adb_host=None, adb_port=None):
     """
     Returns the application version information as a dict. You can specify
     a path to the binary of the application or an Android APK file (to get
     version information for Firefox for Android). If this is omitted then the
     current directory is checked for the existance of an application.ini
     file. If not found and that the binary path was not specified, then it is
     assumed the target application is a remote Firefox OS instance.
 
     :param binary: Path to the binary for the application or Android APK file
     :param sources: Path to the sources.xml file (Firefox OS)
-    :param host: Host address of remote Firefox OS instance (not used with ADB)
+    :param dm_type: Device manager type. Must be 'adb' or 'sut' (Firefox OS)
+    :param host: Host address of remote Firefox OS instance (SUT)
     :param device_serial: Serial identifier of Firefox OS device (ADB)
     :param adb_host: Host address of ADB server
     :param adb_port: Port of ADB server
     """
     try:
         if binary and zipfile.is_zipfile(binary) and 'AndroidManifest.xml' in \
            zipfile.ZipFile(binary, 'r').namelist():
             version = LocalFennecVersion(binary)
@@ -269,16 +279,17 @@ def get_version(binary=None, sources=Non
             version = LocalVersion(binary)
             if version._info.get('application_name') == 'B2G':
                 version = LocalB2GVersion(binary, sources=sources)
     except errors.LocalAppNotFoundError:
         if binary:
             # we had a binary argument, do not search for remote B2G
             raise
         version = RemoteB2GVersion(sources=sources,
+                                   dm_type=dm_type,
                                    host=host,
                                    adb_host=adb_host,
                                    adb_port=adb_port,
                                    device_serial=device_serial)
 
     for (key, value) in sorted(version._info.items()):
         if value:
             version._logger.info('%s: %s' % (key, value))
@@ -306,22 +317,24 @@ def cli(args=sys.argv[1:]):
         '--adb-port',
         help='port running adb')
     mozlog.commandline.add_logging_group(
         parser,
         include_formatters=mozlog.commandline.TEXT_FORMATTERS
     )
 
     args = parser.parse_args()
+    dm_type = os.environ.get('DM_TRANS', 'adb')
     host = os.environ.get('TEST_DEVICE')
 
     mozlog.commandline.setup_logging(
         'mozversion', args, {'mach': sys.stdout})
 
     get_version(binary=args.binary,
                 sources=args.sources,
+                dm_type=dm_type,
                 host=host,
                 device_serial=args.device,
                 adb_host=args.adb_host,
                 adb_port=args.adb_port)
 
 if __name__ == '__main__':
     cli()
--- a/testing/mozharness/configs/android/androidarm_4_3.py
+++ b/testing/mozharness/configs/android/androidarm_4_3.py
@@ -28,16 +28,17 @@ config = {
         "digest": "6609e8b95db59c6a3ad60fc3dcfc358b2c8ec8b4dda4c2780eb439e1c5dcc5d550f2e47ce56ba14309363070078d09b5287e372f6e95686110ff8a2ef1838221",
         "algorithm": "sha512",
         "filename": "android-sdk18_0.r18moz1.orig.tar.gz",
         "unpack": "True"
         }
         ] """,
     "emulator_process_name": "emulator64-arm",
     "emulator_extra_args": "-show-kernel -debug init,console,gles,memcheck,adbserver,adbclient,adb,avd_config,socket",
+    "device_manager": "adb",
     "exes": {
         'adb': '%(abs_work_dir)s/android-sdk18/platform-tools/adb',
     },
     "env": {
         "DISPLAY": ":0.0",
         "PATH": "%(PATH)s:%(abs_work_dir)s/android-sdk-linux/tools:%(abs_work_dir)s/android-sdk18/platform-tools",
         "MINIDUMP_SAVEPATH": "%(abs_work_dir)s/../minidumps"
     },
@@ -59,16 +60,17 @@ config = {
         "ssl_port": "4454",  # starting ssl port to use for the server
         "emulator_port": 5554,
     },
     "suite_definitions": {
         "mochitest": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -80,16 +82,17 @@ config = {
                 "--screenshot-on-fail",
                 "--total-chunks=20",
             ],
         },
         "mochitest-gl": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -100,16 +103,17 @@ config = {
                 "--total-chunks=10",
                 "--subsuite=webgl",
             ],
         },
         "mochitest-chrome": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -121,16 +125,17 @@ config = {
                 "--screenshot-on-fail",
                 "--flavor=chrome",
             ],
         },
         "mochitest-plain-gpu": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -140,16 +145,17 @@ config = {
                 "--screenshot-on-fail",
                 "--subsuite=gpu",
             ],
         },
         "mochitest-plain-clipboard": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -159,16 +165,17 @@ config = {
                 "--screenshot-on-fail",
                 "--subsuite=clipboard",
             ],
         },
         "mochitest-media": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -180,16 +187,17 @@ config = {
                 "--total-chunks=2",
                 "--subsuite=media",
             ],
         },
         "robocop": {
             "run_filename": "runrobocop.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
@@ -202,16 +210,17 @@ config = {
             ],
         },
         "reftest": {
             "run_filename": "remotereftest.py",
             "testsdir": "reftest",
             "options": [
                 "--app=%(app)s",
                 "--ignore-window-size",
+                "--dm_trans=adb",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--httpd-path", "%(modules_dir)s",
                 "--symbols-path=%(symbols_path)s",
                 "--total-chunks=16",
@@ -224,16 +233,17 @@ config = {
             "tests": ["tests/layout/reftests/reftest.list",],
         },
         "reftest-debug": {
             "run_filename": "remotereftest.py",
             "testsdir": "reftest",
             "options": [
                 "--app=%(app)s",
                 "--ignore-window-size",
+                "--dm_trans=adb",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--httpd-path", "%(modules_dir)s",
                 "--symbols-path=%(symbols_path)s",
                 "--total-chunks=48",
@@ -243,16 +253,17 @@ config = {
             ],
         },
         "crashtest": {
             "run_filename": "remotereftest.py",
             "testsdir": "reftest",
             "options": [
                 "--app=%(app)s",
                 "--ignore-window-size",
+                "--dm_trans=adb",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--httpd-path",
                 "%(modules_dir)s",
                 "--symbols-path=%(symbols_path)s",
@@ -262,16 +273,17 @@ config = {
             "tests": ["tests/testing/crashtest/crashtests.list",],
         },
         "crashtest-debug": {
             "run_filename": "remotereftest.py",
             "testsdir": "reftest",
             "options": [
                 "--app=%(app)s",
                 "--ignore-window-size",
+                "--dm_trans=adb",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--httpd-path",
                 "%(modules_dir)s",
                 "--symbols-path=%(symbols_path)s",
@@ -280,46 +292,49 @@ config = {
             ],
         },
         "jsreftest": {
             "run_filename": "remotereftest.py",
             "testsdir": "reftest",
             "options": [
                 "--app=%(app)s",
                 "--ignore-window-size",
+                "--dm_trans=adb",
                 "--remote-webserver=%(remote_webserver)s", "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s", "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s", "--httpd-path", "%(modules_dir)s",
                 "--symbols-path=%(symbols_path)s",
                 "--total-chunks=10",
                 "--extra-profile-file=jsreftest/tests/user.js",
                 "--suite=jstestbrowser",
             ],
             "tests": ["../jsreftest/tests/jstests.list",],
         },
         "jsreftest-debug": {
             "run_filename": "remotereftest.py",
             "testsdir": "reftest",
             "options": [
                 "--app=%(app)s",
                 "--ignore-window-size",
+                "--dm_trans=adb",
                 "--remote-webserver=%(remote_webserver)s", "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s", "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s", "--httpd-path", "%(modules_dir)s",
                 "--symbols-path=%(symbols_path)s",
                 "../jsreftest/tests/jstests.list",
                 "--total-chunks=35",
                 "--extra-profile-file=jsreftest/tests/user.js",
             ],
         },
         "xpcshell": {
             "run_filename": "remotexpcshelltests.py",
             "testsdir": "xpcshell",
             "install": False,
             "options": [
+                "--dm_trans=adb",
                 "--xre-path=%(xre_path)s",
                 "--testing-modules-dir=%(modules_dir)s",
                 "--apk=%(installer_path)s",
                 "--no-logfiles",
                 "--symbols-path=%(symbols_path)s",
                 "--manifest=tests/xpcshell.ini",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
@@ -329,16 +344,17 @@ config = {
         },
         "cppunittest": {
             "run_filename": "remotecppunittests.py",
             "testsdir": "cppunittest",
             "install": False,
             "options": [
                 "--symbols-path=%(symbols_path)s",
                 "--xre-path=%(xre_path)s",
+                "--dm_trans=adb",
                 "--localBinDir=../bin",
                 "--apk=%(installer_path)s",
                 ".",
             ],
         },
         "marionette": {
             "run_filename": os.path.join("harness", "marionette_harness", "runtests.py"),
             "testsdir": "marionette",
--- a/testing/mozharness/configs/android/androidx86.py
+++ b/testing/mozharness/configs/android/androidx86.py
@@ -15,16 +15,17 @@ config = {
         "digest": "6609e8b95db59c6a3ad60fc3dcfc358b2c8ec8b4dda4c2780eb439e1c5dcc5d550f2e47ce56ba14309363070078d09b5287e372f6e95686110ff8a2ef1838221",
         "algorithm": "sha512",
         "filename": "android-sdk18_0.r18moz1.orig.tar.gz",
         "unpack": "True"
         }
         ] """,
     "emulator_process_name": "emulator64-x86",
     "emulator_extra_args": "-show-kernel -debug init,console,gles,memcheck,adbserver,adbclient,adb,avd_config,socket -qemu -m 1024",
+    "device_manager": "adb",
     "exes": {
         'adb': '%(abs_work_dir)s/android-sdk18/platform-tools/adb',
     },
     "env": {
         "DISPLAY": ":0.0",
         "PATH": "%(PATH)s:%(abs_work_dir)s/android-sdk18/tools:%(abs_work_dir)s/android-sdk18/platform-tools",
         "MINIDUMP_SAVEPATH": "%(abs_work_dir)s/../minidumps"
     },
@@ -47,31 +48,33 @@ config = {
         "emulator_port": 5554,
     },
     "suite_definitions": {
         "xpcshell": {
             "run_filename": "remotexpcshelltests.py",
             "testsdir": "xpcshell",
             "install": False,
             "options": [
+                "--dm_trans=adb",
                 "--xre-path=%(xre_path)s",
                 "--testing-modules-dir=%(modules_dir)s",
                 "--apk=%(installer_path)s",
                 "--no-logfiles",
                 "--symbols-path=%(symbols_path)s",
                 "--manifest=tests/xpcshell.ini",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--test-plugin-path=none",
             ],
         },
         "mochitest-chrome": {
             "run_filename": "runtestsremote.py",
             "testsdir": "mochitest",
             "options": [
+                "--dm_trans=adb",
                 "--app=%(app)s",
                 "--remote-webserver=%(remote_webserver)s",
                 "--xre-path=%(xre_path)s",
                 "--utility-path=%(utility_path)s",
                 "--http-port=%(http_port)s",
                 "--ssl-port=%(ssl_port)s",
                 "--certificate-path=%(certs_path)s",
                 "--symbols-path=%(symbols_path)s",
--- a/testing/mozharness/mozharness/mozilla/testing/device.py
+++ b/testing/mozharness/mozharness/mozilla/testing/device.py
@@ -1,15 +1,15 @@
 #!/usr/bin/env python
 # ***** BEGIN LICENSE BLOCK *****
 # 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/.
 # ***** END LICENSE BLOCK *****
-'''Interact with a device via ADB
+'''Interact with a device via ADB or SUT.
 
 This code is largely from
 https://hg.mozilla.org/build/tools/file/default/sut_tools
 '''
 
 import datetime
 import os
 import re
@@ -271,16 +271,17 @@ class ADBDeviceHandler(BaseDeviceHandler
             device_root = "/mnt/sdcard/tests"
         else:
             device_root = "/data/local/tmp/tests"
         if not silent:
             self.info("Device root is %s" % str(device_root))
         self.device_root = device_root
         return self.device_root
 
+    # TODO from here on down needs to be copied to Base+SUT
     def wait_for_device(self, interval=60, max_attempts=20):
         self.info("Waiting for device to come back...")
         time.sleep(interval)
         tries = 0
         while tries <= max_attempts:
             tries += 1
             self.info("Try %d" % tries)
             if self.ping_device(auto_connect=True, silent=True):
@@ -409,19 +410,252 @@ class ADBDeviceHandler(BaseDeviceHandler
                               hosts_file])
             if self.query_device_file_exists(hosts_file):
                 self.add_device_flag(DEVICE_CANT_REMOVE_ETC_HOSTS)
                 self.fatal("Unable to remove %s!" % hosts_file)
         else:
             self.debug("%s file doesn't exist; skipping." % hosts_file)
 
 
+# SUTDeviceHandler {{{1
+class SUTDeviceHandler(BaseDeviceHandler):
+    def __init__(self, **kwargs):
+        super(SUTDeviceHandler, self).__init__(**kwargs)
+        self.devicemanager = None
+        self.default_port = 20701
+        self.default_heartbeat_port = 20700
+        self.DMError = None
+
+    def query_devicemanager(self):
+        if self.devicemanager:
+            return self.devicemanager
+        c = self.config
+        site_packages_path = self.script_obj.query_python_site_packages_path()
+        dm_path = os.path.join(site_packages_path, 'mozdevice')
+        sys.path.append(dm_path)
+        try:
+            from devicemanagerSUT import DeviceManagerSUT
+            from devicemanagerSUT import DMError
+            self.DMError = DMError
+            self.devicemanager = DeviceManagerSUT(c['device_ip'])
+            # TODO configurable?
+            self.devicemanager.debug = c.get('devicemanager_debug_level', 0)
+        except ImportError, e:
+            self.fatal("Can't import DeviceManagerSUT! %s\nDid you check out talos?" % str(e))
+        return self.devicemanager
+
+    # maintenance {{{2
+    def ping_device(self):
+        #TODO writeme
+        pass
+
+    def check_device(self):
+        self.info("Checking for device root to verify the device is alive.")
+        dev_root = self.query_device_root(strict=True)
+        if not dev_root:
+            self.add_device_flag(DEVICE_UNREACHABLE)
+            self.fatal("Can't get dev_root from devicemanager; is the device up?")
+        self.info("Found a dev_root of %s." % str(dev_root))
+
+    def wait_for_device(self, interval=60, max_attempts=20):
+        self.info("Waiting for device to come back...")
+        time.sleep(interval)
+        success = False
+        attempts = 0
+        while attempts <= max_attempts:
+            attempts += 1
+            self.info("Try %d" % attempts)
+            if self.query_device_root() is not None:
+                success = True
+                break
+            time.sleep(interval)
+        if not success:
+            self.add_device_flag(DEVICE_UNREACHABLE)
+            self.fatal("Waiting for tegra timed out.")
+        else:
+            self.info("Device came back.")
+
+    def cleanup_device(self, reboot=False):
+        c = self.config
+        dev_root = self.query_device_root()
+        dm = self.query_devicemanager()
+        if dm.dirExists(dev_root):
+            self.info("Removing dev_root %s..." % dev_root)
+            try:
+                dm.removeDir(dev_root)
+            except self.DMError:
+                self.add_device_flag(DEVICE_CANT_REMOVE_DEVROOT)
+                self.fatal("Can't remove dev_root!")
+        if c.get("enable_automation"):
+            self.remove_etc_hosts()
+        # TODO I need to abstract this uninstall as we'll need to clean
+        # multiple packages off devices.
+        if c.get("device_package_name"):
+            if dm.dirExists('/data/data/%s' % c['device_package_name']):
+                self.info("Uninstalling %s..." % c['device_package_name'])
+                dm.uninstallAppAndReboot(c['device_package_name'])
+                self.wait_for_device()
+            elif reboot:
+                self.reboot_device()
+
+    # device calls {{{2
+    def query_device_root(self, strict=False):
+        c = self.config
+        dm = self.query_devicemanager()
+        dev_root = dm.getDeviceRoot()
+        if strict and c.get('enable_automation'):
+            if not str(dev_root).startswith("/mnt/sdcard"):
+                self.add_device_flag(DEVICE_MISSING_SDCARD)
+                self.fatal("dev_root from devicemanager [%s] is not correct!" %
+                           str(dev_root))
+        if not dev_root or dev_root == "/tests":
+            return None
+        return dev_root
+
+    def query_device_time(self):
+        dm = self.query_devicemanager()
+        timestamp = int(dm.getCurrentTime())  # epoch time in milliseconds
+        dt = datetime.datetime.utcfromtimestamp(timestamp / 1000)
+        self.info("Current device time is %s" % dt.strftime('%Y/%m/%d %H:%M:%S'))
+        return dt
+
+    def set_device_time(self):
+        dm = self.query_devicemanager()
+        s = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')
+        self.info("Setting device time to %s" % s)
+        try:
+            dm.sendCMD(['settime %s' % s])
+            return True
+        except self.DMError, e:
+            self.add_device_flag(DEVICE_CANT_SET_TIME)
+            self.fatal("Exception while setting device time: %s" % str(e))
+
+    def install_app(self, file_path):
+        dev_root = self.query_device_root(strict=True)
+        if not dev_root:
+            self.add_device_flag(DEVICE_UNREACHABLE)
+            # TODO wait_for_device?
+            self.fatal("dev_root %s not correct!" % str(dev_root))
+
+        dm = self.query_devicemanager()
+
+        c = self.config
+        if c.get('enable_automation'):
+            self.query_device_time()
+            self.set_device_time()
+            self.query_device_time()
+            dm.getInfo('process')
+            dm.getInfo('memory')
+            dm.getInfo('uptime')
+
+        # This target needs to not use os.path.join due to differences with win
+        # Paths vs. unix paths.
+        target = "/".join([dev_root, os.path.basename(file_path)])
+        self.info("Installing %s on device..." % file_path)
+        dm.pushFile(file_path, target)
+        # TODO screen resolution
+        # TODO do something with status?
+        try:
+            dm.installApp(target)
+            self.info('-' * 42)
+            self.info("Sleeping for 90 seconds...")
+            time.sleep(90)
+            self.info('installApp(%s) done - gathering debug info' % target)
+            try:
+                self.info(repr(dm.getInfo('process')))
+                self.info(repr(dm.getInfo('memory')))
+                self.info(repr(dm.getInfo('uptime')))
+                self.info(repr(dm.sendCMD(['exec su -c "logcat -d -v time *:W"'])))
+            except Exception, e:
+                self.info("Exception hit while trying to run logcat: %s" % str(e))
+                self.fatal("Remote Device Error: can't run logcat")
+        except self.DMError:
+            self.fatal("Remote Device Error: installApp() call failed - exiting")
+
+    def reboot_device(self):
+        dm = self.query_devicemanager()
+        # logcat?
+        self.info("Rebooting device...")
+        try:
+            dm.reboot()
+        except self.DMError:
+            self.add_device_flag(DEVICE_NOT_REBOOTED)
+            self.fatal("Can't reboot device!")
+        self.wait_for_device()
+        dm.getInfo('uptime')
+
+    # device type specific {{{2
+    def remove_etc_hosts(self, hosts_file="/system/etc/hosts"):
+        c = self.config
+        # TODO figure this out
+        if c['device_type'] not in ("tegra250",) or True:
+            self.debug("No need to remove /etc/hosts on a non-Tegra250.")
+            return
+        dm = self.query_devicemanager()
+        if dm.fileExists(hosts_file):
+            self.info("Removing %s file." % hosts_file)
+            try:
+                dm.sendCMD(['exec mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system'])
+                dm.sendCMD(['exec rm %s' % hosts_file])
+            except self.DMError:
+                self.add_device_flag(DEVICE_CANT_REMOVE_ETC_HOSTS)
+                self.fatal("Unable to remove %s!" % hosts_file)
+            if dm.fileExists(hosts_file):
+                self.add_device_flag(DEVICE_CANT_REMOVE_ETC_HOSTS)
+                self.fatal("Unable to remove %s!" % hosts_file)
+        else:
+            self.debug("%s file doesn't exist; skipping." % hosts_file)
+
+
+# SUTDeviceMozdeviceMixin {{{1
+class SUTDeviceMozdeviceMixin(SUTDeviceHandler):
+    '''
+    This SUT device manager class makes calls through mozdevice (from mozbase) [1]
+    directly rather than calling SUT tools.
+
+    [1] https://github.com/mozilla/mozbase/blob/master/mozdevice/mozdevice/devicemanagerSUT.py
+    '''
+    dm = None
+
+    def query_devicemanager(self):
+        if self.dm:
+            return self.dm
+        sys.path.append(self.query_python_site_packages_path())
+        from mozdevice.devicemanagerSUT import DeviceManagerSUT
+        self.info("Connecting to: %s" % self.mozpool_device)
+        self.dm = DeviceManagerSUT(self.mozpool_device)
+        # No need for 300 second SUT socket timeouts here
+        self.dm.default_timeout = 30
+        return self.dm
+
+    def query_file(self, filename):
+        dm = self.query_devicemanager()
+        if not dm.fileExists(filename):
+            raise Exception("Expected file (%s) not found" % filename)
+
+        file_contents = dm.pullFile(filename)
+        if file_contents is None:
+            raise Exception("Unable to read file (%s)" % filename)
+
+        return file_contents
+
+    def set_device_epoch_time(self, timestamp=int(time.time())):
+        dm = self.query_devicemanager()
+        dm._runCmds([{'cmd': 'setutime %s' % timestamp}])
+        return dm._runCmds([{'cmd': 'clok'}])
+
+    def get_logcat(self):
+        dm = self.query_devicemanager()
+        return dm.getLogcat()
+
+
 # DeviceMixin {{{1
 DEVICE_PROTOCOL_DICT = {
     'adb': ADBDeviceHandler,
+    'sut': SUTDeviceHandler,
 }
 
 device_config_options = [[
     ["--device-ip"],
     {"action": "store",
      "dest": "device_ip",
      "help": "Specify the IP address of the device."
      }
@@ -430,17 +664,17 @@ device_config_options = [[
     {"action": "store",
      "dest": "device_port",
      "help": "Specify the IP port of the device."
      }
 ], [
     ["--device-heartbeat-port"],
     {"action": "store",
      "dest": "device_heartbeat_port",
-     "help": "Specify the heartbeat port of the device."
+     "help": "Specify the heartbeat port of the SUT device."
      }
 ], [
     ["--device-protocol"],
     {"action": "store",
      "type": "choice",
      "dest": "device_protocol",
      "choices": DEVICE_PROTOCOL_DICT.keys(),
      "help": "Specify the device communication protocol."
@@ -455,17 +689,17 @@ device_config_options = [[
      "default": "non-tegra",
      "dest": "device_type",
      "help": "Specify the device type."
      }
 ], [
     ["--devicemanager-path"],
     {"action": "store",
      "dest": "devicemanager_path",
-     "help": "Specify the parent dir of devicemanager.py."
+     "help": "Specify the parent dir of devicemanagerSUT.py."
      }
 ]]
 
 
 class DeviceMixin(object):
     '''BaseScript mixin, designed to interface with the device.
 
     '''
--- a/testing/mozharness/scripts/android_emulator_unittest.py
+++ b/testing/mozharness/scripts/android_emulator_unittest.py
@@ -466,16 +466,17 @@ class AndroidEmulatorTest(BlobUploadMixi
             'certs_path': os.path.join(dirs['abs_work_dir'], 'tests/certs'),
             # TestingMixin._download_and_extract_symbols() will set
             # self.symbols_path when downloading/extracting.
             'symbols_path': self.symbols_path,
             'modules_dir': dirs['abs_modules_dir'],
             'installer_path': self.installer_path,
             'raw_log_file': raw_log_file,
             'error_summary_file': error_summary_file,
+            'dm_trans': c['device_manager'],
             # marionette options
             'address': c.get('marionette_address'),
             'gecko_log': os.path.join(dirs["abs_blob_upload_dir"], 'gecko.log'),
             'test_manifest': os.path.join(
                 dirs['abs_marionette_tests_dir'],
                 self.config.get('marionette_test_manifest', '')
             ),
         }
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -10,17 +10,17 @@ import tempfile
 from zipfile import ZipFile
 import runcppunittests as cppunittests
 import mozcrash
 import mozfile
 import mozinfo
 import mozlog
 import StringIO
 import posixpath
-from mozdevice import devicemanager, devicemanagerADB
+from mozdevice import devicemanager, devicemanagerADB, devicemanagerSUT
 
 try:
     from mozbuild.base import MozbuildObject
     build_obj = MozbuildObject.from_environment()
 except ImportError:
     build_obj = None
 
 class RemoteCPPUnitTests(cppunittests.CPPUnitTests):
@@ -162,16 +162,21 @@ class RemoteCPPUnittestOptions(cppunitte
                         help = "ip address of remote device to test")
         defaults["device_ip"] = None
 
         self.add_option("--devicePort", action="store",
                         type = "string", dest = "device_port",
                         help = "port of remote device to test")
         defaults["device_port"] = 20701
 
+        self.add_option("--dm_trans", action="store",
+                        type = "string", dest = "dm_trans",
+                        help = "the transport to use to communicate with device: [adb|sut]; default=sut")
+        defaults["dm_trans"] = "sut"
+
         self.add_option("--noSetup", action="store_false",
                         dest = "setup",
                         help = "do not copy any files to device (to be used only if device is already setup)")
         defaults["setup"] = True
 
         self.add_option("--localLib", action="store",
                         type = "string", dest = "local_lib",
                         help = "location of libraries to push -- preferably stripped")
@@ -206,31 +211,38 @@ class RemoteCPPUnittestOptions(cppunitte
 
         self.set_defaults(**defaults)
 
 def run_test_harness(options, args):
     if options.with_b2g_emulator:
         from mozrunner import B2GEmulatorRunner
         runner = B2GEmulatorRunner(arch=options.emulator, b2g_home=options.with_b2g_emulator)
         runner.start()
-        # because we just started the emulator, we need more than the
-        # default number of retries here.
-        retryLimit = 50
+    if options.dm_trans == "adb":
+        if options.with_b2g_emulator:
+            # because we just started the emulator, we need more than the
+            # default number of retries here.
+            retryLimit = 50
+        else:
+            retryLimit = 5
+        try:
+            if options.device_ip:
+                dm = devicemanagerADB.DeviceManagerADB(options.device_ip, options.device_port, packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
+            else:
+                dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
+        except:
+            if options.with_b2g_emulator:
+                runner.cleanup()
+                runner.wait()
+            raise
     else:
-        retryLimit = 5
-    try:
-        if options.device_ip:
-            dm = devicemanagerADB.DeviceManagerADB(options.device_ip, options.device_port, packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
-        else:
-            dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
-    except:
-        if options.with_b2g_emulator:
-            runner.cleanup()
-            runner.wait()
-        raise
+        dm = devicemanagerSUT.DeviceManagerSUT(options.device_ip, options.device_port, deviceRoot=options.remote_test_root)
+        if not options.device_ip:
+            print "Error: you must provide a device IP to connect to via the --deviceIP option"
+            sys.exit(1)
 
     options.xre_path = os.path.abspath(options.xre_path)
     cppunittests.update_mozinfo()
     progs = cppunittests.extract_unittests_from_args(args,
                                                      mozinfo.info,
                                                      options.manifest_path)
     tester = RemoteCPPUnitTests(dm, options, [item[0] for item in progs])
     try:
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -27,17 +27,17 @@ CHECK_TEST_ERROR_RERUN = $(call check_te
 endif
 
 # Usage: |make [EXTRA_TEST_ARGS=...] *test|.
 RUN_REFTEST = rm -f ./$@.log && $(PYTHON) _tests/reftest/runreftest.py \
   --extra-profile-file=$(DIST)/plugins \
   $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) $(1) | tee ./$@.log
 
 REMOTE_REFTEST = rm -f ./$@.log && $(PYTHON) _tests/reftest/remotereftest.py \
-  --ignore-window-size \
+  --dm_trans=$(DM_TRANS) --ignore-window-size \
   --app=$(TEST_PACKAGE_NAME) --deviceIP=${TEST_DEVICE} --xre-path=${MOZ_HOST_BIN} \
   --httpd-path=_tests/modules --suite reftest \
   --extra-profile-file=$(topsrcdir)/mobile/android/fonts \
   $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) $(1) | tee ./$@.log
 
 ifeq ($(OS_ARCH),WINNT) #{
 # GPU-rendered shadow layers are unsupported here
 OOP_CONTENT = --setpref=layers.async-pan-zoom.enabled=true --setpref=browser.tabs.remote.autostart=true --setpref=layers.acceleration.disabled=true
@@ -48,23 +48,26 @@ GPU_RENDERING = --setpref=layers.acceler
 endif #}
 
 reftest: TEST_PATH?=layout/reftests/reftest.list
 reftest:
 	$(call RUN_REFTEST,'$(topsrcdir)/$(TEST_PATH)')
 	$(CHECK_TEST_ERROR)
 
 reftest-remote: TEST_PATH?=layout/reftests/reftest.list
+reftest-remote: DM_TRANS?=adb
 reftest-remote:
 	@if [ '${MOZ_HOST_BIN}' = '' ]; then \
         echo 'environment variable MOZ_HOST_BIN must be set to a directory containing host xpcshell'; \
     elif [ ! -d ${MOZ_HOST_BIN} ]; then \
         echo 'MOZ_HOST_BIN does not specify a directory'; \
     elif [ ! -f ${MOZ_HOST_BIN}/xpcshell ]; then \
         echo 'xpcshell not found in MOZ_HOST_BIN'; \
+    elif [ '${TEST_DEVICE}' = '' -a '$(DM_TRANS)' != 'adb' ]; then \
+        echo 'please prepare your host with the environment variable TEST_DEVICE'; \
     else \
         ln -s $(abspath $(topsrcdir)) _tests/reftest/tests; \
         $(call REMOTE_REFTEST,'tests/$(TEST_PATH)'); \
         $(CHECK_TEST_ERROR); \
     fi
 
 crashtest: TEST_PATH?=testing/crashtest/crashtests.list
 crashtest:
@@ -79,22 +82,28 @@ jstestbrowser:
 	$(CHECK_TEST_ERROR)
 
 GARBAGE += $(addsuffix .log,$(MOCHITESTS) reftest crashtest jstestbrowser)
 
 REMOTE_CPPUNITTESTS = \
 	$(PYTHON) -u $(topsrcdir)/testing/remotecppunittests.py \
 	  --xre-path=$(DEPTH)/dist/bin \
 	  --localLib=$(DEPTH)/dist/fennec \
+	  --dm_trans=$(DM_TRANS) \
 	  --deviceIP=${TEST_DEVICE} \
 	  $(TEST_PATH) $(EXTRA_TEST_ARGS)
 
 # Usage: |make [TEST_PATH=...] [EXTRA_TEST_ARGS=...] cppunittests-remote|.
+cppunittests-remote: DM_TRANS?=adb
 cppunittests-remote:
-	$(call REMOTE_CPPUNITTESTS);
+	@if [ '${TEST_DEVICE}' != '' -o '$(DM_TRANS)' = 'adb' ]; \
+          then $(call REMOTE_CPPUNITTESTS); \
+        else \
+          echo 'please prepare your host with environment variables for TEST_DEVICE'; \
+        fi
 
 jetpack-tests:
 	cd $(topsrcdir)/addon-sdk/source && $(PYTHON) bin/cfx -b $(abspath $(browser_path)) --parseable testpkgs
 
 pgo-profile-run:
 	$(PYTHON) $(topsrcdir)/build/pgo/profileserver.py $(EXTRA_TEST_ARGS)
 
 # Package up the tests and test harnesses
--- a/testing/xpcshell/mach_commands.py
+++ b/testing/xpcshell/mach_commands.py
@@ -141,35 +141,41 @@ class XPCShellRunner(MozbuildObject):
         if not result and not xpcshell.sequential:
             print("Tests were run in parallel. Try running with --sequential "
                   "to make sure the failures were not caused by this.")
         return int(not result)
 
 
 class AndroidXPCShellRunner(MozbuildObject):
     """Get specified DeviceManager"""
-    def get_devicemanager(self, ip, port, remote_test_root):
+    def get_devicemanager(self, devicemanager, ip, port, remote_test_root):
         import mozdevice
         dm = None
-        if ip:
-            dm = mozdevice.DroidADB(ip, port, packageName=None, deviceRoot=remote_test_root)
+        if devicemanager == "adb":
+            if ip:
+                dm = mozdevice.DroidADB(ip, port, packageName=None, deviceRoot=remote_test_root)
+            else:
+                dm = mozdevice.DroidADB(packageName=None, deviceRoot=remote_test_root)
         else:
-            dm = mozdevice.DroidADB(packageName=None, deviceRoot=remote_test_root)
+            if ip:
+                dm = mozdevice.DroidSUT(ip, port, deviceRoot=remote_test_root)
+            else:
+                raise Exception("You must provide a device IP to connect to via the --ip option")
         return dm
 
     """Run Android xpcshell tests."""
     def run_test(self, **kwargs):
         # TODO Bug 794506 remove once mach integrates with virtualenv.
         build_path = os.path.join(self.topobjdir, 'build')
         if build_path not in sys.path:
             sys.path.append(build_path)
 
         import remotexpcshelltests
 
-        dm = self.get_devicemanager(kwargs["deviceIP"], kwargs["devicePort"],
+        dm = self.get_devicemanager(kwargs["dm_trans"], kwargs["deviceIP"], kwargs["devicePort"],
                                     kwargs["remoteTestRoot"])
 
         log = kwargs.pop("log")
         self.log_manager.enable_unstructured()
 
         if kwargs["xpcshell"] is None:
             kwargs["xpcshell"] = "xpcshell"
 
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -139,19 +139,19 @@ class RemoteXPCShellTestThread(xpcshell.
         self.timedout = False
         cmd.insert(1, self.remoteHere)
         outputFile = "xpcshelloutput"
         with open(outputFile, 'w+') as f:
             try:
                 self.shellReturnCode = self.device.shell(cmd, f, timeout=timeout+10)
             except mozdevice.DMError as e:
                 if self.timedout:
-                    # If the test timed out, there is a good chance the device
-                    # manager also timed out and raised DMError.
-                    # Ignore the DMError to simplify the error report.
+                    # If the test timed out, there is a good chance the SUTagent also
+                    # timed out and failed to return a return code, generating a
+                    # DMError. Ignore the DMError to simplify the error report.
                     self.shellReturnCode = None
                     pass
                 else:
                     raise e
         # The device manager may have timed out waiting for xpcshell.
         # Guard against an accumulation of hung processes by killing
         # them here. Note also that IPC tests may spawn new instances
         # of xpcshell.
@@ -573,20 +573,26 @@ def main():
             print >>sys.stderr, "Error: please specify an APK"
             sys.exit(1)
 
     options = verifyRemoteOptions(parser, options)
     log = commandline.setup_logging("Remote XPCShell",
                                     options,
                                     {"tbpl": sys.stdout})
 
-    if options.deviceIP:
-        dm = mozdevice.DroidADB(options.deviceIP, options.devicePort, packageName=None, deviceRoot=options.remoteTestRoot)
+    if options.dm_trans == "adb":
+        if options.deviceIP:
+            dm = mozdevice.DroidADB(options.deviceIP, options.devicePort, packageName=None, deviceRoot=options.remoteTestRoot)
+        else:
+            dm = mozdevice.DroidADB(packageName=None, deviceRoot=options.remoteTestRoot)
     else:
-        dm = mozdevice.DroidADB(packageName=None, deviceRoot=options.remoteTestRoot)
+        if not options.deviceIP:
+            print "Error: you must provide a device IP to connect to via the --device option"
+            sys.exit(1)
+        dm = mozdevice.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
 
     if options.interactive and not options.testPath:
         print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
         sys.exit(1)
 
     if options.xpcshell is None:
         options.xpcshell = "xpcshell"
 
--- a/testing/xpcshell/xpcshellcommandline.py
+++ b/testing/xpcshell/xpcshellcommandline.py
@@ -122,16 +122,20 @@ def add_common_arguments(parser):
 
 def add_remote_arguments(parser):
     parser.add_argument("--deviceIP", action="store", type=str, dest="deviceIP",
                         help="ip address of remote device to test")
 
     parser.add_argument("--devicePort", action="store", type=str, dest="devicePort",
                         default=20701, help="port of remote device to test")
 
+    parser.add_argument("--dm_trans", action="store", type=str, dest="dm_trans",
+                        choices=["adb", "sut"], default="adb",
+                        help="the transport to use to communicate with device: [adb|sut]; default=adb")
+
     parser.add_argument("--objdir", action="store", type=str, dest="objdir",
                         help="local objdir, containing xpcshell binaries")
 
 
     parser.add_argument("--apk", action="store", type=str, dest="localAPK",
                         help="local path to Fennec APK")
 
 
--- a/tools/lint/flake8.lint
+++ b/tools/lint/flake8.lint
@@ -185,13 +185,14 @@ LINTER = {
         'testing/marionette/harness',
         'testing/marionette/puppeteer',
         'testing/mozbase',
         'testing/mochitest',
         'testing/talos/',
         'tools/lint',
         'toolkit/components/telemetry',
     ],
-    'exclude': ['testing/mochitest/pywebsocket'],
+    'exclude': ["testing/mozbase/mozdevice/mozdevice/Zeroconf.py",
+                'testing/mochitest/pywebsocket'],
     'extensions': EXTENSIONS,
     'type': 'external',
     'payload': lint,
 }