Bug 772687 - Add ability to specify deviceRoot when instantiating DeviceManager, r=jmaher

This commit is contained in:
Jonathan Griffin 2012-07-11 11:49:30 -07:00
parent 356f7e8cc6
commit bb189eab03
3 changed files with 24 additions and 15 deletions

View File

@ -12,7 +12,7 @@ import tempfile
class DeviceManagerADB(DeviceManager): class DeviceManagerADB(DeviceManager):
def __init__(self, host=None, port=20701, retrylimit=5, packageName='fennec', def __init__(self, host=None, port=20701, retrylimit=5, packageName='fennec',
adbPath='adb', deviceSerial=None): adbPath='adb', deviceSerial=None, deviceRoot=None):
self.host = host self.host = host
self.port = port self.port = port
self.retrylimit = retrylimit self.retrylimit = retrylimit
@ -24,7 +24,7 @@ class DeviceManagerADB(DeviceManager):
self.useZip = False self.useZip = False
self.packageName = None self.packageName = None
self.tempDir = None self.tempDir = None
self.deviceRoot = None self.deviceRoot = deviceRoot
# the path to adb, or 'adb' to assume that it's on the PATH # the path to adb, or 'adb' to assume that it's on the PATH
self.adbPath = adbPath self.adbPath = adbPath
@ -537,6 +537,13 @@ class DeviceManagerADB(DeviceManager):
# Internal method to setup the device root and cache its value # Internal method to setup the device root and cache its value
def setupDeviceRoot(self): def setupDeviceRoot(self):
# if self.deviceRoot is already set, create it if necessary, and use it
if self.deviceRoot:
if not self.dirExists(self.deviceRoot):
if not self.mkDir(self.deviceRoot):
raise DMError("Unable to create device root %s" % self.deviceRoot)
return
# /mnt/sdcard/tests is preferred to /data/local/tests, but this can be # /mnt/sdcard/tests is preferred to /data/local/tests, but this can be
# over-ridden by creating /data/local/tests # over-ridden by creating /data/local/tests
testRoot = "/data/local/tests" testRoot = "/data/local/tests"

View File

@ -44,12 +44,13 @@ class DeviceManagerSUT(DeviceManager):
# The error would be set where appropriate--so sendCMD() could set socket errors, # The error would be set where appropriate--so sendCMD() could set socket errors,
# pushFile() and other file-related commands could set filesystem errors, etc. # pushFile() and other file-related commands could set filesystem errors, etc.
def __init__(self, host, port = 20701, retrylimit = 5): def __init__(self, host, port = 20701, retrylimit = 5, deviceRoot = None):
self.host = host self.host = host
self.port = port self.port = port
self.retrylimit = retrylimit self.retrylimit = retrylimit
self.retries = 0 self.retries = 0
self._sock = None self._sock = None
self.deviceRoot = deviceRoot
if self.getDeviceRoot() == None: if self.getDeviceRoot() == None:
raise BaseException("Failed to connect to SUT Agent and retrieve the device root.") raise BaseException("Failed to connect to SUT Agent and retrieve the device root.")
@ -838,18 +839,22 @@ class DeviceManagerSUT(DeviceManager):
# success: path for device root # success: path for device root
# failure: None # failure: None
def getDeviceRoot(self): def getDeviceRoot(self):
try: if self.deviceRoot:
data = self.runCmds([{ 'cmd': 'testroot' }]) deviceRoot = self.deviceRoot
except: else:
return None try:
data = self.runCmds([{ 'cmd': 'testroot' }])
except:
return None
deviceRoot = data.strip() + '/tests' deviceRoot = data.strip() + '/tests'
if (not self.dirExists(deviceRoot)): if (not self.dirExists(deviceRoot)):
if (self.mkDir(deviceRoot) == None): if (self.mkDir(deviceRoot) == None):
return None return None
return deviceRoot self.deviceRoot = deviceRoot
return self.deviceRoot
def getAppRoot(self, packageName): def getAppRoot(self, packageName):
try: try:

View File

@ -183,6 +183,7 @@ class B2GMochitest(Mochitest):
_automation = None _automation = None
_dm = None _dm = None
localProfile = None localProfile = None
testDir = '/data/local/tests'
def __init__(self, automation, devmgr, options): def __init__(self, automation, devmgr, options):
self._automation = automation self._automation = automation
@ -193,7 +194,6 @@ class B2GMochitest(Mochitest):
self._automation.setRemoteProfile(self.remoteProfile) self._automation.setRemoteProfile(self.remoteProfile)
self.remoteLog = options.remoteLogFile self.remoteLog = options.remoteLogFile
self.userJS = '/data/local/user.js' self.userJS = '/data/local/user.js'
self.testDir = '/data/local/tests'
self.remoteMozillaPath = '/data/b2g/mozilla' self.remoteMozillaPath = '/data/b2g/mozilla'
self.remoteProfilesIniPath = os.path.join(self.remoteMozillaPath, 'profiles.ini') self.remoteProfilesIniPath = os.path.join(self.remoteMozillaPath, 'profiles.ini')
self.originalProfilesIni = None self.originalProfilesIni = None
@ -405,7 +405,8 @@ def main():
auto.marionette = marionette auto.marionette = marionette
# create the DeviceManager # create the DeviceManager
kwargs = {'adbPath': options.adbPath} kwargs = {'adbPath': options.adbPath,
'deviceRoot': B2GMochitest.testDir}
if options.deviceIP: if options.deviceIP:
kwargs.update({'host': options.deviceIP, kwargs.update({'host': options.deviceIP,
'port': options.devicePort}) 'port': options.devicePort})
@ -421,10 +422,6 @@ def main():
mochitest = B2GMochitest(auto, dm, options) mochitest = B2GMochitest(auto, dm, options)
# Create /data/local/tests, to force its use by DeviceManagerADB;
# B2G won't run correctly with the profile installed to /mnt/sdcard.
dm.mkDirs(mochitest.testDir)
options = parser.verifyOptions(options, mochitest) options = parser.verifyOptions(options, mochitest)
if (options == None): if (options == None):
sys.exit(1) sys.exit(1)