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

1087 Commits

Author SHA1 Message Date
Marc Bonnici
80bddf38a2 utils/android: Fix xmltree dump for aapt
Fix syntax error in dump command when using the aapt binary.
2020-07-09 15:06:12 +01:00
Marc Bonnici
00f3f5f690 android/background: Specify the device for background cmds
Ensure the device is passed when executing a background
command.
2020-07-06 17:24:48 +01:00
Marc Bonnici
bc9478c324 connection/send_signal: Use signal value instead of name
Some targets do not support killing via signal name so use the signal
number for greater compatibility.
2020-07-06 17:24:48 +01:00
Marc Bonnici
9a2c413372 target/reset: Ignore all TargetErrors when rebooting
Some targets can thrown stable errors in addition to
transient errors when executing the `reboot` command.
We expect this command to not always complete cleanly
so ignore all target errors.
2020-06-29 16:29:39 +01:00
Marc Bonnici
3cb2793e51 collector/serial_trace: Ensure log is opened in binary mode 2020-06-24 17:16:11 +01:00
Marc Bonnici
1ad2e895b3 collector/serial_trace: Fix typo 2020-06-24 17:16:11 +01:00
Marc Bonnici
3d5a164338 module/vexpress: Remove reference to android.
This method is also called when booting linux so remove specific
reference to Android.
2020-06-24 17:15:40 +01:00
Jonathan Paynter
af8c47151e utils/android: Fix inconsistent logfile read mode
As the exoplayer workload did not specify a pre-existing logfile, it is
created for it by default in LogcatMonitor. This default method opens
the logfile in 'byte' mode rather than the expected 'string' mode.

Regex operations that depend on the logfile for event triggering expect it to
be in 'string' mode, which was not the case.
2020-06-24 10:27:32 +01:00
Marc Bonnici
20d1eabaf0 module/cpuidle: Fix incorrect path check 2020-06-10 18:16:21 +01:00
Marc Bonnici
45ee68fdd4 utils/android: Add support for using aapt2
aapt is now depreciated in favour of aapt2 therefore prefer using the
newer binary if it is found on the system. If not present fallback to
the old implementation.
Currently all invocations of aapt within devlib are compatible with
aapt2 however expose the `aapt_version` attribute to indicate which
version has been selected to allow for allow maintaining future
compatibility.
2020-06-08 17:37:06 +01:00
Marc Bonnici
b52462440c utils/android: Update to discover android tools from PATH
Allow falling back to detecting the required android tools from PATH.
2020-06-08 17:37:06 +01:00
Marc Bonnici
bae741dc81 docs/overview: Fix python2 style print 2020-06-08 17:37:06 +01:00
douglas-raillard-arm
b717deb8e4 module/cpuidle: Simplify Cpuidle.__init__
Replace stateful loop with a nested comprehension that makes obvious:
    * that self._states is a dict(cpu, [CpuidleState])
    * the sysfs folder being used and the constraint applied to make use
      of each level (i.e. which subfolder is used)
    * that the states are sorted by index

As a side effect:
    * Gracefully handle non-contiguous idle state names like "state0,
      state2" without a state1 (not sure if that can happen)
    * Remove some antipatterns while iterating over a dict and counting
      iterations.
2020-06-05 17:21:44 +01:00
Marc Bonnici
ccde9de257 devlib/AndroidTarget: Update screen state methods to handle doze
Newer devices can have a "DOZE" or always on screen state.
Enable the screen state to handle these cases and report these
states as `ON`.
2020-06-05 17:12:35 +01:00
Marc Bonnici
c25852b210 utils/android: Allow instantiating an ApkInfo object without a path.
Do not assume that a path is provided upon creating of an ApkInfo
instance and only attempt to extract information if present.
2020-06-05 09:28:06 +01:00
Marc Bonnici
f7b7aaf527 utils/ssh: Do not attempt to push files recursivley and add logging
No longer recursively attempt to push a file to the target. If the
second attempt goes wrong we assume there is something else wrong and
therefore let the error propagate.
Also log the original error in case it is not the error we were
expecting.
2020-06-05 09:27:37 +01:00
Javi Merino
569e4bd057 LogcatCollector: Learn to pass format to logcat
logcat -v lets you specify the format for the logcat output.  Add a
parameter to the LogcatCollector to allow us to pass that information
down to the logcat invocation.
2020-05-15 14:52:26 +01:00
Marc Bonnici
07cad78046 utils/version: dev version bump
Bump the dev version due to additional parameter exposed on SSHConnection.
2020-05-13 16:42:58 +01:00
Marc Bonnici
21cb10f550 utils/ssh: Add logging to sftp file transfer 2020-05-13 16:42:58 +01:00
Marc Bonnici
d2aea077b4 target/ChromeOsTarget: Update ssh parameter list 2020-05-13 16:42:58 +01:00
Marc Bonnici
d464053546 utils/ssh: Fix typo 2020-05-13 16:42:58 +01:00
Marc Bonnici
cfb28c47c0 utils/ssh: Allow SSH to use SCP as a file transfer method
Paramiko uses sftp for file transfer rather then scp as with the
previous implementation however not all targets support this.
Expose a parameter to the SSHConnection to allow falling back to
the scp implementation.
2020-05-13 16:42:58 +01:00
Marc Bonnici
b941c6c5a6 utils/ssh: Move the scp transport method to the SSH base class
Move the implementation of the scp transport from the Telnet connection
to the base class to allow other types of connection to use the
functionality.
2020-05-13 16:42:58 +01:00
Marc Bonnici
ea9f9c878b docs/ssh: Add note about connecting to passwordless machines. 2020-05-13 16:42:58 +01:00
Marc Bonnici
4f10387688 utils/ssh: Only attempt loading ssh keys if no password is supplied
In the case of connecting to a system without a password the password
parameter needs to be set to an empty string which will currently still
cause ssh keys to be loaded. Only check for ssh keys when the password
is explicitly set to `None`.
2020-05-13 16:42:58 +01:00
Marc Bonnici
a4f9231707 collector/perf: Disable pager for perf event list.
Pipe the list of perf events via cat to ensure that a pager is not
used to display the output as this can cause some systems to hang
waiting for user input.
2020-05-12 10:25:46 +01:00
Marc Bonnici
3c85738f0d docs/target: Fix method name 2020-05-12 10:25:08 +01:00
Marc Bonnici
45881b9f0d utils/android: Expose connection_attempts argument to AdbConnection
Allow for configuring the number of connection attempts that will be
made to the device before failing to connect. This allows for waiting longer
periods of time for the device to come online.
2020-05-12 10:24:47 +01:00
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 77a6de9453 ("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 77a6de9453 was
implementing.
2020-03-27 17:25:28 +00:00
Javi Merino
7c79a040b7 utils/misc: Revert d4b0dedc2a
d4b0dedc2a ("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