Bug 722403 - DeviceManager: killProcess(): Add forceKill parameter and kill all matching processes, r=gbrown Earlier patch by Christian Holler.

--HG--
extra : rebase_source : 295a10d592827f4633951eda196505529560f8f0
This commit is contained in:
William Lachance 2012-03-23 14:00:04 -07:00
Родитель c035407085
Коммит c40c38d353
3 изменённых файлов: 21 добавлений и 14 удалений

Просмотреть файл

@ -235,12 +235,12 @@ class DeviceManager:
@abstractmethod
def killProcess(self, appname):
def killProcess(self, appname, forceKill=False):
"""
external function
returns:
success: output from testagent
failure: None
success: True
failure: False
"""
@abstractmethod

Просмотреть файл

@ -376,16 +376,21 @@ class DeviceManagerADB(DeviceManager):
# external function
# returns:
# success: output from testagent
# failure: None
def killProcess(self, appname):
# success: True
# failure: False
def killProcess(self, appname, forceKill=False):
procs = self.getProcessList()
didKillProcess = False
for (pid, name, user) in procs:
if name == appname:
p = self.runCmdAs(["shell", "kill", pid])
return p.stdout.read()
args = ["shell", "kill"]
if forceKill:
args.append("-9")
args.append(pid)
p = self.runCmdAs(args)
didKillProcess = True
return None
return didKillProcess
# external function
# returns:

Просмотреть файл

@ -582,15 +582,17 @@ class DeviceManagerSUT(DeviceManager):
# external function
# returns:
# success: output from testagent
# failure: None
def killProcess(self, appname):
# success: True
# failure: False
def killProcess(self, appname, forceKill=False):
if forceKill:
print "WARNING: killProcess(): forceKill parameter unsupported on SUT"
try:
data = self.runCmds(['kill ' + appname])
except AgentError:
return None
return False
return data
return True
# external function
# returns: