Bug 963838 - Pass correct app name to automation in Android tests; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Sun, 02 Feb 2014 08:11:22 -0700
changeset 183998 c11048f7a6032d833369fe0c2e3a12e1ed978813
parent 183997 ea2e099d80e2b1be2fb37b7418210ffff76eab08
child 183999 5292116983698d54ee79687105d0ab0da92872a1
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs963838
milestone30.0a1
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 963838 - Pass correct app name to automation in Android tests; r=jmaher
build/mobile/remoteautomation.py
testing/mochitest/runtestsremote.py
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -171,58 +171,38 @@ class RemoteAutomation(Automation):
         return app, args
 
     def getLanIp(self):
         nettools = NetworkTools()
         return nettools.getLanIp()
 
     def Process(self, cmd, stdout = None, stderr = None, env = None, cwd = None):
         if stdout == None or stdout == -1 or stdout == subprocess.PIPE:
-          stdout = self._remoteLog
+            stdout = self._remoteLog
 
-        return self.RProcess(self._devicemanager, cmd, stdout, stderr, env, cwd)
+        return self.RProcess(self._devicemanager, cmd, stdout, stderr, env, cwd, self._appName)
 
     # be careful here as this inner class doesn't have access to outer class members
     class RProcess(object):
         # device manager process
         dm = None
-        def __init__(self, dm, cmd, stdout = None, stderr = None, env = None, cwd = None):
+        def __init__(self, dm, cmd, stdout = None, stderr = None, env = None, cwd = None, app = None):
             self.dm = dm
             self.stdoutlen = 0
             self.lastTestSeen = "remoteautomation.py"
             self.proc = dm.launchProcess(cmd, stdout, cwd, env, True)
             if (self.proc is None):
-              if cmd[0] == 'am':
-                self.proc = stdout
-              else:
-                raise Exception("unable to launch process")
-            exepath = cmd[0]
-            name = exepath.split('/')[-1]
-            self.procName = name
-            # Hack for Robocop: Derive the actual process name from the command line.
-            # We expect something like:
-            #  ['am', 'instrument', '-w', '-e', 'class', 'org.mozilla.fennec.tests.testBookmark', 'org.mozilla.roboexample.test/android.test.InstrumentationTestRunner']
-            # and want to derive 'org.mozilla.fennec'.
+                if cmd[0] == 'am':
+                    self.proc = stdout
+                else:
+                    raise Exception("unable to launch process")
+            self.procName = cmd[0].split('/')[-1]
             if cmd[0] == 'am' and cmd[1] == "instrument":
-              try:
-                i = cmd.index("class")
-              except ValueError:
-                # no "class" argument -- maybe this isn't robocop?
-                i = -1
-              if (i > 0):
-                classname = cmd[i+1]
-                parts = classname.split('.')
-                try:
-                  i = parts.index("tests")
-                except ValueError:
-                  # no "tests" component -- maybe this isn't robocop?
-                  i = -1
-                if (i > 0):
-                  self.procName = '.'.join(parts[0:i])
-                  print "Robocop derived process name: "+self.procName
+                self.procName = app
+                print "Robocop process name: "+self.procName
 
             # Setting timeout at 1 hour since on a remote device this takes much longer
             self.timeout = 3600
             # The benefit of the following sleep is unclear; it was formerly 15 seconds
             time.sleep(1)
 
         @property
         def pid(self):
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -558,16 +558,17 @@ def main():
         log.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])
     else:
         auto.setProduct(options.remoteProductName)
+    auto.setAppName(options.remoteappname)
 
     mochitest = MochiRemote(auto, dm, options)
 
     options = parser.verifyOptions(options, mochitest)
     if (options == None):
         sys.exit(1)
     
     logParent = os.path.dirname(options.remoteLogFile)
@@ -589,18 +590,17 @@ def main():
         dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
         dm.removeFile(dmdPathOnDevice)
         dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
         options.dmdPath = deviceRoot
 
     options.dumpOutputDirectory = deviceRoot
 
     procName = options.app.split('/')[-1]
-    if (dm.processExist(procName)):
-        dm.killProcess(procName)
+    dm.killProcess(procName)
 
     if options.robocopIni != "":
         # sut may wait up to 300 s for a robocop am process before returning
         dm.default_timeout = 320
         mp = manifestparser.TestManifest(strict=False)
         # TODO: pull this in dynamically
         mp.read(options.robocopIni)
         robocop_tests = mp.active_tests(exists=False, **mozinfo.info)