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

948 Commits

Author SHA1 Message Date
douglas-raillard-arm
b6d1863e77 collector/dmesg: DmesgCollector: Avoid not rooted targets
Fail early if the target is not rooted, as root is required by
DmesgCollector.start() anyway.
2021-04-07 10:55:27 +01:00
Vincent Donnefort
bbc891341c module/cpufreq: Warn when cpuinfo doesn't reflect the cpufreq request
The cpufreq/scaling_* files reflect the policy configuration from a kernel
point of view. The actual frequency at which the CPU is running can be
found in cpuinfo_cur_freq. Warn when the requested frequency does not
match the actual one.

As the kernel does not provide any guarantee that the requested frequency
will be actually used (due to other part of the system such as thermal or
the firmware), printing a warning instead of raising an error seems more
suitable here.
2021-04-07 10:55:08 +01:00
Marc Bonnici
d14df074ee utils/android: Fix Typo 2021-03-31 11:03:59 +01:00
Marc Bonnici
81f9ee2c50 utils/android: Use busybox implementation of ps
On some older versions of ps the flags used to look up
the pids are not supported and results in no output.
Use the busybox implementation for consistency.
2021-03-31 11:03:59 +01:00
Marc Bonnici
09d0a0f500 docs: Fix Formatting / typos 2021-03-31 11:02:49 +01:00
Robert Freeman
fe2fe3ae04 collector/perf: run simpleperf report-sample in the target if requested
If simpleperf record is called with "-f N", we may want to run
"simpleperf report-sample" on the output to dump the periodic
records.  Let the PerfCollector() run report-sample in the target,
similar to how we run report.
2021-03-31 10:03:33 +01:00
Robert Freeman
4859e818fb collector/perf: Only kill sleep if running perf stat
The stop() command of the PerfCollector kills all sleep commands in
the target, saying "We hope that no other important sleep is
on-going".  This is only needed if we are running "perf stat",
simpleperf does not need this.  Background the
perf/simpleperf command and only kill all sleeps in that specific case.
2021-03-31 10:03:33 +01:00
douglas-raillard-arm
5d342044a2 host and ssh: Fix sudo invocation
Add -k to sudo invocation to avoid using cached credentials.

If cached credentials is used, sudo will not write a prompt again,
leading to the stderr fixup code to remove a char from stderr output.
2021-03-24 19:06:05 +00:00
douglas-raillard-arm
d953377ff3 doc: Extend doc of Target.background()
Add doc for parameters "force_locale" and "timeout".
2021-03-24 19:05:50 +00:00
douglas-raillard-arm
4f2d9fa66d target: Add Target.background(timeout=...) parameter
Use a Timer daemonic thread to cancel the command after the given
timeout.
2021-03-24 19:05:50 +00:00
douglas-raillard-arm
4e44863777 connection: Un-hardcode _KILL_TIMEOUT
Replace erroneous use of _KILL_TIMEOUT constant by the kill_timeout
parameter.
2021-03-23 15:40:28 +00:00
douglas-raillard-arm
6cabad14d0 connection: Make ConnectionBase.cancel() more robust
Check with poll() if the command is already finished first, to avoid
sending SIGKILL to unrelated processes due to PID recycling.

The race window still exists between the call to poll() and _cancel(),
but is reduced a great deal.
2021-03-23 15:40:28 +00:00
douglas-raillard-arm
31f7c1e8f9 connection: Remove trailing whitespace 2021-03-23 15:40:28 +00:00
douglas-raillard-arm
3bc98f855b target: Align Target.background() LC_ALL and PATH
Make Target.background() behave like Target.execute():

* Set LC_ALL if force_locale is provided (defaults to "C")
* Add the target bin folder to PATH
2021-03-23 15:40:28 +00:00
douglas-raillard-arm
d2b80ccaf9 modules/sched: Fix sched domain flags parsing
Recent kernels can have a space-separated list of textual flags rather
than a bitfield packed in an int.
2021-03-12 17:56:01 +00:00
douglas-raillard-arm
552040f390 devlib/collector/dmesg: handle CONFIG_SECURITY_DMESG_RESTRICT
Some kernels compiled with CONFIG_SECURITY_DMESG_RESTRICT can restrict
reading the dmesg buffer to root user as a security hardening measure.
Detect this case and use root accordingly.
2021-02-12 12:11:07 +00:00
Javi Merino
0d259be01b collector/perf: Run perf as root if the target is rooted
If you want to collect events by event id (eg. in simpleperf, "rNNN"
with NNN a number), you must run it as root.  Otherwise, simpleperf
fails with a SIGABRT.

Run simpleperf as root by default if the target is rooted to avoid
this.
2021-02-02 11:30:09 +00:00
Marc Bonnici
792101819a utils/version: Prevent installation failure on systems without git
On systems that do not have git installed devlib will currently fail
to install with a FileNotFound Exception. If git is not present then
we will not have a commit hash so just ignore this error.
2021-01-12 17:53:27 +00:00
Javi Merino
3b8317d42e target: increase dump_logcat timeout
If WA is connected to a phone via a slow connection, dump_logcat() may
timeout when dumping logcat after the job has finished:

    2021-01-11 09:38:16,277 DEBUG       android:         adb -s X.Y.Z.X:5555 logcat -d -v threadtime > wa_output/wk1-wkld-1/logcat.log
    2021-01-11 09:38:46,317 DEBUG        signal:         Sending error-logged from <ErrorSignalHandler (DEBUG)>
    2021-01-11 09:38:46,318 DEBUG        signal:         Disconnecting <bound method Executor._error_signalled_callback of executor> from error-logged(<class 'louie.sender.Any'>)
    2021-01-11 09:38:46,317 ERROR        signal:         Timed out: adb -s X.Y.Z.X:5555 logcat -d -v threadtime > wa_output/wk1-wkld-1/logcat.log
    2021-01-11 09:38:46,317 ERROR        signal:         OUTPUT:
    2021-01-11 09:38:46,317 ERROR        signal:
    2021-01-11 09:38:46,317 ERROR        signal:

Increase the timeout to prevent this.
2021-01-11 10:11:42 +00:00
Marc Bonnici
e3da419e5b utils/android: Switch to using the lxml module
Using dexdump from versions 30.0.1-30.0.3 of Android build tools
does not produce valid XML caused by certain APKs
Use the lxml module for parsing xml as it is more robust and
better equipped to handle errors in input.
2021-01-08 17:22:12 +00:00
Marc Bonnici
e251b158b2 utils/android: Reorder imports 2021-01-08 17:22:12 +00:00
Marc Bonnici
c0a5765da5 utils/android: Fix aapt discovery with unexpected structure
If there is an additional file or directory in the `build_tools` directory
then WA can fail to find a working version of aapt(2), ensure that at least
one of the binaries is a valid file path.
2021-01-08 17:22:12 +00:00
Marc Bonnici
b32f15bbdb utils/version: Bump to dev version 2020-12-11 16:42:57 +00:00
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