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

135 Commits

Author SHA1 Message Date
Marc Bonnici
454b94501c pylint fixes 2018-07-13 16:05:49 +01:00
Sergei Trofimov
472c5a3294 target: add system_id
Add system_id attribute to targets. This ID is supposed unique for a
combination of hardware, kernel, and the file system, and contains
elements from each.

1. Hardware is identified by the concatenation of MAC addresses of
   'link/ether' network  interfaces on the system. This method is used,
   as DMI tables are often unimplemented on ARM targets.
2. The kernel is identified by its version.
3. The file system is identified by the concatenation of UUID's of the
   target's partitions. It would be more correct to only use UUID of
   the root partition, as system_id is not intended to be affected by
   removable, media, however, there is no straight-forward way of
   reliably identifying that without root.

system_id is intended to be used as an key for the purposes of caching
information about a particular device (e.g. so that it does not need to
be probed on each run).
2018-07-13 13:18:39 +01:00
Sergei Trofimov
9fd690efb3 Update copyrights
- Update the year in the copyrights to match the last year the file was
  modified.
- Add the copyright header to files that did not already have one.
2018-07-04 16:01:47 +01:00
Marc Bonnici
e16c42fe2c target: Add new attribute to Target to indicate a container
Allow for a flag to be set to indicate that the target is a container
and therefore may have limited functionality.
2018-07-02 10:49:43 +01:00
Sergei Trofimov
8e1dc1359a target: fix new line handling in os_version
Use convert_new_lines() before stripping out '\n' character from OS
version strings to ensure no stray '\r's are left in.
2018-06-27 14:41:48 +01:00
Valentin Schneider
96ffa64ad8 AndroidTarget: Add some more screen utility methods 2018-06-22 10:23:18 +01:00
Valentin Schneider
38037850b6 AndroidTarget: Add force_new parameter to open_url
When True, this will force whatever application Android deems best
for viewing that url to be relaunched.

This can be useful when trying to open e.g. Google Maps search URLs,
as the actual search result can be influenced by the location being
currently displayed. Forcing the app the be relaunched allows us to
have reproducible behaviours.
2018-06-22 10:23:18 +01:00
Valentin Schneider
bda1115adb AndroidTarget: Fix escape_double_quote typo 2018-06-22 10:23:18 +01:00
Valentin Schneider
7231030991 target: Add strict option to KernelConfig.get()
Defaults to False. If True, will raise an exception when a requested
config name is not exposed in the config instance.
2018-06-14 12:09:25 +01:00
Sergei Trofimov
69cd3be96c target: ensure shell_prompt is a bytes_regex
shell_prompt gets passed into expect and therefore must be encoded as
bytes on Python 3.
2018-06-14 11:34:16 +01:00
Sergei Trofimov
5cafd2ec4d Add support for Python 3
Add support for running on Python 3 while maintaining Python 2
compatibility.
2018-06-07 14:45:43 +01:00
Marc Bonnici
1d9dc42af5 target: Increase timeout for checking if rooted.
One some devices executing this command takes longer than the original 2
seconds allowed causing devlib to incorrectly think it was not rooted.
2018-05-31 09:49:37 +01:00
Marc Bonnici
329df6f42e AndroidTarget: Ensure path is correctly quoted when listing directories
Previously the path for listing a directory on the device was not quoted
causing it to fail on paths containing spaces. Now ensure the string is
quoted and any quotes contained in the string as escaped.
2018-05-10 11:12:25 +01:00
Marc Bonnici
63bf68b49d LinuxTarget: Ensure path is correctly quoted when listing directories
Previously the path for listing a directory on the device was not quoted
causing it to fail on paths containing spaces. Now ensure the string is
quoted and any quotes contained in the string as escaped.
2018-05-10 10:57:59 +01:00
Marc Bonnici
1e839028a1 target.py: Update default shell prompt 2018-04-25 17:25:06 +01:00
Marc Bonnici
bb3ae48d25 exception: Update "TargetNotRespondingError" syntax.
Update the syntax of the TargetNotRespondingError to conform with the
other exceptions of expecting a full message to be displayed rather than just
a target name.
2018-04-24 09:04:28 +01:00
Marc Bonnici
58c0d30b26 target: Make sure xml is encoded properly before writing to file
Some UI elements can contain non ASCII characters so ensure we encode the
output to utf-8 before writing to file.
2018-04-24 09:04:28 +01:00
Sergei Trofimov
8370c8fba3 target: timestamp for capture_screen
Add an option to format an ISO8601 timestamp into the screenshot file
name.
2018-04-11 10:51:38 +01:00
Sergei Trofimov
9678c7372e AndroidTarget: add capture_ui_hierarchy
Add a method to dump XML UI hierarchy from uiautomator.
2018-03-21 15:02:02 +00:00
Sascha Bischoff
335fa77e4e AndroidTarget: add get_pacakge_info
Add a method to get info (apk path) for an installed package.
2018-03-15 17:06:02 +00:00
Marc Bonnici
a992a890b8 AndroidTarget: Add additional permission error to ignore
Also ignore any errors that granting a permission on an Android device
is not permitted.
2018-03-15 12:26:15 +00:00
Marc Bonnici
e22d278267 AndroidTarget: Add method to open a url in the default browser 2018-03-12 11:25:48 +00:00
Sergei Trofimov
7a8f98720d target: add wait_boot_complete to LinuxTarget
Add an empty implementation, as there is currently no generic way of
detecting boot completion for a random Linux system, and it is
considered to be "fully booted" as soon as it ready to accept
connections.
2018-03-07 18:19:59 +00:00
Sergei Trofimov
328e0ade4b target: fix connect on reboot
Previously, commit

	commit 17bcabd461b22434db00552056e7de995fc7f498

	    target: Install busybox before updating modules

moved busybox deployment into Target.connect() so that modules could
make use of it. This means this now happens before AndroidTarget waits
for the boot to complete at the end of its connect(). This means that
an attempt to create the devlib working directory may be made too early.

To get around this, move wait_boot_completed() into Target, and ensure
it returns before attempting to create the working directory.
2018-03-07 18:19:59 +00:00
Sergei Trofimov
f490a55be2 target: conditionally raise from check_responsive
Add an option to check_responsive() to not throw an exception if
unresponsive target is detected, but to act as a predicate instead.
2018-03-07 18:19:59 +00:00
Sascha Bischoff
83e5ddfd1b target: add option to invoke to redirect stderr
The stderr of a command is not propagated as part of the command
output. However, some workloads/commands write vital output to
stderr. For this reason, we add an option to invoke which redirects
stderr to stdout (redirect_stderr). This is disabled by default.
2018-03-01 15:32:49 +00:00
Sergei Trofimov
f3c8ce975e target: fix get_rotation() when null
Some targets don't seem to set system.user_rotation, resulting in "null"
being returned. This exploded on integer conversion. Handle this case by
returning the Python equivalent, None.
2018-02-08 14:27:47 +00:00
Marc Bonnici
d1b08f6df6 target: Fix typos 2018-01-25 06:27:55 +00:00
Marc Bonnici
e9cf7f5cbe target: Adds initial support for ChromeOs targets
Adds initial support for ChromeOs Targets.

If the device does not support running android apps the target will
behave like a `LinuxTarget` however if android is supported, the chromeos
target opens 2 connections, one via shh to the linux target, as normal,
and one via adb to the android container. By default all calls will be
made to the linux target and if not present, will attempt to use the
android container instead. The android container is also exposed via a
`android_container` attribute so can be accessed directly.

In order to detect whether the target supports running android apps the
existance of '/opt/google/containers/android/' will be queried upon
connection to the linux target.
2018-01-25 06:27:55 +00:00
Marc Bonnici
2954a73c1c Target: Generate a new tmp directory when creating shutils
Previously the same temporary directory was used which caused issues
with concurrent runs interfering with each other.
2018-01-18 14:21:39 +00:00
Patrick Bellasi
cc0210af37 LocalLinuxTarget: fix executables folder location
Since:
   cafc0a4 target: do not create shutil in package directory
we generate 'shutils' in /tmp, which is also the executables_path
used by default by a LocalLinuxTarget.

This ultimately results into a:

   self.install(shutils_ofile)
      ...
         shutil.copy(source, dest)

raising an exception since source == dest.

Let's fix this by setting /tmp/devlib-target as a default base path for
all devlib deployed stuff into a localhost target.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2018-01-18 13:03:34 +00:00
Marc Bonnici
f0b58b32c4 target: Add support for as_root to get_directory method. 2018-01-08 17:05:21 +00:00
Marc Bonnici
30257456ab target: Fix creation of destination
Was previously trying to create the output directory including the
filename.
2018-01-08 17:05:21 +00:00
Marc Bonnici
853bdff936 target: Clean up tmp files afer pulling 2018-01-08 17:05:21 +00:00
Marc Bonnici
54d6a6d39d target: Allow pulling of folders as root
Adds '-r' flag to copy command to allow for copying of folders with their contents
to temporary location on the device before pulling.
2018-01-08 17:05:21 +00:00
Anouk Van Laer
462aecdca0 target, android: Set the default timeout to 30s
Previously, the default timeout was 10s which is too short in some cases.
2017-12-12 17:32:08 +00:00
Sergei Trofimov
cafc0a4bc0 target: do not create shutil in package directory
Do not attempt to create shutil from shutil.in inside
PACKAGE_BIN_DIRECTORY as that may not be writable. Instead, create it in
the temporary directory and remove it right after installing.
2017-12-12 13:46:30 +00:00
Valentin Schneider
724c0ec8df target: LocalLinuxTarget: Populate _file_transfer_cache
Since 1e34390b990f1d85b083d31693d71fad5c9f28a6, AndroidTarget and
LinuxTarget share the same code for `push` and `pull`. However,
these methods expect a `_file_transfer_cache` field to be present.
It is currently populated in `_resolve_paths` for AndroidTarget
and LinuxTarget, but not for LocalLinuxTarget.

Since LocalLinuxTarget inherits its `push` & `pull` from LinuxTarget,
this causes an exception. This commit fixes it by adding an assignment
to `_file_transfer_cache` in `LocalLinuxTarget:_resolves_paths`.

This is a simple fix, and the actual push/pull behaviour of that local
target class could be improved in regards to that transfer cache, but
it should be good enough for now.
2017-12-12 13:28:24 +00:00
Brendan Jackman
1e34390b99 Target: Implement as_root parameter for push/pull in base class
The AndroidTarget implementation is actually generic, so just move it
into the parent class so that LinuxTarget gets it too.
2017-12-11 08:07:50 +00:00
Marc Bonnici
e414a3a193 LinuxTarget: Port forbidden char fix from WA2
Fix for Chromebook Plus and possibly other devices - removes forbidden
characters from the device_model such as the null character.
2017-12-08 08:26:53 +00:00
Marc Bonnici
857edbd48b AndroidTarget: Change android default working directory.
Changes the default working directory from
`/data/local/tmp/` to be on the devices external storage
(discovered from $EXTERNAL_STORAGE) which is usually `/sdcard`.
This is due to permission errors on some devices, to be readable
by android applications and will usually have a larger capacity.
2017-11-30 11:46:14 +00:00
Sergei Trofimov
c0a896642d target: fix broadcast_media_mounted for Android O
In an effort to reduce thrashing, "implicit" broadcasts are no longer
allowed in Android O. See:

https://issuetracker.google.com/issues/36496703#comment7

This impacts MEDIA_MOUNTED broadcasts. To get around this issue,
explicitly specify the component the broadcast is targeted at.
2017-11-21 14:34:35 +00:00
Marc Bonnici
899dbfe4fb Target: Ensures path is quoted and escaped 2017-11-13 15:21:27 +00:00
Marc Bonnici
0390c9d26b AndroidTarget: Port methods for refreshing target files
Adds a method to determine the appropriate method of triggering a media
refresh of a given list of file based on the devices android version and root
status. If a device is running android marshmallow and below or has root, trigger a
refresh of the files containing folder otherwise trigger a refresh of each
individual file.
2017-11-13 15:21:27 +00:00
Marc Bonnici
bd03b2f8ac Utils/Android: Enable parsing of apk permissions
Creates a list of permissions that an apk requires for use, this is
useful for granting of permissions to a previously installed apk.
2017-11-13 15:21:27 +00:00
Marc Bonnici
5d40b23310 AndroidTarget: Adds method to grant permission to an installed package
This is useful on later versions of android where a previously
installed application is missing required permissions without
having to reinstall the whole application.
2017-11-13 15:21:27 +00:00
Marc Bonnici
6fae051deb AndroidTarget: Adds property to retrieve path of external storage
In andoid terms the external storage usually means the internal emulated
sdcard located at '/sdcard/'. This is the usually the root location used for
applications to read files that are not part of the application itself
from.
2017-11-13 15:21:21 +00:00
setrofim
af0ed2ab48 Merge pull request #196 from bjackman/is-network-connected
target: Ensure returning False when is_network_connected fails
2017-10-24 16:29:17 +01:00
Brendan Jackman
417ab3df3e target: Ensure returning False when is_network_connected fails 2017-10-24 16:05:05 +01:00
setrofim
dcffccbb69 Merge pull request #193 from bjackman/is-network-connected
target: Add is_network_connected method
2017-10-24 14:36:37 +01:00