Bug 728993 - Need to check output to capture run-as failure in devicemanagerADB. r=jmaher
authorChristian Holler <choller@mozilla.com>
Tue, 21 Feb 2012 11:13:54 -0500
changeset 87295 9964bcbdc4e2d33928b215dcb8518b5d3b22d16b
parent 87294 7dda043db5711bfc8665328e5a5d5a8924b4432f
child 87296 9bde0d25d76e4ef301668a8016f6edcba1662826
child 87318 bb68ca933ea8350a6f952e45130b9d6a6d34f0f3
push id22106
push userbmo@edmorley.co.uk
push dateTue, 21 Feb 2012 21:14:27 +0000
treeherdermozilla-central@9bde0d25d76e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs728993
milestone13.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 728993 - Need to check output to capture run-as failure in devicemanagerADB. r=jmaher
build/mobile/devicemanagerADB.py
--- a/build/mobile/devicemanagerADB.py
+++ b/build/mobile/devicemanagerADB.py
@@ -28,17 +28,17 @@ class DeviceManagerADB(DeviceManager):
   def Init(self, packageName):
     # Initialization code that may fail: Catch exceptions here to allow
     # successful initialization even if, for example, adb is not installed.
     try:
       self.verifyADB()
       self.verifyRunAs(packageName)
     except:
       self.useRunAs = False
-      self.packageName = None
+      self.packageName = packageName
     try:
       self.verifyZip()
     except:
       self.useZip = False
 
     def verifyRoot():
       # a test to see if we have root privs
       files = self.listFiles("/data/data")
@@ -679,17 +679,23 @@ class DeviceManagerADB(DeviceManager):
     # echoing conditions encountered by Fennec at run time.
     # Check to see if run-as can be used here, by verifying a 
     # file copy via run-as.
     self.useRunAs = False
     devroot = self.getDeviceRoot()
     if (packageName and self.isCpAvailable() and devroot):
       tmpDir = self.getTempDir()
 
-      self.checkCmd(["shell", "run-as", packageName, "mkdir", devroot + "/sanity"])
+      # The problem here is that run-as doesn't cause a non-zero exit code
+      # when failing because of a non-existent or non-debuggable package :(
+      runAsOut = self.runCmd(["shell", "run-as", packageName, "mkdir", devroot + "/sanity"]).communicate()[0]
+      if runAsOut.startswith("run-as:") and ("not debuggable" in runAsOut[0] or
+                                             "is unknown" in runAsOut[0]):
+        raise DMError("run-as failed sanity check")
+
       self.checkCmd(["push", os.path.abspath(sys.argv[0]), tmpDir + "/tmpfile"])
       if self.useDDCopy:
         self.checkCmd(["shell", "run-as", packageName, "dd", "if=" + tmpDir + "/tmpfile", "of=" + devroot + "/sanity/tmpfile"])
       else:
         self.checkCmd(["shell", "run-as", packageName, "cp", tmpDir + "/tmpfile", devroot + "/sanity"])
       if (self.fileExists(devroot + "/sanity/tmpfile")):
         print "will execute commands via run-as " + packageName
         self.packageName = packageName