1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-04-08 19:00:03 +01:00

61 Commits

Author SHA1 Message Date
Marc Bonnici
c33dd65249 Target: Updated install_apk to version from WA2
This version of the method adds support for both replacing and downgrading of
APKS.
2017-06-23 15:33:42 +01:00
setrofim
b738655050 Revert "target: add dry run for command execution" 2017-05-23 17:39:12 +01:00
Valentin Schneider
1a5c1dce07 target: Add dry run for command execution
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
2017-05-23 10:32:11 +01:00
Anouk Van Laer
0b7ab6aa94 target: Added get_directory method
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.
2017-05-17 17:39:00 +01:00
Sergei Trofimov
69a83d4128 target: add new methods
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.
2017-05-12 11:54:31 +01:00
Sergei Trofimov
8b2ac8d29d AndroidTarget: move _execute_util to internal methods. 2017-05-12 11:48:19 +01:00
Marc Bonnici
f6d02c6611 Target: Add read permissions to tmp files before pulling
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.
2017-04-21 15:27:56 +01:00
setrofim
1ab8c25ff9 Merge pull request #110 from marcbonnici/kick_off
Target: Stopped `kick_off` raising an error if command didn't timeout
2017-04-20 15:30:26 +01:00
Marc Bonnici
95102d324b Target: Stopped kick_off raising an error if command didn't timeout
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.
2017-04-20 09:04:08 +01:00
Brendan Jackman
55c27e2c54 AndroidTarget: Fix ps when NAME column contains spaces
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.
2017-04-12 16:33:48 +01:00
Marc Bonnici
0655237217 Target: Fixes __setup_list_directory issue on production devices.
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.
2017-03-29 17:18:49 +01:00
Marc Bonnici
0687dac23b Target: Invalidates _connected_as_root on reboot or reset.
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.
2017-02-28 13:48:10 +00:00
setrofim
05215e7e1b Merge pull request #92 from ionela-voinescu/force_adb_root
android: add support for forced adb root
2017-02-24 14:43:23 +00:00
Ionela Voinescu
66eaf15cdc android: add support for forced adb root
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>
2017-02-24 14:19:25 +00:00
Brendan Jackman
6665693e8f target: Fix kernel version regex for -rc field
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.
2017-02-20 18:32:12 +00:00
Brendan Jackman
18b77b8808 target: Add parts field to KernelVersion 2017-02-20 18:32:12 +00:00
Brendan Jackman
54adf80eab target: Add KernelVersion docstring 2017-02-20 18:11:52 +00:00
Brendan Jackman
03561ee72c target: Make KernelVersion fields numerical 2017-02-20 18:11:52 +00:00
Patrick Bellasi
9a8d539e03 target: better parse kernel version numbers
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>
2017-02-20 12:25:08 +00:00
Brendan Jackman
baa32ec716 AndroidTarget: Add charging_enabled property
Disabling battery charging can be useful for measuring power efficiency of
Android devices with hardware modified for this purpose.
2017-02-16 15:09:44 +00:00
Patrick Bellasi
9ce57c0875 AndroidTarget: add support to reboot a device via ADB
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>
2017-02-16 15:07:18 +00:00
Anouk Van Laer
21f40035d7 gem5: Small tweaks in target to allow gem5 simulations
The target knows as little as possible about gem5 as a platform
but these tweaks add gem5 as a valid platform.

	modified:   devlib/target.py
2017-02-08 11:12:18 +00:00
Sergei Trofimov
6351a3bad9 Target.killall: catch TargetError on individual kills
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.
2017-01-30 11:14:36 +00:00
Sergei Trofimov
beaf8d48ac target: switching conn_cls to an __init__ parameter
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.
2016-12-07 18:13:55 +00:00
Sergei Trofimov
c35230890e AndroidTarget: removing unused parameter
external_storage_directory parmeter of __init__ was not being set is
entrirely used.
2016-12-07 18:13:55 +00:00
Brendan Jackman
c1b5152790 target: Use root in file_exists check
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.
2016-11-28 11:47:44 +00:00
Brendan Jackman
27f545f3f6 target: Note return value in Target::invoke docstring 2016-11-15 16:58:57 +00:00
Chris Redpath
2a4eafae6e AndroidTarget: Handle ls format change in Android 7.0
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>
2016-09-27 12:08:33 +01:00
Sergei Trofimov
ca0b6e88a1 AndroidTarget: fixed kick_off()
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().
2016-08-30 14:27:16 +01:00
Sergei Trofimov
baaa67bfcc target: added extract() method
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.
2016-07-14 11:07:19 +01:00
setrofim
17692891ef Merge pull request #46 from JaviMerino/needs_su
devlib: don't use sudo/su if you are root
2016-06-24 09:18:01 +01:00
Javi Merino
16d87c6924 devlib: don't use sudo/su if you are root
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.
2016-06-23 14:55:19 +01:00
Sebastian Goscik
5880f6e9ef LinuxTarget: now used 'uname' instead of 'busybox uname'
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.
2016-06-16 13:56:13 +01:00
setrofim
cf791d1e64 Merge pull request #35 from derkling/cgroup-fix-setup
Cgroup fix setup
2016-05-27 16:39:50 +01:00
setrofim
bbee251547 Merge pull request #39 from ep1cman/fixes
AndroidDevice: kick-off no longer requires root
2016-05-27 16:37:55 +01:00
Sebastian Goscik
9af32ec485 AndroidDevice: kick-off no longer requires root
kick off will now use root if the device is rooted or if manually
specified otherwise its run without root.
2016-05-27 16:36:45 +01:00
Patrick Bellasi
c4e46b7c26 target: add a "setup" stage for modules initialisation
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>
2016-05-13 18:15:51 +01:00
Sergei Trofimov
6bda8cb867 AndroidTarget: do not set executables_directory inside __init__
This is already being resolved inside the base's __init__.
2016-03-04 18:34:09 +00:00
Sergei Trofimov
ebe3a8a0a8 LinuxTarget: fixing reboot sequence
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.
2016-02-25 10:28:45 +00:00
Sebastian Goscik
bdbf474023 uname: Fixed calls to uname to use busybox
Not all devices have uname, since devlib deploys its own busybox binary
the most portable way to use uname is to use it via busybox.
2016-02-24 14:29:05 +00:00
Sebastian Goscik
f5b7c82f52 AndroidTarget & LinuxTarget: Added a model property 2016-02-23 17:11:26 +00:00
Sebastian Goscik
040daab2cb Target: Fixed fstab parsing 2016-02-23 10:30:02 +00:00
Sebastian Goscik
0a8b0c6989 AndroidTarget: Added package data and extrenal storage path settings
`package_data_directory` and `external_storage_directory` are now arguments of AndroidTarget
2016-02-23 10:30:02 +00:00
Sebastian Goscik
ff8261e44b AndroidTarget: Updated default executables_directory
Now defaults to '/data/local/tmp' which is both executable and writable
on all android devices, including production ones.
2016-02-15 15:55:59 +00:00
Sebastian Goscik
1424cebb90 Added quotes around commands using raw paths
This fixes issues with spaces in path names.
2016-02-15 15:46:35 +00:00
Sebastian Goscik
aab487c1ac pylint 2016-02-15 15:44:38 +00:00
Sebastian Goscik
880a0bcb7c AndroidTarget: Added swipe direction to swipe_to_unlock
swipe_to_unlock can now do either horizontal or vertical swipes to
unlock a target
2016-02-15 15:44:38 +00:00
Sebastian Goscik
cafeb81b83 AndroidTarget: Added android_id property
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."
2016-02-15 15:44:38 +00:00
Sebastian Goscik
be8f972f60 Target: Added install_if_needed method
This method will first search the target for a binary, only installing
it, if one was not found.
2016-02-15 15:44:33 +00:00
Sebastian Goscik
84151f953a Target: Modified get_installed search order
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.
2016-02-15 15:09:27 +00:00