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

1025 Commits

Author SHA1 Message Date
Marc Bonnici
5116d46141 utils/version: Bump release version 2020-12-11 16:31:00 +00:00
Marc Bonnici
beb3b011bd utils/apk_info: Handle apks that do not contain classes.dex
Some apks do not contain the file that we use to determine app methods
so return an empty list in this case.
2020-12-10 20:20:23 +00:00
douglas-raillard-arm
bf4e242129 host: Use "sh -c" for background() like execute()
Align LocalConnection.background() and LocalConnection.execute() by
using "sh -c" when running with sudo.
2020-11-25 10:17:57 +00:00
douglas-raillard-arm
b1538fd184 host: remove unneeded concatenation
'{}'.format(x) + y is equivalent to '{}{}'.format(x, y)
2020-11-25 10:17:57 +00:00
douglas-raillard-arm
5b37dfc50b host: Remove sudo prompt from stderr in execute()
Remove the leading space introduced on stderr by: sudo -S -p ' '
background() still gets the space, since we cannot easily apply
processing to its stderr.

Note: -p '' does not work on recent sudo, so we unfortunately cannot
just completely remove it for the time being.
2020-11-25 10:17:57 +00:00
douglas-raillard-arm
a948982700 host: Fix string literal
String literals are concatenated automatically in Python:

   assert 'a' 'b' == 'ab'

This means that adding ' ' in the middle of a literal delimited by '
will be a no-op. Fix that by changing the literal delimiter to ".
2020-11-25 10:17:57 +00:00
douglas-raillard-arm
d300b9e57f devlib.utils: Fix escape sequences
Fix invalid escape sequence, mostly in regex that were not r-strings.
2020-11-18 13:41:50 +00:00
Marc Bonnici
81db8200e2 utils/logcatmonitor: Ensure adb_server is specified
Ensure the adb_server is specific when monitoring the logcat.
2020-11-13 13:58:11 +00:00
Marc Bonnici
9e9af8c6de utils/version: Bump dev version
Bump the dev version to synchronise the additional exposed parameter.
2020-11-09 17:53:24 +00:00
Marc Bonnici
5473031ab7 utils/ssh: Split out the sudo_cmd template
Split out the `sudo_cmd` template to reduce duplication
for SSH based connections and for use from WA to ensure
the template stays in sync.
2020-11-09 17:53:24 +00:00
Javi Merino
a82db5ed37 instrument/daq: Use clock boottime for the time column of the energy measurements
92e16ee873 ("instrument/daq: Add an explicit time column to the DAQ
measurements") added a time column to the DAQ measurements in order to
help correlate them with those of other collectors like
FtraceCollector.  Sadly, FTrace uses CLOCK_BOOTTIME instead of
CLOCK_MONOTONIC by default.  CLOCK_MONOTONIC is like CLOCK_BOOTTIME,
except that it stops when the device suspends, which is why I hadn't
spot the issue until now.

Switch to CLOCK_BOOTTIME to get the intended behaviour of the original
commit.
2020-11-09 17:27:21 +00:00
Valentin Schneider
1381944e5b utils/ssh, host: Remove sudo prompt from output
On a target where sudo is required, target.file_exists() erroneously
returns True despite the execute() output being:

  '[sudo] password for valsch01: 0\n'

The sudo prompt is being written to stderr (as per sudo -S), but this is
still merged into the final execute() output. Get rid of the prompt to
prevent it from interfering with any command output processor.

Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
2020-11-09 17:26:02 +00:00
Marc Bonnici
822c50273f utils/check_subprocess_output: Fix std error output
Fix stderr output being dropped unless there there is
also output on stdout.
2020-11-09 16:34:17 +00:00
Marc Bonnici
8f3200679c host: Concatenate stdout and stderr from command output
Previously any output from stderr was discarded for LocalTargets.
Align the behaviour of `execute` to append any stderr output
to stdout before returning.
2020-11-09 16:34:17 +00:00
Marc Bonnici
2cfb076e4c utils/check_output: Fix missing ignore parameter propagation 2020-11-04 18:12:56 +00:00
Marc Bonnici
98bc0a31e1 target/page_size_kb: Handle missing KernelPageSize
On some systems KernelPageSize is not exported therefore
in this case return 0.
2020-11-04 18:12:56 +00:00
Marc Bonnici
345a9ed199 fw/version: Development version bump
Bump the version due to additional parameters exposed for transfer
polling.
2020-11-03 10:02:16 +00:00
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