1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 10:50:51 +01:00
Commit Graph

728 Commits

Author SHA1 Message Date
Douglas RAILLARD
8512f116fc trace: Add DmesgCollector
Allows collecting dmesg output and parses it for easy filtering.
2019-03-19 13:52:04 +00:00
Valentin Schneider
be8b87d559 module/sched: Fix/simplify procfs packing behaviour
Back when I first wrote this I tried to make something smart that
would automatically detect which procfs entries to pack into a
mapping, the condition to do so being "the entry ends with a
digit and there is another entry with the same name but a different
digit".

I wrongly assumed this would always work for the sched_domain entries,
but it's possible to have a domain with a single group and thus a
single "group0" entry.

Since we know which entries we want to pack, let's hard-code these and
be less smart about it.
2019-03-19 13:48:29 +00:00
Valentin Schneider
d76c2d63fe module/sched: Make get_capacities() work with hotplugged CPUs 2019-03-19 13:48:29 +00:00
Valentin Schneider
8bfa050226 module/sched: SchedProcFSData: Don't assume SD name is always present
The existence of that field is gated by SCHED_DEBUG, so look for an
always-present field instead.
2019-03-19 13:48:29 +00:00
Chris Redpath
8871fe3c25 devlib/sched: Change order of CPU capacity algorithms
There are two ways we can load CPU capacity. Up until 4.14, supported
kernels did not have the /sys/devices/system/cpu/cpuX/cpu_capacity file
and the only way to read cpu capacity was by grepping the EM from
procfs sched_domain output. After 4.14, that route still exists but is
complicated due to a change in the format once support for
frequency-power models was merged.

In order to avoid rewriting the procfs EM grepping code, lets switch the
order of algorithms we try to use when loading CPU capacity. All newer
kernels provide the dedicated sysfs node and all kernels which do not
have this node use the old format for the EM in sched_domain output.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
2019-03-18 14:29:38 +00:00
Sergei Trofimov
aa50b2d42d host: expect shell syntax inside LocalConnection.execute
When using sudo with LocalConnection, execute the input command via 'sh
-c' to ensure any shell syntax within the command is handled properly.
2019-03-07 09:34:23 +00:00
Marc Bonnici
ebcb1664e7 utils/version: Development version bump 2019-02-27 10:55:20 +00:00
Marc Bonnici
0ff8628c9c utils/version: Version bump 2019-02-27 10:55:20 +00:00
Marc Bonnici
c0d8a98d90 setup.py: Use version_helper to generate devlib version
Instead of parsing the text of the file to extract the current version
use the version_helper to access the newly added version tuple.
2019-02-27 10:55:20 +00:00
Marc Bonnici
441eea9897 devlib/version: Implement devlibs version as a namedtuple
Instead of defining devlibs versions as a string use a namedtuple and
add in a revision field.
2019-02-27 10:55:20 +00:00
Marc Bonnici
b0db2067a2 target: Fix missing import for Python3
The `long` type is no longer present in Python3 so import it from
`past.builtins` for compatibility.
2019-02-14 09:38:31 +00:00
Marc Bonnici
1417e81605 target/HexInt: Fix to inherit from long instead of int.
When using Python 2.7 `int`s have a maximum size which can be exceeded
when attempting to convert the hex representation back. Change `HexInt` to
be a `long` instead to avoid this issue.
2019-02-13 14:21:34 +00:00
Douglas RAILLARD
2e81a72b39 ssh: Fix command line echoing
Command line echoing was disabled, but that disabling did not take
effect. Another part of devlib was still expecting command lines to be
echoed. That is fixed by disabling echoing when creating pxssh
connection, and removing the code that expected the line to be echoed.
2019-02-06 13:16:10 +00:00
Valentin Schneider
22f2c8b663 acmecape: Fix buffer_size use with pipes.quote()
pipes.quote() doesn't like integers:

>>> from pipes import quote
>>> quote(42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/shlex.py", line 282, in quote
    if _find_unsafe(s) is None:
TypeError: expected string or bytes-like object

Convert buffer_size to str when quoting it
2019-02-06 13:15:49 +00:00
Michalis Spyrou
c2db6c17ab Add adb_server option in android background connection
Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com>
2019-02-06 09:28:22 +00:00
Quentin Perret
e01a76ef1b doc: Explain the 'tar' flag of target.read_tree_values
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
2019-02-01 11:21:09 +00:00
Quentin Perret
9fcca25031 hwmon: Robustify hwmon scan
The hwmon module reads sysfs entries from the target during init. Since
this step is known to be fragile on some hosts, make sure to specify
tar=True when calling target.read_tree_values() to improve the chances
of reading the data properly.

Signed-off-by: Quentin Perret <quentin.perret@arm.com>
2019-02-01 11:21:09 +00:00
Quentin Perret
a6b9542f0f target: Speed-up read_tree_values()
Since target.read_tree_values() has been modified to use tar as a way to
fetch the content of files from the target, it is more robust, but also
much slower. Since that level of robustness is in practice required only
for very specific use-cased, re-introduce the old way of doing read_tree
using find and grep.

read_tree_values() gains a new parameter to specify how files should be
read from the target, with or without tar. It defaults to the old way
of doing things.

Signed-off-by: Quentin Perret <quentin.perret@arm.com>
2019-02-01 11:21:09 +00:00
Marc Bonnici
413e83f5d6 target/kernelconfig: Add alias for itteritems
Add an 'items' alias for itteritems to avoid confusion when iterating in
different versions of Python.
2019-01-30 16:47:21 +00:00
Marc Bonnici
ac19873423 target/TypedKernelConfig: Fix converting to string method
Some strings already quoted and therefore result in being quoted twice.
Strip off existing quotes before quoting the value to prevent this.
2019-01-30 16:07:19 +00:00
Douglas RAILLARD
17d4b22b9f shutils: Fix read_tree_tgz_b64 on empty folder
Hide tar stderr output, so it does not get mixed with the base64 stream
in case the folder we are tarring is empty.
2019-01-29 15:21:28 +00:00
Douglas RAILLARD
f65130b7c7 target: Introduce TypedKernelConfig
Maps Kconfig types to appropriate Python types, and act as a regular
mapping with extended API:
    * tristate and bool values mapped to an Enum
    * int values to int
    * hex values to HexInt subclass of int that defaults to parsing and
      printing in hex format.

Implement KernelConfig as a shim on top of TypedKernelConfig so they
share most of the code. Code needing a TypedKernelConfig from a
KernelConfig producer such as Target.config can trivially access the
`typed_config` attribute of KernelConfig objects.
2019-01-28 15:34:22 +00:00
Douglas RAILLARD
5b51c2644e target: Introduce KernelConfigKeyError
Make a new exception type raised by KernelConfig that inherits from both
KeyError (exception raised by mappings) and IndexError (exception raised
by sequences, but also raised here for backward compatibility).
2019-01-28 15:34:22 +00:00
Douglas RAILLARD
a752f55956 target: Fix KernelConfig parsing
Use the canonical option name in the underlying mapping, so looking up
the canonicalized option name will work as expected.

Otherwise, looking up the key CONFIG_FONT_8x8 would not work, since the
internal representation uses 'CONFIG_FONT_8x8' and the user input is
turned into 'CONFIG_FONT_8X8' (note the capital "X").
2019-01-28 15:34:22 +00:00
Douglas RAILLARD
781f9b068d target: Move kernel config parsing in method
Split kernel config parsing from target.KernelConfig from __init__ into
its separate method
2019-01-28 15:34:22 +00:00
Quentin Perret
7e79eeb9cb target: Robustify read_tree_values()
target.read_tree_values() has several weaknesses. It doesn't support
files with ':' in their name, and it fails when reading binary files.
In essence, these limitations are cause by its fragile implementation
based on grep in shutils.

In order to robustify read_tree_values(), use tar and base64 to send the
content of a tree to the host, which can then process it from there. In
the process, read_tree_values() gains two new arguments:
 - decode_unicode: must be set to work text/utf-8 content;
 - strip_null_chars: must be set to remove '\00' chars from text files.

Both are set to true by default to keep backward compatibility with the
existing code.

Suggested-by: Douglas Raillard <douglas.raillard@arm.com>
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
2019-01-28 15:34:11 +00:00
Marc Bonnici
911a9f2ef4 utils/ssh: Implement work around for issue in pexpect
As detailed in https://github.com/pexpect/pexpect/issues/552 when
sending a command with exactly the length of the prompt less than the
window width, an extra prompt is introduced into the returned data
causing the matching to fail and only return part of the commands
output. To workaround this check the length of the command to be
submitted and if of the specific length add an additional whitespace
character to the end of the command to prevent this behaviour.
2019-01-28 15:06:45 +00:00
Patrick Bellasi
cc0679e40f module: sched: add support to get/set scheduler features
Scheduler features are a debbugging mechanism which allows to tune at
run-time some (usually experimental) features of the Linux scheduler.

Let's add a proper API abstraction to easily access the list of
supported features and tune them.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2019-01-28 13:56:31 +00:00
Patrick Bellasi
5dea9f8bcf module: sched: add get/set methods for scheduler attributes
The Linux scheduler exposes a set of tunables via /proc/sys/kernel's
attributes staring by "sched_".

Let's add a convenient API to the sched module to read and set the
values of these attributes.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2019-01-28 13:56:31 +00:00
Marc Bonnici
a9ee41855d GfxInfo: Update to use nano second measurments
GfxInfo reports in nano seconds however was incorrectly labeled as
microseconds. Update to consistently deal in nano seconds.
2019-01-09 13:58:22 +00:00
Marc Bonnici
c13e3c260b instrument/measurment_types: Add nanoseconds
Add a 'nanosecond' measurement type and the appropriate conversions.
Also update notion of existing conversions to make things clearer.
2019-01-09 13:58:22 +00:00
Marc Bonnici
aabb74c8cb utils/rendering: Fix compatibility with Python3
Ensure output is encoded before attempting to write to file.
2019-01-09 13:58:22 +00:00
Marc Bonnici
a4c22cef71 utils/rendering: Fix incorrect debug message
This debug message is used for all derived FrameCollectors so do not
specify a particular method.
2019-01-09 13:58:22 +00:00
Marc Bonnici
3da7fbc9dd utils/rendering: Fix default value
Make sure to use an int default value otherwise can cause type error
when used for comparison.
2019-01-09 13:58:22 +00:00
Pierre-Clement Tosi
f2a87ce61c utils.android.ApkInfo: Retrieve APK class methods
Add a pseudo-attribute to ApkInfo giving all the methods available in
the APK as a list of (class, method) tuples. To keep backward
compatibility, this list is retrieved the first time the attribute is
being accessed.
2019-01-04 11:22:48 +00:00
Pierre-Clement Tosi
2b6cb264cf utils.android.ApkInfo: Add reading activity names
Add an activities pseudo-attribute to the ApkInfo class that retrieves the
names of the activities (_i.e._ entry points) of the APK. To keep
backward compatibility, these are retrieved the first time the attribute is
being accessed.
2019-01-04 11:22:48 +00:00
Pierre-Clement Tosi
7e0e6e8706 utils.android: Add ApkInfo._run()
Add a _run() method to handle CLI calls from within the class.
2019-01-04 11:22:48 +00:00
Volker Eckert
4fabcae0b4 cgroups.py: strip slashes, don't drop first char
this makes it cope with both, names starting with or without slashes
2019-01-04 11:22:24 +00:00
Marc Bonnici
3c4a282c29 devlib/version: Update to development version 2019-01-04 11:22:03 +00:00
Marc Bonnici
683da92067 devlib: Version Bump to v1.1 2018-12-21 10:49:14 +00:00
Marc Bonnici
1569be9ba7 trace/serial_trace: Ensure markers are encoded to before writing.
To be compatible with Python3 ensure that start and stop markers are
encoded before writing.
2018-12-14 15:26:44 +00:00
Marc Bonnici
f1b7fd184a module/cgroups: Execute command as root when launching cmd in cgroup
On some devices root is required to configure cgroups therefore run the
command as root if available unless otherwise specified.
2018-12-14 10:19:52 +00:00
Douglas RAILLARD
22a5945460 ftrace: Turn TraceCollector into a context manager
This allows using an TraceCollector instance as a context manager, so
tracing will stop even if the devlib application is interrupted, or if
an exception is raised.
2018-12-03 15:20:48 +00:00
Douglas RAILLARD
fbf0875357 serial_port: Handle exception in open_serial_connection
Use try/finally clause in the contextmanager to always close the
connection if an exception is raised.

Also remove "del conn" since it only decrements the reference count,
which is done anyway when the generator function returns.
2018-11-28 10:56:52 +00:00
Quentin Perret
b7ab340d33 instrument: Fix active_channels for Python 3
Since we can iterate over the active_channel attribute of Instrument
more than once, make sure to cast the return value of filter() to a list
to avoid issues with python 3.

Signed-off-by: Quentin Perret <quentin.perret@arm.com>
2018-11-27 16:43:28 +00:00
Juri Lelli
beb824256d bin: Add ppc64le binaries
Add busybox and trace-cmd binaries for ppc64le so that devlib can be
used on POWER machines.

Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
2018-11-23 15:08:51 +00:00
Marc Bonnici
efbf630422 utils/ssh: Remove original traceback from exception
In Python 3 when re-raising an exception the original traceback will
also be included. In the `_scp` method we do not want to expose the
password so hide the original exception when re-raising.
2018-11-21 15:11:37 +00:00
Douglas RAILLARD
389ec76c1e escaping: Use pipes.quote instead of escape_*
pipes.quote (also known as shlex.quote in Python3) provides a robust
implementation of quoting and escaping strings before passing them to
POSIX-style shells. Use it instead of the escape_* functions to simplify
quoting inside devlib.
2018-11-21 15:07:14 +00:00
Douglas RAILLARD
1f50b0ffc2 quoting: Use shlex.split instead of str.split
Split command lines using str.split ignores the quoting. Fixes that by
using shlex.split.
2018-11-21 15:07:14 +00:00
Douglas RAILLARD
ed7f0e56a2 subprocess: Fix quoting issues
Strings are passed to subprocess.Popen is used instead of sequences, so
proper quoting of parameters in command lines is needed to avoid
failures on filenames containing e.g. parenthesis. Use pipes.quote to
quote a string to avoid any issue with special characters.
2018-11-21 15:07:14 +00:00