зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1130187 - Optimize devicemanager calls during remote xpcshell tests; r=bc
This commit is contained in:
Родитель
c7d65fd1a2
Коммит
e11572838a
|
@ -47,11 +47,9 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
|
||||||
return mapping.remote
|
return mapping.remote
|
||||||
return local
|
return local
|
||||||
|
|
||||||
|
|
||||||
def setupTempDir(self):
|
def setupTempDir(self):
|
||||||
# make sure the temp dir exists
|
# make sure the temp dir exists
|
||||||
if not self.device.dirExists(self.remoteTmpDir):
|
self.clearRemoteDir(self.remoteTmpDir)
|
||||||
self.device.mkDir(self.remoteTmpDir)
|
|
||||||
# env var is set in buildEnvironment
|
# env var is set in buildEnvironment
|
||||||
return self.remoteTmpDir
|
return self.remoteTmpDir
|
||||||
|
|
||||||
|
@ -69,8 +67,7 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
|
||||||
return pluginsDir
|
return pluginsDir
|
||||||
|
|
||||||
def setupProfileDir(self):
|
def setupProfileDir(self):
|
||||||
self.device.removeDir(self.profileDir)
|
self.clearRemoteDir(self.profileDir)
|
||||||
self.device.mkDir(self.profileDir)
|
|
||||||
if self.interactive or self.singleFile:
|
if self.interactive or self.singleFile:
|
||||||
self.log.info("profile dir is %s" % self.profileDir)
|
self.log.info("profile dir is %s" % self.profileDir)
|
||||||
return self.profileDir
|
return self.profileDir
|
||||||
|
@ -89,9 +86,10 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
path = remoteJoin(self.remoteHere, f)
|
path = remoteJoin(self.remoteHere, f)
|
||||||
if not self.device.fileExists(path):
|
|
||||||
raise Exception('%s file does not exist: %s' % ( kind,
|
# skip check for file existence: the convenience of discovering
|
||||||
path))
|
# a missing file does not justify the time cost of the round trip
|
||||||
|
# to the device
|
||||||
|
|
||||||
yield path
|
yield path
|
||||||
|
|
||||||
|
@ -145,7 +143,6 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
|
||||||
# Guard against an accumulation of hung processes by killing
|
# Guard against an accumulation of hung processes by killing
|
||||||
# them here. Note also that IPC tests may spawn new instances
|
# them here. Note also that IPC tests may spawn new instances
|
||||||
# of xpcshell.
|
# of xpcshell.
|
||||||
self.device.killProcess(cmd[0])
|
|
||||||
self.device.killProcess("xpcshell")
|
self.device.killProcess("xpcshell")
|
||||||
return outputFile
|
return outputFile
|
||||||
|
|
||||||
|
@ -163,8 +160,7 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
|
||||||
with mozfile.TemporaryDirectory() as dumpDir:
|
with mozfile.TemporaryDirectory() as dumpDir:
|
||||||
self.device.getDirectory(self.remoteMinidumpDir, dumpDir)
|
self.device.getDirectory(self.remoteMinidumpDir, dumpDir)
|
||||||
crashed = xpcshell.XPCShellTestThread.checkForCrashes(self, dumpDir, symbols_path, test_name)
|
crashed = xpcshell.XPCShellTestThread.checkForCrashes(self, dumpDir, symbols_path, test_name)
|
||||||
self.device.removeDir(self.remoteMinidumpDir)
|
self.clearRemoteDir(self.remoteMinidumpDir)
|
||||||
self.device.mkDir(self.remoteMinidumpDir)
|
|
||||||
return crashed
|
return crashed
|
||||||
|
|
||||||
def communicate(self, proc):
|
def communicate(self, proc):
|
||||||
|
@ -192,6 +188,9 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
|
||||||
def removeDir(self, dirname):
|
def removeDir(self, dirname):
|
||||||
self.device.removeDir(dirname)
|
self.device.removeDir(dirname)
|
||||||
|
|
||||||
|
def clearRemoteDir(self, remoteDir):
|
||||||
|
self.device.shellCheckOutput([self.remoteClearDirScript, remoteDir])
|
||||||
|
|
||||||
#TODO: consider creating a separate log dir. We don't have the test file structure,
|
#TODO: consider creating a separate log dir. We don't have the test file structure,
|
||||||
# so we use filename.log. Would rather see ./logs/filename.log
|
# so we use filename.log. Would rather see ./logs/filename.log
|
||||||
def createLogFile(self, test, stdout):
|
def createLogFile(self, test, stdout):
|
||||||
|
@ -239,6 +238,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
|
||||||
self.remoteComponentsDir = remoteJoin(self.remoteTestRoot, "c")
|
self.remoteComponentsDir = remoteJoin(self.remoteTestRoot, "c")
|
||||||
self.remoteModulesDir = remoteJoin(self.remoteTestRoot, "m")
|
self.remoteModulesDir = remoteJoin(self.remoteTestRoot, "m")
|
||||||
self.remoteMinidumpDir = remoteJoin(self.remoteTestRoot, "minidumps")
|
self.remoteMinidumpDir = remoteJoin(self.remoteTestRoot, "minidumps")
|
||||||
|
self.remoteClearDirScript = remoteJoin(self.remoteBinDir, "cleardir")
|
||||||
self.profileDir = remoteJoin(self.remoteTestRoot, "p")
|
self.profileDir = remoteJoin(self.remoteTestRoot, "p")
|
||||||
self.remoteDebugger = options.debugger
|
self.remoteDebugger = options.debugger
|
||||||
self.remoteDebuggerArgs = options.debuggerArgs
|
self.remoteDebuggerArgs = options.debuggerArgs
|
||||||
|
@ -279,6 +279,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
|
||||||
'profileDir': self.profileDir,
|
'profileDir': self.profileDir,
|
||||||
'remoteTmpDir': self.remoteTmpDir,
|
'remoteTmpDir': self.remoteTmpDir,
|
||||||
'remoteMinidumpDir': self.remoteMinidumpDir,
|
'remoteMinidumpDir': self.remoteMinidumpDir,
|
||||||
|
'remoteClearDirScript': self.remoteClearDirScript,
|
||||||
}
|
}
|
||||||
if self.remoteAPK:
|
if self.remoteAPK:
|
||||||
self.mobileArgs['remoteAPK'] = self.remoteAPK
|
self.mobileArgs['remoteAPK'] = self.remoteAPK
|
||||||
|
@ -297,15 +298,32 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
|
||||||
f.write("#!/system/bin/sh\n")
|
f.write("#!/system/bin/sh\n")
|
||||||
for envkey, envval in self.env.iteritems():
|
for envkey, envval in self.env.iteritems():
|
||||||
f.write("export %s=%s\n" % (envkey, envval))
|
f.write("export %s=%s\n" % (envkey, envval))
|
||||||
f.write("cd $1\n")
|
f.writelines([
|
||||||
f.write("echo xpcw: cd $1\n")
|
"cd $1\n",
|
||||||
f.write("shift\n")
|
"echo xpcw: cd $1\n",
|
||||||
f.write("echo xpcw: xpcshell \"$@\"\n")
|
"shift\n",
|
||||||
f.write("%s/xpcshell \"$@\"\n" % self.remoteBinDir)
|
"echo xpcw: xpcshell \"$@\"\n",
|
||||||
|
"%s/xpcshell \"$@\"\n" % self.remoteBinDir])
|
||||||
f.close()
|
f.close()
|
||||||
remoteWrapper = remoteJoin(self.remoteBinDir, "xpcw")
|
remoteWrapper = remoteJoin(self.remoteBinDir, "xpcw")
|
||||||
self.device.pushFile(localWrapper, remoteWrapper)
|
self.device.pushFile(localWrapper, remoteWrapper)
|
||||||
os.remove(localWrapper)
|
os.remove(localWrapper)
|
||||||
|
|
||||||
|
# Removing and re-creating a directory is a common operation which
|
||||||
|
# can be implemented more efficiently with a shell script.
|
||||||
|
localWrapper = tempfile.mktemp()
|
||||||
|
f = open(localWrapper, "w")
|
||||||
|
# The directory may not exist initially, so rm may fail. 'rm -f' is not
|
||||||
|
# supported on some Androids. Similarly, 'test' and 'if [ -d ]' are not
|
||||||
|
# universally available, so we just ignore errors from rm.
|
||||||
|
f.writelines([
|
||||||
|
"#!/system/bin/sh\n",
|
||||||
|
"rm -r \"$1\"\n",
|
||||||
|
"mkdir \"$1\"\n"])
|
||||||
|
f.close()
|
||||||
|
self.device.pushFile(localWrapper, self.remoteClearDirScript)
|
||||||
|
os.remove(localWrapper)
|
||||||
|
|
||||||
self.device.chmodDir(self.remoteBinDir)
|
self.device.chmodDir(self.remoteBinDir)
|
||||||
|
|
||||||
def buildEnvironment(self):
|
def buildEnvironment(self):
|
||||||
|
|
Загрузка…
Ссылка в новой задаче