Bug 705175: update devicemanager, devicemanagerSUT versions of getAppRoot; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Sat, 07 Jan 2012 18:41:08 -0500
changeset 84013 33359378d8f80f88796c969cd30e862f46191fce
parent 84012 96e27b40144f46820485497a2bc343d0fa7a5dd5
child 84014 23d71e342b3e8d1d5afe4942001a1547d5c3f06b
push id4680
push userjmaher@mozilla.com
push dateSat, 07 Jan 2012 23:45:20 +0000
treeherdermozilla-inbound@33359378d8f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs705175
milestone12.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 705175: update devicemanager, devicemanagerSUT versions of getAppRoot; r=jmaher
build/mobile/devicemanager.py
build/mobile/devicemanagerADB.py
build/mobile/devicemanagerSUT.py
build/mobile/sutagent/android/DoCommand.java
testing/xpcshell/remotexpcshelltests.py
--- a/build/mobile/devicemanager.py
+++ b/build/mobile/devicemanager.py
@@ -341,34 +341,17 @@ class DeviceManager:
   # Either we will have /tests/fennec or /tests/firefox but we will never have
   # both.  Return the one that exists
   # TODO: ensure we can support org.mozilla.firefox
   # external function
   # returns:
   #  success: path for app root
   #  failure: None
   def getAppRoot(self):
-    devroot = self.getDeviceRoot()
-    if (devroot == None):
-      return None
-
-    if (self.dirExists(devroot + '/fennec')):
-      return devroot + '/fennec'
-    elif (self.dirExists(devroot + '/firefox')):
-      return devroot + '/firefox'
-    elif (self.dirExsts('/data/data/org.mozilla.fennec')):
-      return 'org.mozilla.fennec'
-    elif (self.dirExists('/data/data/org.mozilla.firefox')):
-      return 'org.mozilla.firefox'
-    elif (self.dirExists('/data/data/org.mozilla.fennec_aurora')):
-      return 'org.mozilla.fennec_aurora'
-    elif (self.dirExists('/data/data/org.mozilla.firefox_beta')):
-      return 'org.mozilla.firefox_beta'
-
-    # Failure (either not installed or not a recognized platform)
+    assert 0 == 1
     return None
 
   # Gets the directory location on the device for a specific test type
   # Type is one of: xpcshell|reftest|mochitest
   # external function
   # returns:
   #  success: path for test root
   #  failure: None
--- a/build/mobile/devicemanagerADB.py
+++ b/build/mobile/devicemanagerADB.py
@@ -421,25 +421,24 @@ class DeviceManagerADB(DeviceManager):
 
   # Either we will have /tests/fennec or /tests/firefox but we will never have
   # both.  Return the one that exists
   # TODO: ensure we can support org.mozilla.firefox
   # external function
   # returns:
   #  success: path for app root
   #  failure: None
-  def getAppRoot(self):
+  def getAppRoot(self, packageName):
     devroot = self.getDeviceRoot()
     if (devroot == None):
       return None
 
-    if (self.dirExists(devroot + '/fennec')):
-      return devroot + '/fennec'
-    elif (self.dirExists(devroot + '/firefox')):
-      return devroot + '/firefox'
+    if (packageName and self.dirExists('/data/data/' + packageName)):
+      self.packageName = packageName
+      return '/data/data/' + packageName
     elif (self.packageName and self.dirExists('/data/data/' + self.packageName)):
       return '/data/data/' + self.packageName
 
     # Failure (either not installed or not a recognized platform)
     print "devicemanagerADB: getAppRoot failed"
     return None
 
   # Gets the directory location on the device for a specific test type
--- a/build/mobile/devicemanagerSUT.py
+++ b/build/mobile/devicemanagerSUT.py
@@ -853,16 +853,25 @@ class DeviceManagerSUT(DeviceManager):
     deviceRoot = self.stripPrompt(data).strip('\n') + '/tests'
 
     if (not self.dirExists(deviceRoot)):
       if (self.mkDir(deviceRoot) == None):
         return None
 
     return deviceRoot
 
+  def getAppRoot(self, packageName):
+    try:
+      data = self.verifySendCMD(['getapproot '+packageName])
+    except:
+      return None
+  
+    appRoot = self.stripPrompt(data).strip('\n')
+    return appRoot
+
   # external function
   # returns:
   #  success: output of unzip command
   #  failure: None
   def unpackFile(self, filename):
     devroot = self.getDeviceRoot()
     if (devroot == None):
       return None
--- a/build/mobile/sutagent/android/DoCommand.java
+++ b/build/mobile/sutagent/android/DoCommand.java
@@ -132,17 +132,17 @@ public class DoCommand {
 
     String    currentDir = "/";
     String    sErrorPrefix = "##AGENT-WARNING## ";
     boolean bTraceOn = false;
 
     String ffxProvider = "org.mozilla.ffxcp";
     String fenProvider = "org.mozilla.fencp";
 
-    private final String prgVersion = "SUTAgentAndroid Version 1.03";
+    private final String prgVersion = "SUTAgentAndroid Version 1.04";
 
     public enum Command
         {
         RUN ("run"),
         EXEC ("exec"),
         ENVRUN ("envrun"),
         KILL ("kill"),
         PS ("ps"),
@@ -1280,17 +1280,17 @@ private void CancelNotification()
         String sRet = sErrorPrefix + " internal error [no context]";
         Context ctx = contextWrapper.getApplicationContext();
 
         if (ctx != null)
             {
             try {
                 Context appCtx = ctx.createPackageContext(AppName, 0);
                 ContextWrapper appCtxW = new ContextWrapper(appCtx);
-                sRet = appCtxW.getPackageResourcePath();
+                sRet = appCtxW.getApplicationInfo().dataDir;
                 appCtxW = null;
                 appCtx = null;
                 ctx = null;
                 System.gc();
                 }
             catch (NameNotFoundException e)
                 {
                 e.printStackTrace();
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -32,16 +32,17 @@
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK ***** */
 
 import re, sys, os
+import subprocess
 import runxpcshelltests as xpcshell
 from automationutils import *
 import devicemanager, devicemanagerADB, devicemanagerSUT
 
 # A specialization of XPCShellTests that runs tests on an Android device
 # via devicemanager.
 class XPCShellRemote(xpcshell.XPCShellTests, object):
 
@@ -61,16 +62,32 @@ class XPCShellRemote(xpcshell.XPCShellTe
         self.remoteComponentsDir = self.remoteJoin(self.remoteTestRoot, "c")
         self.profileDir = self.remoteJoin(self.remoteTestRoot, "p")
         if options.setup:
           self.setupUtilities()
           self.setupTestDir()
         self.remoteAPK = self.remoteJoin(self.remoteBinDir, os.path.basename(options.localAPK))
         self.remoteDebugger = options.debugger
         self.remoteDebuggerArgs = options.debuggerArgs  
+        self.setAppRoot()
+
+    def setAppRoot(self):
+        # Determine the application root directory associated with the package 
+        # name used by the Fennec APK.
+        self.appRoot = None
+        packageName = None
+        if self.options.localAPK:
+          try:
+            packageName = subprocess.check_output(["unzip", "-p", self.options.localAPK, "package-name.txt"])
+            if packageName:
+              self.appRoot = self.device.getAppRoot(packageName.strip())
+          except Exception as detail:
+            print "unable to determine app root: " + detail
+            pass
+        return None
 
     def remoteJoin(self, path1, path2):
         joined = os.path.join(path1, path2)
         joined = joined.replace('\\', '/')
         return joined
 
     def remoteForLocal(self, local):
         for mapping in self.pathMapping:
@@ -198,19 +215,19 @@ class XPCShellRemote(xpcshell.XPCShellTe
             cmd[index] = part
           index = index + 1
 
         xpcshell = self.remoteJoin(self.remoteBinDir, "xpcshell")
 
         shellArgs = "cd "+self.remoteHere
         shellArgs += "; LD_LIBRARY_PATH="+self.remoteBinDir
         shellArgs += "; export CACHE_PATH="+self.remoteBinDir
-        if (self.device.getAppRoot()):
+        if (self.appRoot):
           # xpcshell still runs without GRE_HOME; it may not be necessary
-          shellArgs += "; export GRE_HOME="+self.device.getAppRoot()
+          shellArgs += "; export GRE_HOME="+self.appRoot
         shellArgs += "; export XPCSHELL_TEST_PROFILE_DIR="+self.profileDir
         shellArgs += "; "+xpcshell+" "
         shellArgs += " ".join(cmd[1:])
 
         if self.verbose:
           self.log.info(shellArgs)
 
         # If the adb version of devicemanager is used and the arguments passed