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

908 Commits

Author SHA1 Message Date
Jonathan Paynter
1fc9f6cc94 doc/target: Add polling to target push method
Update the documentation for ``target`` to mention transfer polling,
and redirect to more information in ``connection``.
2020-11-03 10:01:43 +00:00
Jonathan Paynter
4194b1dd5e utils/ssh: Add remote path formatter method 2020-11-03 10:01:43 +00:00
Jonathan Paynter
ef2d1a6fa4 doc/connection: Add transfer poll parameter info
Also update SSHConnection parameters to reflect the current state.
2020-11-03 10:01:43 +00:00
Jonathan Paynter
33397649b6 connection,targets: enable file transfer polling
For connections that allow for it (ADB and SSH using SFTP
and SCP) this change enables file transfers to be polled to check
if the transfer is still in progress after some period of time or
whether the transfer should be terminated.

If a timeout is specified in the call to ``pull`` or ``push`` then the
transfer will not be polled and will terminate ordinarily when either
the transfer completes or the timeout is reached. If a timeout is
not specified, then the transfer will be polled if ``poll_transfers`` is
set, otherwise the transfer will continue with no timeout at all.

SSH transfers supply a callback to the transfer, that is called
after every block of the source is transferred. If the callback has not
been triggered within one poll period, then the transfer is cancelled.

ADB transfers have the destination size polled every poll period, and
the size compared to the previous poll to check if the transfer has
stalled. When the destination is no longer growing in size, the poller
will attempt to kill the subprocess to end the transfer.

If the transfer is still active, but the total transfer time has
exceeded the ``total_timeout`` (default: 1 hour) the transfer will then
also be killed.

Transfer polling will only begin after the ``start_transfer_poll_delay``
time has elapsed.

Polling periods that are too small may incorrectly cancel transfers.
2020-11-03 10:01:43 +00:00
Jonathan Paynter
ebf1c1a2e1 utils/ssh: Add paramiko based scp transfers
Using scp over paramiko allows scp transfers to be treated similarly to
sftp transfers, instead of requiring subprocesses, and provides
the ability to monitor an scp transfer using a callback as can be done
using sftp.
2020-11-03 10:01:43 +00:00
Jonathan Paynter
1d1ba7811d utils/misc: separate check_output functionality
The custom check_output function consisted of two main parts: fetching
the subprocess required for the command, and checking its output.

It is convenient to provide functions that implement these parts
distinctly, so that the output of any subprocess can be checked easily
and the creation of a typical Popen object wrapped inside
get_subprocess.
2020-11-03 10:01:43 +00:00
Jonathan Paynter
dc7faf46e4 connection: kill spawned child subprocesses:
Subprocesses that were spawned under the same pgid were not necessarily
being terminated when the parent was terminated, allowing them to
continue running. This change explicitly kills the process group
involved.
2020-11-03 10:01:43 +00:00
Marc Bonnici
0498017bf0 utils/apkinfo: Fix handing when no methods defined
Not all apks list their class methods so add handling of this
situation.
2020-09-18 18:12:09 +01:00
Jonathan Paynter
b2950686a7 devlib/target: Enable screen stay-on mode:
Adds the ability to set the android global setting
``stay_on_while_plugged_in``.

This setting has 4 main modes:
- 0: never stay on
- 1: stay on when plugged in to AC charger
- 2: stay on when plugged in to USB charger
- 4: stay on when wirelessly charged

These values can be OR-ed together to produce combinations.
2020-09-02 18:06:07 +01:00
Marc Bonnici
f2b5f85dab target/file_xfer: Fix incorrect method call 2020-07-24 16:30:32 +01:00
Marc Bonnici
c0f26e536a target.py: Fix incorrect parameter name 2020-07-24 16:30:32 +01:00
Marc Bonnici
1a02f77fdd target/pull: Use chmod from busybox
Not all implementations of chmod support the use of `--` so ensure
we use a known implementations from busybox.
2020-07-24 16:30:32 +01:00
Stephen Kyle
117686996b target: support threads in ps
Adds 'tid' attribute to PsEntry namedtuple. This is equal to the PID of
the process.

Adds 'threads=True' parameter to target.ps(). When true, PsEntrys will be
returned for all threads on the target, not just processes. The 'tid' will
be the distinct PID for each thread, rather than the owning process.
2020-07-21 14:11:55 +01:00
douglas-raillard-arm
8695344969 target/{host,ssh}: Align push/pull with cp/mv behaviour
When pushing or pulling a folder, replicate the mv/cp/scp/adb behaviour,
which is:
    * splitting the destination into (existing, new) components
    * if {new} component is empty, set it to the basename of the source.
    * mkdir {new} if necessary
    * merge the hierarchies of {src} and {existing}/{new}
2020-07-20 15:49:14 +01:00
douglas-raillard-arm
f23fbd22b6 target: Use Target._xfer_cache_file() context manager
Use the context manager to simplify the file transfer cache management.

Also introduce devlib.utils.misc.nullcontext() mirroring the behavior of
contextlib.nullcontext().
2020-07-20 15:49:14 +01:00
douglas-raillard-arm
24e6de67ae target: Add Target.{push,pull}(globbing=False) parameter
When globbing=True, the source is interpreted as a globbing pattern on
the target and is expanded before pulling the files or folders.

This also aligns the behaviour of all targets:
    * adb connection was supported a limited form of globbing by default
      (only on the last component of the path)
    * SCP was supporting a limited form of globbing
    * GEM5 was not supporting globbing at all
    * paramiko was not supporting globbing at all

Also fix a race condition on push/pull as root, where pushing/pulling
the same file from multiple threads would have ended up using the same
temporary file.
2020-07-20 15:49:14 +01:00
douglas-raillard-arm
07bbf902ba docs/target: Update Target.{push,pull}() description
Document the fact that it accepts folders as source and destination in
addition to files.
2020-07-20 15:49:14 +01:00
douglas-raillard-arm
590069f01f target: Add Target.makedirs()
Create a directory on the target.
2020-07-20 15:49:14 +01:00
douglas-raillard-arm
bef1ec3afc target: Add option delimiter to rm command
Use a lone -- to make sure to not treat paths as options.
2020-07-20 15:49:14 +01:00
douglas-raillard-arm
0c72763d2a target/ssh: Fix improper use of os.path.basename()
os.path.basename() can give surprising results on folder names:

    os.path.basename('/foo/') == ''
    os.path.basename(os.path.normpath('/foo/')) == 'foo'
2020-07-20 15:49:14 +01:00
Marc Bonnici
2129d85422 utils/android: Use separate tmp dirs when extracting apk methods
Create a new temporary directory to use when extracting apk methods,
as when running multiple processes in parallel the extracted files could
be overwritten by each other.
2020-07-13 10:24:03 +01:00
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