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>
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.
This is further to commit 6d854fd4dc59936142fff811e575cd034a308c43
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.
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>
Configuration sysfs files required by ftrace are usually accessible only by
the root user. In systems where ADB does not run as root by default, the
initialisation of the ftrace module fails.
This patch ensure that all ftrace commands are executed with root privileges.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
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.
Prior to this commit, measurements to be collected were specified via
"sites" and "kinds" parameters. This has the limitation that if you
wanted measurments of kind X from site A and kind Y from site B, you'd
have to specify them as
reset(sites=['A', 'B'], kinds=['X', 'Y'])
Which would have the effect of also collecting measurments Y for site A
and measurments X for site B. This commit adds the option of specifying
individual channels, via thier labels, e.g.
reset(channels=['A_X', 'B_Y'])
so that only the channels you're interested in will be collected.
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.
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().
When passing an idle state ID to get_states(), nothing is returned. Also, there
is a wrong call to enable() in the method.
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
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.
The "adb connect" command is not required for USB connected devices.
This patch is a small update to use "adb connect" only for android devices
accessed by IP address.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
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.
Using the wrapt module we can improve the memoize decorator. In fact, it allows
to preserve the attributes of the memoized function, such as signature,
docstring, path to the file where the function is implemented, and so on.
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
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.
Connection objects set timeout to a default value in case a timeout is
not specified. However, Target defaults timeout to None and passes that
to connection, overridng the default.
This commit ensures that default timeout remains set if calling code
specified timemout as None.
Fix for issue
https://github.com/ARM-software/devlib/issues/34
The cgroups module requires busybox and shutil to properly initialise.
This patch required the module to be initialized once the setup has
completed.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
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>
In case a target does not report a configuration file, we can still check
the user-space API to verify it CGroups are supported.
NOTE: a rooted target is still a mandatory requirement because some commands
are still dependant on the possibility to run them with root permissions.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>