Bug 728993 - Need to check output to capture run-as failure in devicemanagerADB. r=jmaher
--- 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