1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-08 21:11:54 +01:00
Commit Graph

74 Commits

Author SHA1 Message Date
Valentin Schneider
6bda0934ad utils/android: LogcatMonitor fixes
host.kill_children() is used to properly kill the logcat process
when it is IO blocked.

The logcat regexp argument is now within double quotes, as having
parenthesis within the regexp could break the command.

LogcatMonitor.search() has been renamed to wait_for() to make the
behaviour of the method more explicit. A non-blocking version of
this method has been added and is named search().
2017-09-12 17:21:31 +01:00
Valentin Schneider
035181a8f1 utils/android: Add LogcatMonitor 2017-09-11 17:12:11 +01:00
Quentin Perret
34d73e6af1 utils/gem5: try to cast statistics dump values
All values in the gem5 statistics log file are numeric. This commit adds a
cast on the strings read from the stats file to native numeric values when
and logs a warning in case of a malformed entry.
2017-08-22 16:16:09 +01:00
Sergei Trofimov
3d10e3eae9 utils/types: numeric expeanded to handle percentages
numeric() conversion function is expanded to handle percentage values in
the form "10.123%". The result is the numeric part converted to a float
and divided by 100, e.g. 0.10123.
2017-08-16 16:00:38 +01:00
Brendan Jackman
380ad0515d ssh: Improve error when failing to push file
CalledProcessError doesn't include the output of the failed command
in the message it prints, so use a HostError isntead.
2017-08-09 16:01:49 +01:00
Brendan Jackman
93b39a7f47 ssh: Fix redacting SSH password in errors
IIUC this is supposed to redact the password from exception messages,
but 'pass_string' is not set to the password so nothing is
altered. Fix that.
2017-08-09 16:01:49 +01:00
setrofim
1da8d3f95f Merge pull request #151 from AnthonyARM/master
Add support for arbitrary ADB servers
2017-07-31 15:51:15 +01:00
Anthony Barbier
7919a5643c Add support for arbitrary ADB servers 2017-07-25 13:48:33 +01:00
Marc Bonnici
02c93b48ab ABI_MAP: Adds 'armeabi-v7a' to mapping 2017-07-20 14:24:07 +01:00
Marc Bonnici
68be9d8acc utils/android: Added native code extraction of apks from WA2 2017-07-14 17:20:24 +01:00
Sergei Trofimov
85036fbb30 utils/android: better error message when exit code not detected
Include the stdout/stderr output in the message of the exception raised
when the exit code of the adb command cannot be detected.
2017-07-12 13:46:19 +01:00
Ionela Voinescu
0a95bbed87 misc.py: fix syntax error introduced by 86c9b6a1c7
Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
2017-07-10 16:07:28 +01:00
Sergei Trofimov
86c9b6a1c7 utils/misc: update MIDR table
Update the MIDR CPU part number table with values from
https://github.com/torvalds/linux/blob/master/arch/arm64/include/asm/cputype.h
2017-07-10 15:03:59 +01:00
Quentin Perret
baedd676a9 module: Control and parse gem5's statistics log file
Gem5's statistics log file contains plenty of interesting information
that are not exposed so far. This module enables control and parsing of
the statistics file by:
 - configuring periodic dumps of statistics;
 - marking Regions of Interest (ROIs);
 - and extracting values of specific fields during the ROIs.
2017-07-07 11:33:28 +01:00
Anthony Barbier
c837a29299 Let the user customize the way to execute superuser commands 2017-06-28 15:08:35 +01:00
setrofim
7145b366ab Merge pull request #133 from valschneider/fix-activity-error
utils/android: Fix error detection in adb_shell()
2017-06-13 08:57:56 +01:00
Valentin Schneider
2d96840873 utils/android: Fix error detection in adb_shell()
If we execute a command such as:
'am start -a android.intent.action.VIEW -d nothing'
on Hikey960 with AOSP master, we do get an error message:
'Error: Activity not started, unable to resolve Intent ...'
but the error code is set to 0. Furthermore, that error message
is outputted to STDERR and not STDOUT.

The current error checking in adb_shell() is done by either
reading the error code or finding an error string in the
standard output. This commit adds a check of the error output,
and also changes the regular expression that is used to find
an error string as it wasn't generic enough.
2017-06-12 19:08:10 +01:00
Sergei Trofimov
2b3cee6a7e rendering: Add surfaceflinger frame collector
Add a FrameCollector implementation that utilizes the output from
surfaceflinger (the Android compositor). This is is the only method for
accessing rendering data on older Android devices.
2017-06-07 11:53:57 +01:00
Sergei Trofimov
195085e28d rendering: Add gfxinfo frame data collector
Add display rendering frame collector that utilizes gfxinfo utility
present on newer Android devices.
2017-06-07 11:53:52 +01:00
Ionela Voinescu
cac70cba19 gem5: modify pull method to support transfer of multiple files
When providing a source file with wildcards (e.g. *ramp*.log)
to be pulled from the target, this might involve transferring
multiple files.
Add support for the transfer of multiple files in the pull method.

Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
2017-05-23 16:53:18 +01:00
Anouk Van Laer
35987d5281 Gem5Connection: Correct pull method
The pull method used when connecting to gem5 uses the 'm5 writefile'.
This only works if the file to pulled in, is in the current working directory
on the target. The file therefore might need to be copied on the target, from its
original location to the working directory.
The previous implemention of this was incorrect and used information about the
current working directory on the host.
2017-05-17 15:49:20 +01:00
Sergei Trofimov
97a89970d0 android: downgrading ls command log to debug
The format of an ls command is an implementation detail rather than
something of immediate interest to the user. Debug level is more
appropriate than info for this kind of message.
2017-05-12 10:45:42 +01:00
Sascha Bischoff
f5906cb4ab Gem5Connection: Propagate the check_error_code flag
Previously, the flag was not propagated, so the error code was always
checked. With this change, we propage it to the _gem5_shell method.
2017-05-11 10:34:24 +01:00
setrofim
783669371d Merge pull request #120 from bjackman/speed-up-ssh-execute
ssh: Combine exit code and main command
2017-05-04 16:59:22 +01:00
Brendan Jackman
0a20cec2d9 ssh: Combine exit code and main command
This avoids a network round trip and speeds up SSH targets.
2017-05-04 16:47:37 +01:00
Brendan Jackman
e17b9c33d1 android: Raise better error when trying to push non-existent file 2017-04-28 11:32:23 +01:00
Sergei Trofimov
bd27de194c SshConnection: do not try to sudo as root
If a command is executed "as_root", SshConnection always prepended
"sudo" invocation to the command, even if the user name is "root". This
causes problems on patforms that do not have "sudo".

This commit changes this behavior so that sudo is never used for root
users.
2017-04-20 17:12:01 +01:00
Brendan Jackman
3298205b42 android: Improve error when _setup_ls fails
If the ADB command fails (e.g. if you provide the wrong device ID), adb_command
raises a CalledProcessError. CalledProcessError doesn't print the output of the
failed command, so you get a useless error message.

This is relevent here in particular as _setup_ls is the first thing to run an
ADB command if a non-IP device ID is provided.

Catch the CalledProcessError and instead raise a HostError with the command
output in the exception message.
2017-03-01 18:56:05 +00:00
Sergei Trofimov
fef7c16b42 utils/misc: allow modules in walk_modules input
Previsously, the import path passed to walk_modules must have been
pointing to a package. This update allows the path to point to a single
module.
2017-02-27 17:12:20 +00:00
Sergei Trofimov
1dd6950177 utils/misc: attach exc_info on error in walk_modules
Commit 28891a82 made it easier to debug issues during walk_modules by
attaching the specific name of the module being loaded to the exception.
However, the error may not originite in the imported module, but one of
the modules that module itself is importing.

To further facilitate debugging, exc_info (which contains the traceback)
for the orginal ImportError is now also attached to the raised
HostError.
2017-02-23 09:25:23 +00:00
Patrick Bellasi
da588ea091 android: allow to specify a target for fastboot commands
ADB commands always expect a device ID as first parameter, here
unfortunately we need to pass it as an optional one to avoid breaking
existing clients.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2017-02-16 13:08:31 +00:00
Sergei Trofimov
28891a822b utils/misc: walk_modules always raises HostError
Previously, if an error had occured while attempting to load a module
during walk_modules, it was propagated to the loading code. This
meant that walk_modules could, in theory, raise any exception at all,
and that it was not always possible to tell exactly where the exception
originated.

Now, all encounted errors are re-raised as HostError, which preserves
the original exception in an attribute and sets "modpath" attribute to
point to the module that originated it.
2017-02-08 11:30:33 +00:00
Sergei Trofimov
a9265031ba TimeoutError: moved to devlib.exception
Moved TimeoutError from devlib.util.misc to devlib.exception. It was
previously defined in misc because it needed to be there when the code
was part of WA in order to prevent an import cycle. This is not
necessary in devlib, so it is moved to be with the other exception
definitions.
2017-02-08 11:29:42 +00:00
Anouk Van Laer
29a7940731 gem5: Addition of a gem5 connection
This is the first in a series of commits to allow for the use of gem5 as a target in devlib.
The interaction with the gem5 simulation is done by the Gem5Connection, a type of TelnetConnection.
There are two types of Gem5Connections (Linux and Android) as they differ slightly in the implementation
of some methods. Other types of connections have only been changed to make them uniform (e.g. arguments for init method)

 Changes to be committed:
	modified:   devlib/__init__.py
	modified:   devlib/host.py
	modified:   devlib/utils/android.py
	modified:   devlib/utils/ssh.py
2017-02-08 11:12:17 +00:00
Brendan Jackman
44fe0370f8 android: Handle variation in ADB behaviour
On older combinations of ADB/Android versions, the adb host command always
exits with 0 if it was able to run the command on the target, even if the
command failed (https://code.google.com/p/android/issues/detail?id=3254).

When we need the target's exit code (check_exit_code=True), we currently work
around this behaviour by echoing the target's exit code after the command and
parsing it out of the output.

The ADB behaviour is now "fixed" on newer versions with newer Androids (It's not
clear which versions these are and it appears that different builds of ADB with
the same version number differ in this respect). For those version combinations
adb_shell will currently raise a CalledProcessError when check_exit_code=False
and the target command fails.

So lets now use the "echo $?" trick whether or not we need the exit code.

Fixes https://github.com/ARM-software/devlib/issues/85
2017-01-25 15:27:13 +00:00
Sergei Trofimov
d5460e1185 android: pick ANDROID_HOME/platform-tools over PATH
When ANDROID_HOME is defined, ANDROID_HOME/platform-tools was appended
to the PATH in the environment of the Python interpreter. That meant
that if an adb binary was in PATH, it would be picked in preference to
the one under ANDROID_HOME. This is now reversed so that ANDROID_HOME
takes precedence.
2016-12-13 11:26:32 +00:00
Sergei Trofimov
b3cea0c0d2 TelnetConnction: splitting from SshConnection
Perviously, a parameter passed into SshConnection controlled whether the
connection was established over SSH or Telnet. Now, there is a separate
class for Telnet connections.
2016-12-08 11:50:17 +00:00
Sergei Trofimov
5d492ca957 utils/misc: Adding Kryo cores to CPU part map
Adding part IDs of Qualcomm Kryo Gold and Silver cores to the CPU part
map.
2016-11-29 13:11:04 +00:00
Brendan Jackman
ee38a4244a android: Fix whitespace in wildcard match for ADB pull
When there are multiple matches for the wildcard, the output has been
observed to have a space at the end. That means the pull command doesn't
work. This commit fixes that.
2016-11-25 18:29:59 +00:00
Marc Bonnici
b59f7c360e android: Fixed issue using single quoted command with adb_shell
When using 'check_exit_code' and 'as_root' options for adb_shell with
a command containing single quotes, the provided command was escaped
twice which has now been avoided.
2016-11-02 14:36:03 +00:00
Chris Redpath
e8e945a700 Fix adb pull with wildcard on Android v7+
Similarly to other uses of ls, the change to multi-column default output
format has confused this API. Add in a similar routine to other objects
which use ls, so that we can try to figure out if we have a multi-column
default and control the output if so, or just use the plain command if
that doesn't work and hope it is still single column output.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
2016-10-14 14:35:58 +01:00
Chris Redpath
119fd7dc24 android: don't try to disconnect devices which aren't connected
If you try to disconnect a device and there are none, certain versions
of adb return 1, which leads to a TargetError and stops everything in
its tracks.

Try to mitigate this by checking if the device we want to disconnect is
connected before we make the disconnect call.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
2016-10-06 16:34:14 +01:00
Sergei Trofimov
cae239d1dc memoized: detect hashability by catching TypeError
This is a fix for

https://github.com/ARM-software/devlib/issues/60

Apprently, being an instance of Hashable does not mean that the object
is, in fact, hashable. So rather than testing for hashability, try to
hash the object and handle the potential error by falling back to the
old method.
2016-10-06 08:44:42 +01:00
Sergei Trofimov
09ec88e946 memoized: further fixes; hash objects whre possible
This is further to commit 6d854fd4dc

Due to the way certain objects are handled, getting the frist few bytes
of an object may not be enough (e.g. strings do not store their values
inline). To further mitigate the issue, hash the object where possible.
2016-10-04 17:57:46 +01:00
Sergei Trofimov
08b36e71cb utils; adding more CPU part numbers 2016-09-06 16:01:09 +01:00
Sergei Trofimov
6d854fd4dc memoized: fix for bug where wrong cached results were returned
memoized() used id() to get "unique" representations for arguments
passed to a function, in order to ensure that results for the same
function called with different arguments are treated differently.

However, Python object identities are only guaranteed to be unique at a
particular point in time. It is possible than a particular ID gets
reused for a different object if the previous object associated with
that ID no longer exists. In particular, in CPython, the IDs are just
addresses of the corresponding PyObject's in memory. If a PyObject gets
garbage collected, another object may get allocated in its place, and
the new object will "inherit" the ID by virtue of being in the same
memory location. If the new object is then used to call a memoized
function that was previously called with the old object, the old cached
result will be incorrectly returned.

To get around this issue, the cache is now indexed not only by the ID of
an object but also but the first few bytes of its value.

NOTE: there is still a potential issue it two relatively large objects
gets allocated in the same place and happen to share the first few
(currently 32) bytes, and are then both used as parameters to the same
memoized function. The only way around that is to hash the entire value
of the object. However, given the performance penalty that would incur
for larger object, and the unlikeliness of this situation actually
arising, it is currently deemed not worth it.
2016-09-06 09:57:58 +01:00
Sergei Trofimov
d7aac2b5df utils: added a function to reset memoized cache
Added a function to reset the memo cache used by memoized decorator,
which would force all memoized functions to re-evalued their results
when they are next called. This is primarily intended for debugging.
2016-09-02 13:24:30 +01:00
setrofim
0c8f26763b Merge pull request #49 from derkling/fix-adb-connect
android: avoid connect for USB target
2016-07-29 16:09:17 +01:00
Gareth Stockwell
f24493676c TelnetConnection: allow username and/or password to be optional
If username is set to None, no '-l' option is appended to the telnet command.
If password is set to None, devlib does not wait for a password prompt when
connecting.
2016-07-29 14:52:52 +00:00
Gareth Stockwell
76b059c6b1 TelnetConnection: allow client to specify the original prompt string 2016-07-29 14:52:52 +00:00