Bug 573263 - Refactor remote reftest to work on android, create shared remoteautomation class r=jmaher
authorClint Talbert <ctalbert@mozilla.com>
Thu, 24 Jun 2010 02:32:01 -0700
changeset 46151 abddae3485f93dbc0c5ea3f58c74fc6a8a0a0f34
parent 46150 323c9405300945ade2cd74b002ec1bfc0717254a
child 46152 68d98f30eda0168041cc8e82dab380e3f47cc748
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs573263
milestone1.9.3a6pre
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
Bug 573263 - Refactor remote reftest to work on android, create shared remoteautomation class r=jmaher
testing/mochitest/runtestsremote.py
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -181,58 +181,58 @@ class MochiRemote(Mochitest):
         self.remoteLog = options.remoteLogFile
 
     def cleanup(self, manifest, options):
         self._dm.getFile(self.remoteLog, self.localLog)
         self._dm.removeFile(self.remoteLog)
         self._dm.removeDir(self.remoteProfile)
 
     def findPath(self, paths, filename = None):
-      for path in paths:
-        p = path
-        if filename:
-          p = os.path.join(p, filename)
-        if os.path.exists(self.getFullPath(p)):
-          return path
-      return None
+        for path in paths:
+            p = path
+            if filename:
+                p = os.path.join(p, filename)
+            if os.path.exists(self.getFullPath(p)):
+                return path
+        return None
 
     def startWebServer(self, options):
-      """ Create the webserver on the host and start it up """
-      remoteXrePath = options.xrePath
-      remoteProfilePath = options.profilePath
-      remoteUtilityPath = options.utilityPath
-      localAutomation = Automation()
+        """ Create the webserver on the host and start it up """
+        remoteXrePath = options.xrePath
+        remoteProfilePath = options.profilePath
+        remoteUtilityPath = options.utilityPath
+        localAutomation = Automation()
 
-      paths = [options.xrePath, localAutomation.DIST_BIN, 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"))
+        paths = [options.xrePath, localAutomation.DIST_BIN, 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"
-      if (os.name == "nt"):
-        xpcshell += ".exe"
+        xpcshell = "xpcshell"
+        if (os.name == "nt"):
+            xpcshell += ".exe"
       
-      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)
+        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)
 
-      options.profilePath = tempfile.mkdtemp()
-      self.server = MochitestServer(localAutomation, options)
-      self.server.start()
+        options.profilePath = tempfile.mkdtemp()
+        self.server = MochitestServer(localAutomation, options)
+        self.server.start()
 
-      self.server.ensureReady(self.SERVER_STARTUP_TIMEOUT)
-      options.xrePath = remoteXrePath
-      options.utilityPath = remoteUtilityPath
-      options.profilePath = remoteProfilePath
+        self.server.ensureReady(self.SERVER_STARTUP_TIMEOUT)
+        options.xrePath = remoteXrePath
+        options.utilityPath = remoteUtilityPath
+        options.profilePath = remoteProfilePath
          
     def stopWebServer(self, options):
         self.server.stop()
         
     def buildProfile(self, options):
         manifest = Mochitest.buildProfile(self, options)
         self.localProfile = options.profilePath
         if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
@@ -277,63 +277,63 @@ class MochiRemote(Mochitest):
 
     def getLogFilePath(self, logFile):             
         return logFile
 
 #
 # utilities to get the local ip address
 #
 if os.name != "nt":
-  import fcntl
-  import struct
-  def get_interface_ip(ifname):
-      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-      return socket.inet_ntoa(fcntl.ioctl(
-                      s.fileno(),
-                      0x8915,  # SIOCGIFADDR
-                      struct.pack('256s', ifname[:15])
-                      )[20:24])
+    import fcntl
+    import struct
+    def get_interface_ip(ifname):
+        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        return socket.inet_ntoa(fcntl.ioctl(
+                                s.fileno(),
+                                0x8915,  # SIOCGIFADDR
+                                struct.pack('256s', ifname[:15])
+                                )[20:24])
 
 def get_lan_ip():
-  ip = socket.gethostbyname(socket.gethostname())
-  if ip.startswith("127.") and os.name != "nt":
-    interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
-    for ifname in interfaces:
-      try:
-        ip = get_interface_ip(ifname)
-        break;
-      except IOError:
-        pass
-  return ip
+    ip = socket.gethostbyname(socket.gethostname())
+    if ip.startswith("127.") and os.name != "nt":
+        interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
+        for ifname in interfaces:
+            try:
+                ip = get_interface_ip(ifname)
+                break;
+            except IOError:
+                pass
+    return ip
 
 
 def main():
     scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
     dm = devicemanager.DeviceManager(None, None)
     auto = RemoteAutomation(dm, "fennec")
     parser = RemoteOptions(auto, scriptdir)
     options, args = parser.parse_args()
 
     dm = devicemanager.DeviceManager(options.deviceIP, options.devicePort)
     auto.setDeviceManager(dm)
     options = parser.verifyRemoteOptions(options, auto)
     if (options == None):
-      print "ERROR: Invalid options specified, use --help for a list of valid options"
-      sys.exit(1)
+        print "ERROR: Invalid options specified, use --help for a list of valid options"
+        sys.exit(1)
 
     productPieces = options.remoteProductName.split('.')
     if (productPieces != None):
-      auto.setProduct(productPieces[0])
+        auto.setProduct(productPieces[0])
     else:
-      auto.setProduct(options.remoteProductName)
+        auto.setProduct(options.remoteProductName)
 
     mochitest = MochiRemote(auto, dm, options)
 
     options = parser.verifyOptions(options, mochitest)
     if (options == None):
-      sys.exit(1)
+        sys.exit(1)
     
     auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
     sys.exit(mochitest.runTests(options))
     
 if __name__ == "__main__":
-  main()
+    main()