Bug 722403 - DeviceManager: killProcess(): Add forceKill parameter and kill all matching processes, r=gbrown Earlier patch by Christian Holler.
authorWilliam Lachance <wlachance@mozilla.com>
Fri, 23 Mar 2012 14:00:04 -0700
changeset 93513 ba379b14fd60f52d1278366cb7c0386cdc6e2599
parent 93512 94d710277cd45eef41b9ac77b29e1da48e979436
child 93514 d0dfb71a2df99cde818e4ebefd93c5b519e5482c
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs722403
milestone14.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 722403 - DeviceManager: killProcess(): Add forceKill parameter and kill all matching processes, r=gbrown Earlier patch by Christian Holler.
build/mobile/devicemanager.py
build/mobile/devicemanagerADB.py
build/mobile/devicemanagerSUT.py
--- a/build/mobile/devicemanager.py
+++ b/build/mobile/devicemanager.py
@@ -230,22 +230,22 @@ class DeviceManager:
       procName = proc[1].split('/')[-1]
       if (procName == app):
         pid = proc[0]
         break
     return pid
 
 
   @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
   def catFile(self, remoteFile):
     """
     external function
     returns:
     success: filecontents
--- a/build/mobile/devicemanagerADB.py
+++ b/build/mobile/devicemanagerADB.py
@@ -371,26 +371,31 @@ class DeviceManagerADB(DeviceManager):
       acmd.append("-d")
       acmd.append(''.join(['\'',uri, '\'']));
     print acmd
     self.checkCmd(acmd)
     return outputFile
 
   # 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:
   #  success: filecontents
   #  failure: None
   def catFile(self, remoteFile):
     #p = self.runCmd(["shell", "cat", remoteFile])
     #return p.stdout.read()
--- a/build/mobile/devicemanagerSUT.py
+++ b/build/mobile/devicemanagerSUT.py
@@ -577,25 +577,27 @@ class DeviceManagerSUT(DeviceManager):
     cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
 
     if self.fireProcess(cmdline, failIfRunning) is None:
       return None
     return outputFile
 
   # 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:
   #  success: tmpdir, string
   #  failure: None
   def getTempDir(self):
     try:
       data = self.runCmds(['tmpd'])