1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-22 20:01:53 +01:00

7 Commits

Author SHA1 Message Date
Marc Bonnici
f525374fbb version: perform additional revision release
Revert the minor version number to allow release of additional
revision release to fix some bugs that made it into the previous
release.
2022-05-24 17:50:01 +01:00
Douglas Raillard
42e62aed57 target: Fix AndroidTarget pickling
Avoid pickling the "clear_logcat_lock". Instead, discard the attribute
and re-initialize it anew.
2022-05-24 10:39:31 +01:00
Douglas Raillard
f5cfcafb08 shutils: Remove shebang
Since shutils should be run using busybox shell anyway, remove the
shebang.
2022-05-24 10:37:17 +01:00
Douglas Raillard
7853d2c85c target: Run shutils.in in busybox
Ensure shutils.in runs in a busybox shell.
2022-05-24 10:37:17 +01:00
Douglas Raillard
a9fcc75f60 collector/dmesg: Fix dmesg_out property
When no entry has been recorded by the collector, return an empty string
rather than returning the full dmesg log.

Also fix get_data() that would fail try to add None + '\n' if dmesg_out
property returns None.
2022-05-18 15:21:18 +01:00
Douglas Raillard
cd8720b901 module/cgroups: Fix move_tasks()/move_all_tasks_to()
Both move_all_tasks_to() and move_tasks() take a list of grep patterns
to exclude.

It turned out that move_all_tasks_to() was calling move_tasks() with a
string instead of a list, leading to broken quoting.

Fix that by passing the pattern list to move_tasks() and let
move_tasks() add the "-e" option in front of it. Also add a
DeprecationWarning in move_tasks() if someone passes a string instead of
an iterable of strings.
2022-05-17 19:04:29 +01:00
Marc Bonnici
03569fb01f version: Bump minor version number
This next release will drop support for Python < 3.7
therefore bump to a dev tag of the next minor version.
2022-04-29 19:38:50 +01:00
5 changed files with 36 additions and 21 deletions

View File

@@ -1,5 +1,3 @@
#!__DEVLIB_SHELL__
CMD=$1 CMD=$1
shift shift

View File

@@ -202,10 +202,10 @@ class DmesgCollector(CollectorBase):
try: try:
entry = self.entries[0] entry = self.entries[0]
except IndexError: except IndexError:
i = 0 return ''
else: else:
i = entry.line_nr i = entry.line_nr
return '\n'.join(out.splitlines()[i:]) return '\n'.join(out.splitlines()[i:])
@property @property
def entries(self): def entries(self):
@@ -278,5 +278,5 @@ class DmesgCollector(CollectorBase):
if self.output_path is None: if self.output_path is None:
raise RuntimeError("Output path was not set.") raise RuntimeError("Output path was not set.")
with open(self.output_path, 'wt') as f: with open(self.output_path, 'wt') as f:
f.write(self.dmesg_out + '\n') f.write((self.dmesg_out or '') + '\n')
return CollectorOutput([CollectorOutputEntry(self.output_path, 'file')]) return CollectorOutput([CollectorOutputEntry(self.output_path, 'file')])

View File

@@ -17,6 +17,8 @@ import logging
import re import re
from collections import namedtuple from collections import namedtuple
from shlex import quote from shlex import quote
import itertools
import warnings
from devlib.module import Module from devlib.module import Module
from devlib.exception import TargetStableError from devlib.exception import TargetStableError
@@ -123,9 +125,20 @@ class Controller(object):
return cgroups return cgroups
def move_tasks(self, source, dest, exclude=None): def move_tasks(self, source, dest, exclude=None):
if isinstance(exclude, str):
warnings.warn("Controller.move_tasks() takes needs a _list_ of exclude patterns, not a string", DeprecationWarning)
exclude = [exclude]
if exclude is None: if exclude is None:
exclude = [] exclude = []
exclude = ' '.join(
itertools.chain.from_iterable(
('-e', quote(pattern))
for pattern in exclude
)
)
srcg = self.cgroup(source) srcg = self.cgroup(source)
dstg = self.cgroup(dest) dstg = self.cgroup(dest)
@@ -133,7 +146,7 @@ class Controller(object):
'cgroups_tasks_move {src} {dst} {exclude}'.format( 'cgroups_tasks_move {src} {dst} {exclude}'.format(
src=quote(srcg.directory), src=quote(srcg.directory),
dst=quote(dstg.directory), dst=quote(dstg.directory),
exclude=' '.join(map(quote, exclude)) exclude=exclude,
), ),
as_root=True, as_root=True,
) )
@@ -165,18 +178,11 @@ class Controller(object):
self.logger.debug('Moving all tasks into %s', dest) self.logger.debug('Moving all tasks into %s', dest)
# Build list of tasks to exclude # Build list of tasks to exclude
grep_filters = ' '.join( self.logger.debug(' using grep filter: %s', exclude)
'-e {}'.format(comm)
for comm in exclude
)
self.logger.debug(' using grep filter: %s', grep_filters)
if grep_filters != '':
self.logger.debug(' excluding tasks which name matches:')
self.logger.debug(' %s', ', '.join(exclude))
for cgroup in self.list_all(): for cgroup in self.list_all():
if cgroup != dest: if cgroup != dest:
self.move_tasks(cgroup, dest, grep_filters) self.move_tasks(cgroup, dest, exclude)
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
def tasks(self, cgroup, def tasks(self, cgroup,

View File

@@ -1202,14 +1202,10 @@ fi
shutils_ifile = os.path.join(PACKAGE_BIN_DIRECTORY, 'scripts', 'shutils.in') shutils_ifile = os.path.join(PACKAGE_BIN_DIRECTORY, 'scripts', 'shutils.in')
tmp_dir = tempfile.mkdtemp() tmp_dir = tempfile.mkdtemp()
shutils_ofile = os.path.join(tmp_dir, 'shutils') shutils_ofile = os.path.join(tmp_dir, 'shutils')
shell_path = '/bin/sh'
if self.os == 'android':
shell_path = '/system/bin/sh'
with open(shutils_ifile) as fh: with open(shutils_ifile) as fh:
lines = fh.readlines() lines = fh.readlines()
with open(shutils_ofile, 'w') as ofile: with open(shutils_ofile, 'w') as ofile:
for line in lines: for line in lines:
line = line.replace("__DEVLIB_SHELL__", shell_path)
line = line.replace("__DEVLIB_BUSYBOX__", self.busybox) line = line.replace("__DEVLIB_BUSYBOX__", self.busybox)
ofile.write(line) ofile.write(line)
self._shutils = self.install(shutils_ofile) self._shutils = self.install(shutils_ofile)
@@ -1218,7 +1214,7 @@ fi
@call_conn @call_conn
def _execute_util(self, command, timeout=None, check_exit_code=True, as_root=False): def _execute_util(self, command, timeout=None, check_exit_code=True, as_root=False):
command = '{} {}'.format(self.shutils, command) command = '{} sh {} {}'.format(quote(self.busybox), quote(self.shutils), command)
return self.conn.execute(command, timeout, check_exit_code, as_root) return self.conn.execute(command, timeout, check_exit_code, as_root)
def _extract_archive(self, path, cmd, dest=None): def _extract_archive(self, path, cmd, dest=None):
@@ -1576,8 +1572,23 @@ class AndroidTarget(Target):
conn_cls=conn_cls, conn_cls=conn_cls,
is_container=is_container) is_container=is_container)
self.package_data_directory = package_data_directory self.package_data_directory = package_data_directory
self._init_logcat_lock()
def _init_logcat_lock(self):
self.clear_logcat_lock = threading.Lock() self.clear_logcat_lock = threading.Lock()
def __getstate__(self):
dct = super().__getstate__()
return {
k: v
for k, v in dct.items()
if k not in ('clear_logcat_lock',)
}
def __setstate__(self, dct):
self.__dict__.update(dct)
self._init_logcat_lock()
def reset(self, fastboot=False): # pylint: disable=arguments-differ def reset(self, fastboot=False): # pylint: disable=arguments-differ
try: try:
self.execute('reboot {}'.format(fastboot and 'fastboot' or ''), self.execute('reboot {}'.format(fastboot and 'fastboot' or ''),

View File

@@ -21,7 +21,7 @@ from subprocess import Popen, PIPE
VersionTuple = namedtuple('Version', ['major', 'minor', 'revision', 'dev']) VersionTuple = namedtuple('Version', ['major', 'minor', 'revision', 'dev'])
version = VersionTuple(1, 3, 3, '') version = VersionTuple(1, 3, 4, '')
def get_devlib_version(): def get_devlib_version():