1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

1009 Commits

Author SHA1 Message Date
Marc Bonnici
a8ff622f33 target: Propergate adb_server in all adb_commands
Add property to AndroidTarget to retrieve the adb server if using an
AdbConnection and ensure this is passed in remaining adb_commands.
2020-05-12 10:15:47 +01:00
Javi Merino
fcd2439b50 LogcatCollector: flush the log before terminating pexpect.spawn()
Unless we tell pexpect to expect something it will not read from the
process' buffer, or write anything to the logfile.  If we follow the
collector instructions from devlib's documentation:

  In [1]: from devlib import AndroidTarget, LogcatCollector

  In [2]: t = AndroidTarget()

  # Set up the collector on the Target.

  In [3]: collector = LogcatCollector(t)

  # Configure the output file path for the collector to use.
  In [4]: collector.set_output('adb_log.txt')

  # Reset the Collector to preform any required configuration or
  # preparation.
  In [5]: collector.reset()

  # Start Collecting
  In [6]: collector.start()

  # Wait for some output to be generated
  In [7]: sleep(10)

  # Stop Collecting
  In [8]: collector.stop()

  # Retrieved the collected data
  In [9]: output = collector.get_data()

adb_log.txt will be empty because between collector.start() and
collector.stop() there were no expect() calls to
LogcatMonitor._logcat.  As the get_log() function already has code to
flush the log, abstract it to a function and call it in stop() before
terminating the pexpect.spawn().
2020-05-11 13:09:34 +01:00
Javi Merino
3709e06b5c utils/android: LogcatMonitor: put pexpect.spawn() in str mode
By default, pexpect.spawn() is a bytes interface: its read methods
return bytes and its write/send and expect method expect bytes. Logcat
uses utf-8 strings, so put pexpect.spawn() in str mode.

This code can't have worked in python3 before, since the logcat file
is not opened in "b" mode.
2020-05-11 13:09:34 +01:00
Marc Bonnici
7c8573a416 README: Update to include installation notes for paramiko 2020-04-20 12:03:42 +01:00
Marc Bonnici
6f1ffee2b7 platform/arm: Decode IP address directly
Convert bytes to a string when acquired rather than in the calling
functions.
2020-04-16 09:45:06 +01:00
Marc Bonnici
7ade1b8bcc platform/arm: Don't specify "Android" in the debug print.
This function be used to determine the IP address of other OSs
e.g. linux.
2020-04-16 09:45:06 +01:00
Marc Bonnici
3c28c280de utils/check_output: Ensure output and error are always initialised.
Ensure that the `output` and `error` variables are always initialised
regardless of whether an error occurs during execution.
2020-03-30 16:21:46 +01:00
Marc Bonnici
b9d50ec164 utils/check_output: Only attempt to decode output if present.
If an error occurs while executing a command the `output` and `error`
variables may not get initialised, only attempted to decode their
contents if this is not the case.
2020-03-30 16:05:23 +01:00
Javi Merino
7780cfdd5c utils/android: Combine stdout and stderror by combining the strings in adb_shell()
check_output(combined_output=True) does not guarantee that stdout will
come before stderr, but the ordering is needed in case check_exit_code
is True, as we are expecting the exit code at the end of stdout.
Furthermore, the exceptions can't report what is stdout and what is
stderr as they are combined.

Partially revert 77a6de94537b ("utils/android: include stderr in adb_shell
output") and parse output and err independently. Return them combined
from adb_shell() to keep the functionality that 77a6de94537b was
implementing.
2020-03-27 17:25:28 +00:00
Javi Merino
7c79a040b7 utils/misc: Revert d4b0dedc2a63
d4b0dedc2a63 ("utils/misc: add combined output option to
check_output") adds an option that combines stdout and stderr, but
their order is arbitrary (stdout may appear before or after
stderr). This leads to problems in adb_shell() when it tries to check
the error code. Now that adb_shell() doesn't use combined_output,
remove the option as there are no more users in devlib.

squash! utils/misc: Make the return of check_output consistent
2020-03-27 17:25:28 +00:00
Marc Bonnici
779b0cbc77 utils/ssh: Only try SSH keys if no password is supplied.
By default parmaiko attempts to search for SSH keys even when connecting
with a password. Ensure this is disabled to prevent issues where
non-valid keys are found on the host when connecting using password
authentication.
2020-03-25 18:09:15 +00:00
Marc Bonnici
b6cab6467d docs: Add LinuxTarget and LocalLinuxTarget to the documentation 2020-03-20 15:35:16 +00:00
Marc Bonnici
ec0a5884c0 docs: Update to use module diretive
Update the documentation to indicated which module each class is
located. This allows the documentation to be referenced from other
modules as well as enabling links to the source code directly from the
documentation.
2020-03-20 15:35:16 +00:00
Marc Bonnici
7f5e0f5b4d utils/version: Bump dev version
Bump the development version due to the change in SSH interface.
2020-03-06 17:34:22 +00:00
Douglas RAILLARD
7e682ed97d target: Check that the connection works cleanly upon connection
Check that executing the most basic command works without troubles or stderr
content. If that's not the case, raise a TargetStableError.
2020-03-06 17:33:04 +00:00
Douglas RAILLARD
62e24c5764 connections: Unify BackgroundCommand API and use paramiko for SSH
* Unify the behavior of background commands in connections.BackgroundCommand().
  This implements a subset of subprocess.Popen class, with a unified behavior
  across all connection types

* Implement the SSH connection using paramiko rather than pxssh.
2020-03-06 17:33:04 +00:00
Douglas RAILLARD
eb6fa93845 utils/misc: Add redirect_streams() helper
Update a command line to redirect standard streams as specified using the
parameters. This helper allows honoring streams specified in the same way as
subprocess.Popen, by doing it as much using shell redirections as possible.
2020-03-06 17:33:04 +00:00
Douglas RAILLARD
9d5d70564f target: Use tls_property() to manage a thread-local connection
This frees the connection to have to handle threading issues, since each thread
using the Target will have its own connection. The connection will be garbage
collected when the thread using it dies, avoiding connection leaks.
2020-03-06 17:33:04 +00:00
Douglas RAILLARD
922686a348 utils/misc: Add tls_property()
Similar to a regular property(), with the following differences:
* Values are memoized and are threadlocal

* The value returned by the property needs to be called (like a weakref) to get
  the actual value. This level of indirection is needed to allow methods to be
  implemented in the proxy object without clashing with the value's methods.

* If the above is too annoying, a "sub property" can be created with the regular
  property() behavior (and therefore without the additional methods) using
  tls_property.basic_property .
2020-03-06 17:33:04 +00:00
Douglas RAILLARD
98e2e51d09 devlib.utils.misc: Use Popen.communicate(timeout=...) in check_output
Use the timeout parameter added in Python 3.3, which removes the need for the
timer thread and avoids some weird issues in preexec_fn, as it's now documented
to sometimes not work when threads are involved.
2020-03-06 17:33:04 +00:00
Javi Merino
92e16ee873 instrument/daq: Add an explicit time column to the DAQ measurements
Add the monotonic clock time to the energy measurements to help
correlate the measurement with those of other collectors, like
FtraceCollector or LogcatCollector.
2020-03-02 14:48:46 +00:00
Javi Merino
72ded188fa instrument/daq: Convert reading rows from all files to a generator
Instead of calling _read_next_rows() before the while and at the end,
it's simpler to read the rows in a for loop and have _read_rows() be a
generator.
2020-03-02 14:48:46 +00:00
Javi Merino
dcab0b3718 instrument/daq: Check that self.tempdir has been set before calling os.path.isdir()
self.tempdir is initialized to None, and os.path.isdir() throws an
exception if you don't pass it a str.  This can happen if teardown()
is called before get_data(), which WA sometimes does.  Check that
self.tempdir has been initializing before calling os.path.isdir().
2020-03-02 14:48:46 +00:00
Vincent Donnefort
37a6b4f96d target: a valid sha1 must be concatenated with the kernel version
Some SoC vendors add several sha's to the kernel version string. This is
problematic for the KernelVersion class, which might identify the wrong one.

Fixing this issue by matching the following "git describe" pattern:

  <version>.<major>.<minor>-<rc>-<commits>-g<sha1>

Where commits is the number of commits on top of the tag, which is now a
member of the class.

Prior to this patch:

>> KernelVersion("4.14.111-00001-gd913f26_audio-00003-g3ab4335").sha1
3ab4335
>>> KernelVersion("4.14.111_audio-00003-g3ab4335").sha1
3ab4335

With the modified regex:

>> KernelVersion("4.14.111-00001-gd913f26_audio-00003-g3ab4335").sha1
d913f26
>>> KernelVersion("4.14.111_audio-00003-g3ab4335").sha1
None
2020-02-28 13:10:31 +00:00
Marc Bonnici
1ddbb75e74 uilts/android: Fix parameters to adb_kill_server 2020-02-20 16:25:50 +00:00
Marc Bonnici
696dec9b91 utils/android: Ensure that adb_server is propergated to helper functions
Ensure that we use the correct `adb_server` in the adb helper functions.
2020-02-20 16:25:50 +00:00
Douglas RAILLARD
17374cf2b4 target: Update Target.modules from Target.install_modules()
Make sure the target.modules list stays up to date when a new module is
installed, since behaviors like devlib_cpu_frequency event injection rely on
content of target.modules.
2020-02-19 09:15:38 +00:00
Douglas RAILLARD
9661c6bff3 target: Handle non-existing /sys/devices/system/node
Some systems (ARM 32bits it seems) don't have this file in sysfs. Assume 1 node
in that case.
2020-01-22 09:21:56 +00:00
Douglas RAILLARD
0aeb5bc409 target: Remove use of ls
Using "ls" in scripts is highly discouraged:
http://mywiki.wooledge.org/ParsingLs
2020-01-22 09:21:56 +00:00
Javi Merino
a5640502ac devlib/AndroidTarget: Allow passing format options to dump_logcat()
logcat has a modifier for its output format.  Add a logcat_format
parameter to dump_logcat() so that we can pass it on to logcat.
2020-01-21 09:37:07 +00:00
Douglas RAILLARD
6fe78b4d47 module/cpufreq: Sort list of frequencies
Ensure the order of frequencies is deterministic to have consistent output when
printing it or when using it to carry out some actions.
2020-01-15 11:36:55 +00:00
Sergei Trofimov
5bda1c0eee host: add host attribute to LocalConnection
Add a host attribute (hard-coded to "localhost") to LocalConnection to
make it easier to seamlessly swap it out with ssh connection.
2020-01-09 16:59:13 +00:00
Ambroise Vincent
0465a75c56 devlib/trace/ftrace.py: Fix reset and stop states
A system with function_profile_enabled set to 1 prevents using
function_graph.

Using nop tracer left the tracing files in a dirty state.
2020-01-07 14:14:38 +00:00
Marc Bonnici
795c0f233f Development version bump 2019-12-20 16:25:03 +00:00
Marc Bonnici
5ff278b133 Version bump for release v1.2 2019-12-20 15:57:57 +00:00
Marc Bonnici
b72fb470e7 docs: Update to include Collector information 2019-12-20 15:16:32 +00:00
Marc Bonnici
a4fd57f023 devlib/__init__: Export LogcatCollector in devlib package 2019-12-20 15:16:32 +00:00
Marc Bonnici
cf8ebf6668 devlib/collector: Update Collectors to implement collector interface 2019-12-20 15:16:32 +00:00
Marc Bonnici
15a77a841d collector/screencapture: Refactor to use new collector interface
Update the interface to make use of the collector interface.
Notable changes are the removal of the `output_path` path provided on
initialisation which will now be provided by the dedicated `set_output`
method.
2019-12-20 15:16:32 +00:00
Marc Bonnici
9bf9f2dd1b collector: Update the Collector Interface
Update `get_trace` to `get_data` to better reflect the purpose.
The return type of said method will be a `CollectorOutput` object will
contain one or more `CollectorOutputEntry` objects which will be used to
provide the `path`and `path_kind` attributes to indicate the path to the
obtained output and it's type (currently a "file" or "directory")
respectively.
2019-12-20 15:16:32 +00:00
Marc Bonnici
19887de71e devlib/trace: Refactor trace to be collector
We now have have multiple `trace` instruments that do not match the
description and therefore are moved to have a more suitably named
hierarchy.
2019-12-20 15:16:32 +00:00
Marc Bonnici
baa7ad1650 devlib/AndroidTarget: Move adb specific commands into the ADB connection
The `AndroidTarget` class should not depend on ADB specific commands as
is is possible to use this target with other connection types e.g. ssh.
Therefore move the adb specific commands into the `AdbConnection`.

- `wait_for_device` and `reboot_bootloader` are now exposed in AndroidTarget
as generic methods and call through to the connection method.
- `adb_kill_server` is now a standalone function of the AdbConnection.
2019-12-20 15:15:45 +00:00
Marc Bonnici
75621022be devlib/AndroidTarget: Move ADB disconnect code into connection.
The `AndroidTarget` would ensure that when connecting to a IP target
that it disconnected first to prevent the connection getting stuck if
the connection was not closed correctly. Move this code into the
`AdbConnection` instead as this is more relevant.
2019-12-20 15:15:45 +00:00
Valentin Schneider
01dd80df34 module/sched: Fix get_capacities() on !SCHED_DEBUG kernels
While reading the DT-provided capacity values (exposed in sysfs) is
sufficient, get_capacities() also unconditionally fetches data from the
sched_domain procfs, which is only populated on kernels compiled with
CONFIG_SCHED_DEBUG.

Tweak the logic to only call get_sd_info() if it is both possible and
required.
2019-12-13 15:32:01 +00:00
Sergei Trofimov
eb0661a6b4 utils/android: update SDK versions map
Update the entry for API level 28 and add an entry for API level 29.
2019-12-06 16:25:11 +00:00
Marc Bonnici
f303d1326b exception/get_traceback: Fix type error
Passing a `BytesIO` object to `print_tb` returns a `TypeError` change
this to a `StringIO` object instead.
2019-12-06 08:20:12 +00:00
Marc Bonnici
abd88548d2 instrument/frames: Fix missing import 2019-12-06 08:20:12 +00:00
Marc Bonnici
2a934288eb instrument/daq: Fix error message 2019-12-06 08:20:12 +00:00
Douglas RAILLARD
2bf4d8a433 target: Return a bool in Target.check_responsive()
Since bool is a subclass of int, turning 0 into False and 1 into True should not
break any user code.
2019-12-05 18:26:09 +00:00
Valentin Schneider
cf26dee308 trace/ftrace: Support the 'function' tracer
This tracer is similar to the 'function_graph' tracer in that it helps us
trace function calls. It is however more lightweight, and only traces
functions entries (along with the caller of the function). It can also
happen that the kernel has support for the 'function' tracer but not for
'function_graph' (the opposite cannot be true, however).
2019-12-04 11:17:13 +00:00