1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-29 05:58:55 +00:00

LinuxDevice: kick_off & killall will now run as root on rooted devices by default

kick_off has been changed to behave the same as AndroidDevice.

Said changes caused kill all to fail on rooted devices. Killall will now
behave in the same way as kick_off, if specifically told to (or not to)
run as root it will. Otherwise it will run as root if the device is rooted
This commit is contained in:
Sebastian Goscik 2016-06-01 13:28:17 +01:00
parent 772346507c
commit 2ff13089fd

View File

@ -393,7 +393,7 @@ class BaseLinuxDevice(Device): # pylint: disable=abstract-method
signal_string = '-s {}'.format(signal) if signal else '' signal_string = '-s {}'.format(signal) if signal else ''
self.execute('kill {} {}'.format(signal_string, pid), as_root=as_root) self.execute('kill {} {}'.format(signal_string, pid), as_root=as_root)
def killall(self, process_name, signal=None, as_root=False): # pylint: disable=W0221 def killall(self, process_name, signal=None, as_root=None): # pylint: disable=W0221
""" """
Kill all processes with the specified name. Kill all processes with the specified name.
@ -404,6 +404,8 @@ class BaseLinuxDevice(Device): # pylint: disable=abstract-method
Modified in version 2.1.5: added ``as_root`` parameter. Modified in version 2.1.5: added ``as_root`` parameter.
""" """
if as_root is None:
as_root = self.is_rooted
for pid in self.get_pids_of(process_name): for pid in self.get_pids_of(process_name):
self.kill(pid, signal=signal, as_root=as_root) self.kill(pid, signal=signal, as_root=as_root)
@ -734,13 +736,15 @@ class LinuxDevice(BaseLinuxDevice):
except CalledProcessError as e: except CalledProcessError as e:
raise DeviceError(e) raise DeviceError(e)
def kick_off(self, command, as_root=False): def kick_off(self, command, as_root=None):
""" """
Like execute but closes adb session and returns immediately, leaving the command running on the Like execute but closes ssh session and returns immediately, leaving the command running on the
device (this is different from execute(background=True) which keeps adb connection open and returns device (this is different from execute(background=True) which keeps ssh connection open and returns
a subprocess object). a subprocess object).
""" """
if as_root is None:
as_root = self.is_rooted
self._check_ready() self._check_ready()
command = 'sh -c "{}" 1>/dev/null 2>/dev/null &'.format(escape_double_quotes(command)) command = 'sh -c "{}" 1>/dev/null 2>/dev/null &'.format(escape_double_quotes(command))
return self.shell.execute(command, as_root=as_root) return self.shell.execute(command, as_root=as_root)