It sometimes can be useful to enable dry-run before calling
high-level functions in order to check what individual commands
are being called (or do whatever else with them).
This patch adds dry-run with an on/off switch:
once start_dryrun() is called, every subsequent command passed to
execute() will be accumulated in a list.
stop_dryrun() disables dry-run, and the accumulated commands can
be fetched via Target.dryrun
This new method allows to pull over a complete directory from the target.
It does so by compressing the directory, pulling over the
compressed file and extracting the directory on the host.
Added the following method to targets:
- sleep: sleep on target for the specified duration. In some situations,
e.g. on simulation platforms, it is important that sleep
happens on the target rather than the host.
Added the following methods to Android targets:
- ensure_screen_is_off: complements the existing ensure_screen_is_on.
- homescreen: navigate to home screen.
Previously trying to pull a file from an android target would fail if the file
was owned by root, this commit adds read permissions to the file before
attempting to pull.
On some devices backgrounding a task results in the command returning
immediately with no error. This was falsely interpreted as the command failing
to run, therefore the additional check has been removed.
Targets have been observed where `ps` output contains entries with NAME columns
of the form "[foo bar]". This means the `parts` list is too long and the PsEntry
call reports too many arguments. Since NAME is the rightmost column, just fix
the number of entries we recognise to 8.
As per issue #102, not all devices have permission to list the root directory
causing the ls command to be incorrectly determined. This commit changes the
directory to be checked to the working directory to ensure sufficient
permissions.
From #92, when rebooting a platform the internal connection state becomes
different from `_connected_as_root`, now clears the state upon device reboot or
reset.
When rebooting a platform the internal connection state becomes
different from _connected_as_root, which was set before reboot.
Add the possibility to force adb root if you've rebooted or know
to have done something that would result in the platform having
a different connection state than the one of _connected_as_root.
Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
This regex currently matches the `rc` group against the added-patches-count,
e.g. "00005" in "4.4.41-00005-g17b74bafccbe-dirty" and "59" in
"4.4.0-59-generic". Fix this by requiring "rc" in the match.
This adds a regexp to better parse all the kernel version numbers as well
as additional (optional) fields like SHA1 and RC.
The regexp has been made generic enough to match these examples:
4.9.0-rc6-00202-g3a60597
4.9.0-rc6-00202
4.9.0-rc6-00202-g3a60597 #321 SMP PREEMPT Mon Feb 13 12:30:59 GMT 2017 aarch64 GNU/Linux
3.18.31-g226dafe #1 SMP PREEMPT Wed Feb 15 16:34:14 GMT 2017
4.4.0-59-generic #80~14.04.1-Ubuntu SMP Fri Jan 6 18:02:02 UTC 2017
3.11.0-26-generic #45~precise1-Ubuntu SMP Tue Jul 15 04:02:35 UTC 2014
3.13.0-107-generic #154-Ubuntu SMP Tue Dec 20 09:57:27 UTC 2016
3.13.0-generic #154-Ubuntu SMP Tue Dec 20 09:57:27 UTC 2016
4.8.0 #1 SMP Fri Jan 6 18:06:24 GMT 2017
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This adds a couple of commodity ADB commands to reboot in bootloader
mode and to restart ADB in root mode.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
killall() is implemented by discovering all PIDs who's name matches the
specified process, and then sending individual kills for each PID. If a
PID no longer exists by the time the kill is sent (e.g. if it was a
child of one of the previously killed PIDs), this will result in a
TargetError, which for the purposes of killall() should be ignored.
conn_cls is no longer a class attribute and is specified on
instantiaation as well. This more flexible -- new connection types no
longer require a corresponding new Target subclass but can be used with
existing targets. This is also more consistent with how Platforms are
handled.
Use case: To check if a kernel supports function profiling we need to
check for the presence of
"/sys/kernel/debug/tracing/function_profiler_enabled", but
"/sys/kernel/debug/"'s permissions are 700.
We expect ls to output single column listings. Previous to Linaro Android
16.09 release, this was the default. From the 16.09 release onwards, the
default is multi-column. Unfortunately, pre-16.09 ls does not support the
'-1' option to guarantee single column output.
Test for ls supporting '-1' and use it if possible.
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
kick_off relies on nohup, which may not work properly unless the command
for it is explicitly backgrounded with "&", which was not being done in
the AndroidTarget implementation of kick_off().
Added a method for extracting compressed on-target files and archives.
The method extacts the specified on-target path (the method is based on
the extension) and return the path to extracted content.
Most invocations of target.execute() pass as_root=self.is_rooted .
However, is_rooted is not what you want to do here. as_root tells the
connection to wrap the command around sudo/su to execute the command as
root. is_rooted returns True if the device can run commands as
root (for example, if we are connected as root). If you are already
connected as root, there is no need to wrap the command around sudo, you
are already root. In that case, as_root should always be false.
Define a new property for the target called needs_su that returns true
if the target needs to run a command to get superuser privileges.
To install busybox we need to know the ABI of the device to push the
correct binary but to know the ABI we need busybox.
Since uname is part of the POSIX standard and this issue only effects
the LinuxTarget (AndroidTarget gets this from build.prop) it is safe
to assume all LinuxTargets should have uname.
Some modules could requires assets available on a target before being
initialised. For example, the cgroups module requires busybox and shutil
to properly initialise.
This patch adds a new stage to Target which allows to post-pone the
initialisation of some modules till Target.setup() has been executed.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
When issuing a target.reboot(), the reset was immediately followed by a
boot() (for platforms that have it) and an attempt to connect. When
issuing a soft reset, it's possible the target is still shutting down
when the attempt to connect is made. This results in the connection
succeeding but being severed shortly thereafter.
This introduces a delay after the reset to the reboot sequence, giving
the target time to shutdown and improves the handling of EOF's that
result from failed reconnection attempts (while still being with the
allotted timeout period.
Get the device's ANDROID_ID. Which is
"A 64-bit number (as a hex string) that is randomly generated when the user
first sets up the device and should remain constant for the lifetime of the
user's device."
Changed get_installed to search self.executables_directory first.
This means that user provided binaries will be used over system ones.
Also added the option to not search system folders for a binary.