Backed out changeset 31ef6f1090fd (bug 916350) for android reftest bustage on a CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Tue, 21 Jan 2014 15:37:02 -0800
changeset 164536 91ad8c446e5575c768c0184bf656647479f94279
parent 164535 49700610a9b73515e9603bb7d5232beb586b9da2
child 164537 4358d0cb5d7098d12e16c2b40b660283986f2844
push id38738
push userkwierso@gmail.com
push dateTue, 21 Jan 2014 23:37:15 +0000
treeherdermozilla-inbound@91ad8c446e55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs916350
milestone29.0a1
backs out31ef6f1090fd1d22fc625a6f8ea7888dde9b8782
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 31ef6f1090fd (bug 916350) for android reftest bustage on a CLOSED TREE
layout/tools/reftest/Makefile.in
layout/tools/reftest/b2g_desktop.py
layout/tools/reftest/b2g_start_script.js
layout/tools/reftest/reftest.js
layout/tools/reftest/remotereftest.py
layout/tools/reftest/runreftest.py
layout/tools/reftest/runreftestb2g.py
testing/mozbase/mozrunner/mozrunner/local.py
testing/mozbase/mozrunner/mozrunner/runner.py
--- a/layout/tools/reftest/Makefile.in
+++ b/layout/tools/reftest/Makefile.in
@@ -40,17 +40,16 @@ make-xpi:
 copy-harness: make-xpi
 libs:: copy-harness
 endif
 
 _HARNESS_FILES = \
   $(srcdir)/runreftest.py \
   $(srcdir)/remotereftest.py \
   $(srcdir)/runreftestb2g.py \
-  $(srcdir)/b2g_desktop.py \
   $(srcdir)/b2g_start_script.js \
   automation.py \
   $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanager.py \
   $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py \
   $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py \
   $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/droid.py \
   $(topsrcdir)/testing/mozbase/mozdevice/mozdevice/Zeroconf.py \
   $(topsrcdir)/build/mobile/b2gautomation.py \
deleted file mode 100644
--- a/layout/tools/reftest/b2g_desktop.py
+++ /dev/null
@@ -1,170 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
-# You can obtain one at http://mozilla.org/MPL/2.0/.
-from __future__ import print_function, unicode_literals
-
-import json
-import os
-import signal
-import sys
-import threading
-
-here = os.path.abspath(os.path.dirname(__file__))
-
-from runreftest import RefTest, ReftestOptions
-
-from marionette import Marionette
-from mozprocess import ProcessHandler
-from mozrunner import FirefoxRunner
-import mozinfo
-import mozlog
-
-log = mozlog.getLogger('REFTEST')
-
-class B2GDesktopReftest(RefTest):
-    def __init__(self, marionette):
-        RefTest.__init__(self)
-        self.last_test = os.path.basename(__file__)
-        self.marionette = marionette
-        self.profile = None
-        self.runner = None
-        self.test_script = os.path.join(here, 'b2g_start_script.js')
-        self.timeout = None
-
-    def run_marionette_script(self):
-        assert(self.marionette.wait_for_port())
-        self.marionette.start_session()
-        self.marionette.set_context(self.marionette.CONTEXT_CHROME)
-
-        if os.path.isfile(self.test_script):
-            f = open(self.test_script, 'r')
-            self.test_script = f.read()
-            f.close()
-        self.marionette.execute_script(self.test_script)
-
-    def run_tests(self, test_path, options):
-        reftestlist = self.getManifestPath(test_path)
-        if not reftestlist.startswith('file://'):
-            reftestlist = 'file://%s' % reftestlist
-
-        self.profile = self.create_profile(options, reftestlist,
-                                           profile_to_clone=options.profile)
-        env = self.buildBrowserEnv(options, self.profile.profile)
-        kp_kwargs = { 'processOutputLine': [self._on_output],
-                      'onTimeout': [self._on_timeout],
-                      'kill_on_timeout': False }
-
-        if not options.debugger:
-            if not options.timeout:
-                if mozinfo.info['debug']:
-                    options.timeout = 420
-                else:
-                    options.timeout = 300
-            self.timeout = options.timeout + 30.0
-
-        log.info("%s | Running tests: start.", os.path.basename(__file__))
-        cmd, args = self.build_command_line(options.app,
-                            ignore_window_size=options.ignoreWindowSize)
-        self.runner = FirefoxRunner(profile=self.profile,
-                                    binary=cmd,
-                                    cmdargs=args,
-                                    env=env,
-                                    process_class=ProcessHandler,
-                                    symbols_path=options.symbolsPath,
-                                    kp_kwargs=kp_kwargs)
-
-        status = 0
-        try:
-            self.runner.start(outputTimeout=self.timeout)
-            log.info("%s | Application pid: %d",
-                     os.path.basename(__file__),
-                     self.runner.process_handler.pid)
-
-            # kick starts the reftest harness
-            self.run_marionette_script()
-            status = self.runner.wait()
-        finally:
-            self.runner.check_for_crashes(test_name=self.last_test)
-            self.runner.cleanup()
-
-        if status > 0:
-            log.testFail("%s | application terminated with exit code %s",
-                         self.last_test, status)
-        elif status < 0:
-            log.info("%s | application killed with signal %s",
-                         self.last_test, -status)
-
-        log.info("%s | Running tests: end.", os.path.basename(__file__))
-        return status
-
-    def create_profile(self, options, reftestlist, profile_to_clone=None):
-        profile = RefTest.createReftestProfile(self, options, reftestlist,
-                                               profile_to_clone=profile_to_clone)
-
-        prefs = {}
-        # Turn off the locale picker screen
-        prefs["browser.firstrun.show.localepicker"] = False
-        prefs["browser.homescreenURL"] = "app://test-container.gaiamobile.org/index.html"
-        prefs["browser.manifestURL"] = "app://test-container.gaiamobile.org/manifest.webapp"
-        prefs["browser.tabs.remote"] = False
-        prefs["dom.ipc.tabs.disabled"] = False
-        prefs["dom.mozBrowserFramesEnabled"] = True
-        prefs["font.size.inflation.emPerLine"] = 0
-        prefs["font.size.inflation.minTwips"] = 0
-        prefs["network.dns.localDomains"] = "app://test-container.gaiamobile.org"
-        prefs["reftest.browser.iframe.enabled"] = False
-        prefs["reftest.remote"] = False
-        prefs["reftest.uri"] = "%s" % reftestlist
-        # Set a future policy version to avoid the telemetry prompt.
-        prefs["toolkit.telemetry.prompted"] = 999
-        prefs["toolkit.telemetry.notifiedOptOut"] = 999
-
-        # Set the extra prefs.
-        profile.set_preferences(prefs)
-        return profile
-
-    def build_command_line(self, app, ignore_window_size=False):
-        cmd = os.path.abspath(app)
-        args = []
-
-        if not ignore_window_size:
-            args.extend(['--screen', '800x1000'])
-        return cmd, args
-
-    def _on_output(self, line):
-        print(line)
-        # TODO use structured logging
-        if "TEST-START" in line and "|" in line:
-            self.last_test = line.split("|")[1].strip()
-
-    def _on_timeout(self):
-        msg = "%s | application timed out after %s seconds with no output"
-        log.testFail(msg % (self.last_test, self.timeout))
-
-        # kill process to get a stack
-        self.runner.stop(sig=signal.SIGABRT)
-
-
-def run_desktop_reftests(parser, options, args):
-    kwargs = {}
-    if options.marionette:
-        host, port = options.marionette.split(':')
-        kwargs['host'] = host
-        kwargs['port'] = int(port)
-    marionette = Marionette.getMarionetteOrExit(**kwargs)
-
-    reftest = B2GDesktopReftest(marionette)
-
-    options = ReftestOptions.verifyCommonOptions(parser, options, reftest)
-    if options == None:
-        sys.exit(1)
-
-    # add a -bin suffix if b2g-bin exists, but just b2g was specified
-    if options.app[-4:] != '-bin':
-        if os.path.isfile("%s-bin" % options.app):
-            options.app = "%s-bin" % options.app
-
-    if options.desktop and not options.profile:
-        raise Exception("must specify --profile when specifying --desktop")
-
-    sys.exit(reftest.run_tests(args[0], options))
--- a/layout/tools/reftest/b2g_start_script.js
+++ b/layout/tools/reftest/b2g_start_script.js
@@ -1,12 +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/. */
 
+let serverAddr = __marionetteParams[0];
+let serverPort = __marionetteParams[1];
+
 function setDefaultPrefs() {
     // This code sets the preferences for extension-based reftest; for
     // command-line based reftest they are set in function handler_handle in
     // reftest-cmdline.js.  These two locations should stay in sync.
     //
     // FIXME: These should be in only one place.
     var prefs = Cc["@mozilla.org/preferences-service;1"].
                 getService(Ci.nsIPrefService);
@@ -36,22 +39,16 @@ function setDefaultPrefs() {
     // Checking whether two files are the same is slow on Windows.
     // Setting this pref makes tests run much faster there.
     branch.setBoolPref("security.fileuri.strict_origin_policy", false);
     // Disable the thumbnailing service
     branch.setBoolPref("browser.pagethumbnails.capturing_disabled", true);
 }
 
 function setPermissions() {
-  if (__marionetteParams.length < 2) {
-    return;
-  }
-
-  let serverAddr = __marionetteParams[0];
-  let serverPort = __marionetteParams[1];
   let perms = Cc["@mozilla.org/permissionmanager;1"]
               .getService(Ci.nsIPermissionManager);
   let ioService = Cc["@mozilla.org/network/io-service;1"]
                   .getService(Ci.nsIIOService);
   let uri = ioService.newURI("http://" + serverAddr + ":" + serverPort, null, null);
   perms.add(uri, "allowXULXBL", Ci.nsIPermissionManager.ALLOW_ACTION);
 }
 
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -389,25 +389,16 @@ function InitAndStartRefTests()
     gIOService = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService);
     gDebug = CC[DEBUG_CONTRACTID].getService(CI.nsIDebug2);
 
     RegisterProcessCrashObservers();
 
     if (gRemote) {
         gServer = null;
     } else {
-        // not all gecko applications autoregister xpcom components
-        if (CC["@mozilla.org/server/jshttp;1"] === undefined) {
-            var file = CC["@mozilla.org/file/directory_service;1"].
-                        getService(CI.nsIProperties).get("ProfD", CI.nsIFile);
-            file.appendRelativePath("extensions/reftest@mozilla.org/chrome.manifest");
-
-            registrar = Components.manager.QueryInterface(CI.nsIComponentRegistrar);
-            registrar.autoRegister(file);
-        }
         gServer = CC["@mozilla.org/server/jshttp;1"].
                       createInstance(CI.nsIHttpServer);
     }
     try {
         if (gServer)
             StartHTTPServer();
     } catch (ex) {
         //gBrowser.loadURI('data:text/plain,' + ex);
--- a/layout/tools/reftest/remotereftest.py
+++ b/layout/tools/reftest/remotereftest.py
@@ -103,17 +103,17 @@ class RemoteOptions(ReftestOptions):
         self.set_defaults(**defaults)
 
     def verifyRemoteOptions(self, options):
         if options.runTestsInParallel:
             self.error("Cannot run parallel tests here")
 
         # Ensure our defaults are set properly for everything we can infer
         if not options.remoteTestRoot:
-            options.remoteTestRoot = self.automation._devicemanager.getDeviceRoot() + '/reftest'
+            options.remoteTestRoot = self._automation._devicemanager.getDeviceRoot() + '/reftest'
         options.remoteProfile = options.remoteTestRoot + "/profile"
 
         # Verify that our remotewebserver is set properly
         if (options.remoteWebServer == None or
             options.remoteWebServer == '127.0.0.1'):
             print "ERROR: Either you specified the loopback for the remote webserver or ",
             print "your local IP cannot be detected.  Please provide the local ip in --remote-webserver"
             return None
@@ -161,70 +161,70 @@ class RemoteOptions(ReftestOptions):
 
         # httpd-path is specified by standard makefile targets and may be specified
         # on the command line to select a particular version of httpd.js. If not
         # specified, try to select the one from hostutils.zip, as required in bug 882932.
         if not options.httpdPath:
             options.httpdPath = os.path.join(options.utilityPath, "components")
 
         # TODO: Copied from main, but I think these are no longer used in a post xulrunner world
-        #options.xrePath = options.remoteTestRoot + self.automation._product + '/xulrunner'
-        #options.utilityPath = options.testRoot + self.automation._product + '/bin'
+        #options.xrePath = options.remoteTestRoot + self._automation._product + '/xulrunner'
+        #options.utilityPath = options.testRoot + self._automation._product + '/bin'
         return options
 
 class ReftestServer:
     """ Web server used to serve Reftests, for closer fidelity to the real web.
         It is virtually identical to the server used in mochitest and will only
         be used for running reftests remotely.
         Bug 581257 has been filed to refactor this wrapper around httpd.js into
         it's own class and use it in both remote and non-remote testing. """
 
     def __init__(self, automation, options, scriptDir):
-        self.automation = automation
+        self._automation = automation
         self._utilityPath = options.utilityPath
         self._xrePath = options.xrePath
         self._profileDir = options.serverProfilePath
         self.webServer = options.remoteWebServer
         self.httpPort = options.httpPort
         self.scriptDir = scriptDir
         self.pidFile = options.pidFile
         self._httpdPath = os.path.abspath(options.httpdPath)
         self.shutdownURL = "http://%(server)s:%(port)s/server/shutdown" % { "server" : self.webServer, "port" : self.httpPort }
 
     def start(self):
         "Run the Refest server, returning the process ID of the server."
 
-        env = self.automation.environment(xrePath = self._xrePath)
+        env = self._automation.environment(xrePath = self._xrePath)
         env["XPCOM_DEBUG_BREAK"] = "warn"
-        if self.automation.IS_WIN32:
+        if self._automation.IS_WIN32:
             env["PATH"] = env["PATH"] + ";" + self._xrePath
 
         args = ["-g", self._xrePath,
                 "-v", "170",
                 "-f", os.path.join(self._httpdPath, "httpd.js"),
                 "-e", "const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = '%(port)s'; const _SERVER_ADDR ='%(server)s';" %
                        {"profile" : self._profileDir.replace('\\', '\\\\'), "port" : self.httpPort, "server" : self.webServer },
                 "-f", os.path.join(self.scriptDir, "server.js")]
 
         xpcshell = os.path.join(self._utilityPath,
-                                "xpcshell" + self.automation.BIN_SUFFIX)
+                                "xpcshell" + self._automation.BIN_SUFFIX)
 
         if not os.access(xpcshell, os.F_OK):
             raise Exception('xpcshell not found at %s' % xpcshell)
-        if self.automation.elf_arm(xpcshell):
+        if self._automation.elf_arm(xpcshell):
             raise Exception('xpcshell at %s is an ARM binary; please use '
                             'the --utility-path argument to specify the path '
                             'to a desktop version.' % xpcshell)
 
-        self._process = self.automation.Process([xpcshell] + args, env = env)
+        self._process = self._automation.Process([xpcshell] + args, env = env)
         pid = self._process.pid
         if pid < 0:
             print "TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server."
             return 2
-        self.automation.log.info("INFO | remotereftests.py | Server pid: %d", pid)
+        self._automation.log.info("INFO | remotereftests.py | Server pid: %d", pid)
 
         if (self.pidFile != ""):
             f = open(self.pidFile + ".xpcshell.pid", 'w')
             f.write("%s" % pid)
             f.close()
 
     def ensureReady(self, timeout):
         assert timeout >= 0
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -1,38 +1,33 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 """
 Runs the reftest test harness.
 """
 
-from optparse import OptionParser
-import collections
-import json
-import multiprocessing
+import re
+import sys
+import shutil
 import os
-import re
-import shutil
+import threading
 import subprocess
-import sys
-import threading
-
+import collections
+import multiprocessing
 SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
 sys.path.insert(0, SCRIPT_DIRECTORY)
 
+from automation import Automation
+from automationutils import *
+from optparse import OptionParser
+from tempfile import mkdtemp
+
 import mozprofile
-from automation import Automation
-from automationutils import (
-        addCommonOptions,
-        getDebuggerInfo,
-        isURL,
-        processLeakLog
-)
 
 def categoriesToRegex(categoryList):
   return "\\(" + ', '.join(["(?P<%s>\\d+) %s" % c for c in categoryList]) + "\\)"
 summaryLines = [('Successful', [('pass', 'pass'), ('loadOnly', 'load only')]),
                 ('Unexpected', [('fail', 'unexpected fail'),
                                 ('pass', 'unexpected pass'),
                                 ('asserts', 'unexpected asserts'),
                                 ('fixedAsserts', 'unexpected fixed asserts'),
@@ -129,21 +124,21 @@ class RefTest(object):
         if os.path.exists(defaultManifestPath):
           path = defaultManifestPath
     return path
 
   def makeJSString(self, s):
     return '"%s"' % re.sub(r'([\\"])', r'\\\1', s)
 
   def createReftestProfile(self, options, manifest, server='localhost',
-                           special_powers=True, profile_to_clone=None):
+                           special_powers=True):
     """
       Sets up a profile for reftest.
       'manifest' is the path to the reftest.list file we want to test with.  This is used in
-      the remote subclass in remotereftest.py so we can write it to a preference for the
+      the remote subclass in remotereftest.py so we can write it to a preference for the 
       bootstrap extension.
     """
 
     locations = mozprofile.permissions.ServerLocations()
     locations.add_host(server, port=0)
     locations.add_host('<file>', port=0)
 
     # Set preferences for communication between our command line arguments
@@ -184,37 +179,34 @@ class RefTest(object):
     if os.path.isdir(distExtDir):
       for f in os.listdir(distExtDir):
         addons.append(os.path.join(distExtDir, f))
 
     # Install custom extensions.
     for f in options.extensionsToInstall:
       addons.append(self.getFullPath(f))
 
-    kwargs = { 'addons': addons,
-               'preferences': prefs,
-               'locations': locations }
-    if profile_to_clone:
-        profile = mozprofile.Profile.clone(profile_to_clone, **kwargs)
-    else:
-        profile = mozprofile.Profile(**kwargs)
-
+    profile = mozprofile.profile.Profile(
+        addons=addons,
+        preferences=prefs,
+        locations=locations,
+    )
     self.copyExtraFilesToProfile(options, profile)
     return profile
 
   def buildBrowserEnv(self, options, profileDir):
     browserEnv = self.automation.environment(xrePath = options.xrePath)
     browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
 
     for v in options.environment:
       ix = v.find("=")
       if ix <= 0:
         print "Error: syntax error in --setenv=" + v
         return None
-      browserEnv[v[:ix]] = v[ix + 1:]
+      browserEnv[v[:ix]] = v[ix + 1:]    
 
     # Enable leaks detection to its own log file.
     self.leakLogFile = os.path.join(profileDir, "runreftest_leaks.log")
     browserEnv["XPCOM_MEM_BLOAT_LOG"] = self.leakLogFile
     return browserEnv
 
   def cleanup(self, profileDir):
     if profileDir:
@@ -341,68 +333,68 @@ class RefTest(object):
         shutil.copytree(abspath, dest)
       else:
         self.automation.log.warning("WARNING | runreftest.py | Failed to copy %s to profile", abspath)
         continue
 
 
 class ReftestOptions(OptionParser):
 
-  def __init__(self, automation=None):
-    self.automation = automation or Automation()
+  def __init__(self, automation):
+    self._automation = automation
     OptionParser.__init__(self)
     defaults = {}
 
     # we want to pass down everything from automation.__all__
-    addCommonOptions(self,
-                     defaults=dict(zip(self.automation.__all__,
-                            [getattr(self.automation, x) for x in self.automation.__all__])))
-    self.automation.addCommonOptions(self)
+    addCommonOptions(self, 
+                     defaults=dict(zip(self._automation.__all__, 
+                            [getattr(self._automation, x) for x in self._automation.__all__])))
+    self._automation.addCommonOptions(self)
     self.add_option("--appname",
                     action = "store", type = "string", dest = "app",
                     default = os.path.join(SCRIPT_DIRECTORY, automation.DEFAULT_APP),
                     help = "absolute path to application, overriding default")
     self.add_option("--extra-profile-file",
                     action = "append", dest = "extraProfileFiles",
                     default = [],
                     help = "copy specified files/dirs to testing profile")
-    self.add_option("--timeout",
-                    action = "store", dest = "timeout", type = "int",
+    self.add_option("--timeout",              
+                    action = "store", dest = "timeout", type = "int", 
                     default = 5 * 60, # 5 minutes per bug 479518
                     help = "reftest will timeout in specified number of seconds. [default %default s].")
     self.add_option("--leak-threshold",
                     action = "store", type = "int", dest = "leakThreshold",
                     default = 0,
                     help = "fail if the number of bytes leaked through "
                            "refcounted objects (or bytes in classes with "
                            "MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater "
                            "than the given number")
     self.add_option("--utility-path",
                     action = "store", type = "string", dest = "utilityPath",
-                    default = self.automation.DIST_BIN,
+                    default = self._automation.DIST_BIN,
                     help = "absolute path to directory containing utility "
                            "programs (xpcshell, ssltunnel, certutil)")
-    defaults["utilityPath"] = self.automation.DIST_BIN
+    defaults["utilityPath"] = self._automation.DIST_BIN
 
     self.add_option("--total-chunks",
                     type = "int", dest = "totalChunks",
                     help = "how many chunks to split the tests up into")
     defaults["totalChunks"] = None
 
     self.add_option("--this-chunk",
                     type = "int", dest = "thisChunk",
                     help = "which chunk to run between 1 and --total-chunks")
     defaults["thisChunk"] = None
 
     self.add_option("--log-file",
                     action = "store", type = "string", dest = "logFile",
                     default = None,
                     help = "file to log output to in addition to stdout")
     defaults["logFile"] = None
-
+ 
     self.add_option("--skip-slow-tests",
                     dest = "skipSlowTests", action = "store_true",
                     help = "skip tests marked as slow when running")
     defaults["skipSlowTests"] = False
 
     self.add_option("--ignore-window-size",
                     dest = "ignoreWindowSize", action = "store_true",
                     help = "ignore the window size, which may cause spurious failures and passes")
--- a/layout/tools/reftest/runreftestb2g.py
+++ b/layout/tools/reftest/runreftestb2g.py
@@ -4,28 +4,29 @@
 
 import ConfigParser
 import os
 import sys
 import tempfile
 import traceback
 
 # We need to know our current directory so that we can serve our test files from it.
-here = os.path.abspath(os.path.dirname(__file__))
+SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
+sys.path.insert(0, SCRIPT_DIRECTORY)
 
 from automation import Automation
 from b2gautomation import B2GRemoteAutomation
-from b2g_desktop import run_desktop_reftests
 from runreftest import RefTest
 from runreftest import ReftestOptions
 from remotereftest import ReftestServer
 
 from mozdevice import DeviceManagerADB, DMError
 from marionette import Marionette
 
+
 class B2GOptions(ReftestOptions):
 
     def __init__(self, automation=None, **kwargs):
         defaults = {}
         if not automation:
             automation = B2GRemoteAutomation(None, "fennec", context_chrome=True)
 
         ReftestOptions.__init__(self, automation)
@@ -105,49 +106,40 @@ class B2GOptions(ReftestOptions):
         self.add_option('--busybox', action='store',
                         type='string', dest='busybox',
                         help="Path to busybox binary to install on device")
         defaults['busybox'] = None
         self.add_option("--httpd-path", action = "store",
                     type = "string", dest = "httpdPath",
                     help = "path to the httpd.js file")
         defaults["httpdPath"] = None
-        self.add_option("--profile", action="store",
-                    type="string", dest="profile",
-                    help="for desktop testing, the path to the "
-                         "gaia profile to use")
-        defaults["profile"] = None
-        self.add_option("--desktop", action="store_true",
-                        dest="desktop",
-                        help="Run the tests on a B2G desktop build")
-        defaults["desktop"] = False
         defaults["remoteTestRoot"] = "/data/local/tests"
         defaults["logFile"] = "reftest.log"
         defaults["autorun"] = True
         defaults["closeWhenDone"] = True
         defaults["testPath"] = ""
         defaults["runTestsInParallel"] = False
 
         self.set_defaults(**defaults)
 
     def verifyRemoteOptions(self, options):
         if options.runTestsInParallel:
             self.error("Cannot run parallel tests here")
 
         if not options.remoteTestRoot:
-            options.remoteTestRoot = self.automation._devicemanager.getDeviceRoot() + "/reftest"
+            options.remoteTestRoot = self._automation._devicemanager.getDeviceRoot() + "/reftest"
         options.remoteProfile = options.remoteTestRoot + "/profile"
 
-        productRoot = options.remoteTestRoot + "/" + self.automation._product
-        if options.utilityPath == self.automation.DIST_BIN:
+        productRoot = options.remoteTestRoot + "/" + self._automation._product
+        if options.utilityPath == self._automation.DIST_BIN:
             options.utilityPath = productRoot + "/bin"
 
         if options.remoteWebServer == None:
             if os.name != "nt":
-                options.remoteWebServer = self.automation.getLanIp()
+                options.remoteWebServer = self._automation.getLanIp()
             else:
                 print "ERROR: you must specify a --remote-webserver=<ip address>\n"
                 return None
 
         options.webServer = options.remoteWebServer
 
         if options.geckoPath and not options.emulator:
             self.error("You must specify --emulator if you specify --gecko-path")
@@ -212,40 +204,43 @@ class ProfileConfigParser(ConfigParser.R
             for (key, value) in self._sections[section].items():
                 if key == "__name__":
                     continue
                 if (value is not None) or (self._optcre == self.OPTCRE):
                     key = "=".join((key, str(value).replace('\n', '\n\t')))
                 fp.write("%s\n" % (key))
             fp.write("\n")
 
-class B2GRemoteReftest(RefTest):
 
+class B2GReftest(RefTest):
+
+    _automation = None
     _devicemanager = None
     localProfile = None
     remoteApp = ''
     profile = None
 
     def __init__(self, automation, devicemanager, options, scriptDir):
-        RefTest.__init__(self, automation)
+        self._automation = automation
+        RefTest.__init__(self, self._automation)
         self._devicemanager = devicemanager
         self.runSSLTunnel = False
         self.remoteTestRoot = options.remoteTestRoot
         self.remoteProfile = options.remoteProfile
-        self.automation.setRemoteProfile(self.remoteProfile)
+        self._automation.setRemoteProfile(self.remoteProfile)
         self.localLogName = options.localLogName
         self.remoteLogFile = options.remoteLogFile
         self.bundlesDir = '/system/b2g/distribution/bundles'
         self.userJS = '/data/local/user.js'
         self.remoteMozillaPath = '/data/b2g/mozilla'
         self.remoteProfilesIniPath = os.path.join(self.remoteMozillaPath, 'profiles.ini')
         self.originalProfilesIni = None
         self.scriptDir = scriptDir
         self.SERVER_STARTUP_TIMEOUT = 90
-        if self.automation.IS_DEBUG_BUILD:
+        if self._automation.IS_DEBUG_BUILD:
             self.SERVER_STARTUP_TIMEOUT = 180
 
     def cleanup(self, profileDir):
         # Pull results back from device
         if (self.remoteLogFile):
             try:
                 self._devicemanager.getFile(self.remoteLogFile, self.localLogName)
             except:
@@ -259,34 +254,34 @@ class B2GRemoteReftest(RefTest):
                 self._devicemanager._checkCmdAs(['shell', 'rm', '-rf',
                                                  os.path.join(self.bundlesDir, filename)])
             except DMError:
                 pass
 
         # Restore the original profiles.ini.
         if self.originalProfilesIni:
             try:
-                if not self.automation._is_emulator:
+                if not self._automation._is_emulator:
                     self.restoreProfilesIni()
                 os.remove(self.originalProfilesIni)
             except:
                 pass
 
-        if not self.automation._is_emulator:
+        if not self._automation._is_emulator:
             self._devicemanager.removeFile(self.remoteLogFile)
             self._devicemanager.removeDir(self.remoteProfile)
             self._devicemanager.removeDir(self.remoteTestRoot)
 
             # Restore the original user.js.
             self._devicemanager._checkCmdAs(['shell', 'rm', '-f', self.userJS])
             self._devicemanager._checkCmdAs(['shell', 'dd', 'if=%s.orig' % self.userJS, 'of=%s' % self.userJS])
 
             # We've restored the original profile, so reboot the device so that
             # it gets picked up.
-            self.automation.rebootDevice()
+            self._automation.rebootDevice()
 
         RefTest.cleanup(self, profileDir)
         if getattr(self, 'pidFile', '') != '':
             try:
                 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
@@ -317,18 +312,18 @@ class B2GRemoteReftest(RefTest):
             localAutomation.IS_LINUX = True
             localAutomation.UNIXISH = True
         elif hostos in ['win32', 'win64']:
             localAutomation.BIN_SUFFIX = ".exe"
             localAutomation.IS_WIN32 = True
 
         paths = [options.xrePath,
                  localAutomation.DIST_BIN,
-                 self.automation._product,
-                 os.path.join('..', self.automation._product)]
+                 self._automation._product,
+                 os.path.join('..', self._automation._product)]
         options.xrePath = self.findPath(paths)
         if options.xrePath == None:
             print "ERROR: unable to find xulrunner path for %s, please specify with --xre-path" % (os.name)
             sys.exit(1)
         paths.append("bin")
         paths.append(os.path.join("..", "bin"))
 
         xpcshell = "xpcshell"
@@ -338,17 +333,17 @@ class B2GRemoteReftest(RefTest):
         if (options.utilityPath):
             paths.insert(0, options.utilityPath)
         options.utilityPath = self.findPath(paths, xpcshell)
         if options.utilityPath == None:
             print "ERROR: unable to find utility path for %s, please specify with --utility-path" % (os.name)
             sys.exit(1)
 
         xpcshell = os.path.join(options.utilityPath, xpcshell)
-        if self.automation.elf_arm(xpcshell):
+        if self._automation.elf_arm(xpcshell):
             raise Exception('xpcshell at %s is an ARM binary; please use '
                             'the --utility-path argument to specify the path '
                             'to a desktop version.' % xpcshell)
 
         options.serverProfilePath = tempfile.mkdtemp()
         self.server = ReftestServer(localAutomation, options, self.scriptDir)
         retVal = self.server.start()
         if retVal:
@@ -367,16 +362,17 @@ class B2GRemoteReftest(RefTest):
         options.utilityPath = remoteUtilityPath
         options.profilePath = remoteProfilePath
         return 0
 
     def stopWebServer(self, options):
         if hasattr(self, 'server'):
             self.server.stop()
 
+
     def restoreProfilesIni(self):
         # restore profiles.ini on the device to its previous state
         if not self.originalProfilesIni or not os.access(self.originalProfilesIni, os.F_OK):
             raise DMError('Unable to install original profiles.ini; file not found: %s',
                           self.originalProfilesIni)
 
         self._devicemanager.pushFile(self.originalProfilesIni, self.remoteProfilesIniPath)
 
@@ -469,17 +465,16 @@ class B2GRemoteReftest(RefTest):
             self._devicemanager.pushDir(profileDir, options.remoteProfile)
         except DMError:
             print "Automation Error: Failed to copy extra files to device"
             raise
 
     def getManifestPath(self, path):
         return path
 
-
 def run_remote_reftests(parser, options, args):
     auto = B2GRemoteAutomation(None, "fennec", context_chrome=True)
 
     # create our Marionette instance
     kwargs = {}
     if options.emulator:
         kwargs['emulator'] = options.emulator
         auto.setEmulator(True)
@@ -525,37 +520,37 @@ def run_remote_reftests(parser, options,
         parts = dm.getInfo('screen')['screen'][0].split()
         width = int(parts[0].split(':')[1])
         height = int(parts[1].split(':')[1])
         if (width < 1366 or height < 1050):
             print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height)
             return 1
 
     auto.setProduct("b2g")
-    auto.test_script = os.path.join(here, 'b2g_start_script.js')
+    auto.test_script = os.path.join(SCRIPT_DIRECTORY, 'b2g_start_script.js')
     auto.test_script_args = [options.remoteWebServer, options.httpPort]
     auto.logFinish = "REFTEST TEST-START | Shutdown"
 
-    reftest = B2GRemoteReftest(auto, dm, options, here)
+    reftest = B2GReftest(auto, dm, options, SCRIPT_DIRECTORY)
     options = parser.verifyCommonOptions(options, reftest)
 
     logParent = os.path.dirname(options.remoteLogFile)
     dm.mkDir(logParent);
     auto.setRemoteLog(options.remoteLogFile)
     auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
 
     # Hack in a symbolic link for jsreftest
-    os.system("ln -s %s %s" % (os.path.join('..', 'jsreftest'), os.path.join(here, 'jsreftest')))
+    os.system("ln -s %s %s" % (os.path.join('..', 'jsreftest'), os.path.join(SCRIPT_DIRECTORY, 'jsreftest')))
 
     # Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot
     manifest = args[0]
-    if os.path.exists(os.path.join(here, args[0])):
+    if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])):
         manifest = "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, args[0])
     elif os.path.exists(args[0]):
-        manifestPath = os.path.abspath(args[0]).split(here)[1].strip('/')
+        manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/')
         manifest = "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, manifestPath)
     else:
         print "ERROR: Could not find test manifest '%s'" % manifest
         return 1
 
     # Start the webserver
     retVal = 1
     try:
@@ -582,17 +577,14 @@ def run_remote_reftests(parser, options,
         return 1
 
     reftest.stopWebServer(options)
     return retVal
 
 def main(args=sys.argv[1:]):
     parser = B2GOptions()
     options, args = parser.parse_args(args)
-
-    if options.desktop:
-        return run_desktop_reftests(parser, options, args)
     return run_remote_reftests(parser, options, args)
 
 
 if __name__ == "__main__":
     sys.exit(main())
 
--- a/testing/mozbase/mozrunner/mozrunner/local.py
+++ b/testing/mozbase/mozrunner/mozrunner/local.py
@@ -68,26 +68,26 @@ def debugger_arguments(debugger, argumen
 
 class LocalRunner(Runner):
     """Handles all running operations. Finds bins, runs and kills the process."""
 
     profile_class = Profile # profile class to use by default
 
     @classmethod
     def create(cls, binary=None, cmdargs=None, env=None, kp_kwargs=None, profile_args=None,
-               clean_profile=True, process_class=None, **kwargs):
+               clean_profile=True, process_class=None):
         profile = cls.profile_class(**(profile_args or {}))
         return cls(profile, binary=binary, cmdargs=cmdargs, env=env, kp_kwargs=kp_kwargs,
-                                           clean_profile=clean_profile, process_class=process_class, **kwargs)
+                                           clean_profile=clean_profile, process_class=process_class)
 
     def __init__(self, profile, binary, cmdargs=None, env=None,
-                 kp_kwargs=None, clean_profile=None, process_class=None, **kwargs):
+                 kp_kwargs=None, clean_profile=None, process_class=None):
 
         super(LocalRunner, self).__init__(profile, clean_profile=clean_profile, kp_kwargs=kp_kwargs,
-                                          process_class=process_class, env=env, **kwargs)
+                                               process_class=process_class, env=env)
 
         # find the binary
         self.binary = binary
         if not self.binary:
             raise Exception("Binary not specified")
         if not os.path.exists(self.binary):
             raise OSError("Binary path does not exist: %s" % self.binary)
 
--- a/testing/mozbase/mozrunner/mozrunner/runner.py
+++ b/testing/mozbase/mozrunner/mozrunner/runner.py
@@ -1,14 +1,13 @@
 #!/usr/bin/env 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/.
-
-import os
 import subprocess
 import traceback
 
 from mozprocess.processhandler import ProcessHandler
 import mozcrash
 import mozlog
 
 # we can replace this method with 'abc'
@@ -34,16 +33,17 @@ class Runner(object):
         self.kp_kwargs = kp_kwargs or {}
         self.process_class = process_class or ProcessHandler
         self.process_handler = None
         self.returncode = None
         self.profile = profile
         self.log = mozlog.getLogger('MozRunner')
         self.symbols_path = symbols_path
 
+    @abstractmethod
     def start(self, *args, **kwargs):
         """
         Run the process
         """
 
         # ensure you are stopped
         self.stop()
 
@@ -107,20 +107,17 @@ class Runner(object):
 
     def reset(self):
         """
         Reset the runner to its default state
         """
         if getattr(self, 'profile', False):
             self.profile.reset()
 
-    def check_for_crashes(self, dump_directory=None, test_name=None):
-        if not dump_directory:
-            dump_directory = os.path.join(self.profile.profile, 'minidumps')
-
+    def check_for_crashes(self, dump_directory, test_name=None):
         crashed = False
         try:
             crashed = mozcrash.check_for_crashes(dump_directory,
                                                  self.symbols_path,
                                                  test_name=test_name)
         except:
             traceback.print_exc()
         return crashed