1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00
Commit Graph

110 Commits

Author SHA1 Message Date
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
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
Sergei Trofimov
89256fd408 connetion: fixing None timeout issue
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
2016-05-17 14:00:01 +01:00
Patrick Bellasi
616f229949 cgroups: requires initialization after the "setup" stage
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>
2016-05-13 18:17:22 +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
setrofim
1dc1e1364c Merge pull request #28 from msrasmussen/patch-1
Fix typos in overview documentation
2016-04-27 11:01:42 +01:00
setrofim
232204633f Merge pull request #33 from derkling/fix-cgroups-noprefix
Fix cgroups noprefix
2016-04-27 08:55:18 +01:00
Patrick Bellasi
4b58c573a5 cgroups: make probe method more robust
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>
2016-04-26 16:38:30 +01:00
Patrick Bellasi
3acf5d56df cgroups: run some commands with root permissions
Certain commands requires in general root permissions to be properly
executed (for example on an Android target).

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-04-26 16:38:30 +01:00
Patrick Bellasi
96392fd6b5 cgroups: fix run_into shutils
On some targets the run_into function is not passing all params to the
called application. This patch should fix that using shift to get a list
of all command parameters.

Moreovere, we use now exec to spawn the command execution, which avoids to
generate yet another shell to run the required command.
2016-04-26 16:38:30 +01:00
Patrick Bellasi
c976189444 cgroups: fix get attributes for controller noprefix mounted
CGroups controller can be mounted by specifying a "noprefix" option,
in which case attribute names are named as:
   <mountpoint>/<attribute_name>
instead of the (more recent) naming schema using:
   <mountpoint>/<contoller_name>.<attribute_name>

For example, Android uses the old format for backward compatibility
with user-space. Thus, it's possible in general to work on a target
system where some controller are mounted "noprefix" while others not.

This patchset adds a set of updates which allows to use the proper
attributes naming schema based on how the controller has been mounted.

This patch provides a more generic implementation of the get attributes
shutils which is working also for noprefix mounted controllers.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-04-26 16:38:28 +01:00
Patrick Bellasi
658005a178 cgroups: properly format attributes path and check for being supported
CGroups controller can be mounted by specifying a "noprefix" option,
in which case attribute names are named as:
   <mountpoint>/<attribute_name>
instead of the (more recent) naming schema using:
   <mountpoint>/<contoller_name>.<attribute_name>

For example, Android uses the old format for backward compatibility
with user-space. Thus, it's possible in general to work on a target
system where some controller are mounted "noprefix" while others not.

This patchset adds a set of updates which allows to use the proper
attributes naming schema based on how the controller has been mounted.

This patch makes use of the Controller::_noprefix option to properly
build the attribute path. It adds also a check which reports a more
clear error in case an attribute is set which is not provided by the
controller.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-04-26 16:38:25 +01:00
Patrick Bellasi
15f9c03b45 cgroups: keep track if a controller is mounted with noprefix option
CGroups controller can be mounted by specifying a "noprefix" option,
in which case attribute names are named as:
   <mountpoint>/<attribute_name>
instead of the (more recent) naming schema using:
   <mountpoint>/<contoller_name>.<attribute_name>

For example, Android uses the old format for backward compatibility
with user-space. Thus, it's possible in general to work on a target
system where some controller are mounted "noprefix" while others not.

This patchset adds a set of updates which allows to use the proper
attributes naming schema based on how the controller has been mounted.

This first patch keeps track of whatever a controller has been mounted
using the noprefix option.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-04-26 16:38:21 +01:00
Patrick Bellasi
28739397c0 cgroups: add a couple of functions to move tasks among groups
This patch provides a couple of utility functions which makes it
easy to run a command under a specific CGroup or to move all tasks
from a group to another.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-04-22 11:43:49 +01:00
setrofim
741157c000 Merge pull request #31 from derkling/fix-newline-separator
fix: AdbConnection: added automatic detection of new line separators
2016-03-29 09:26:06 +01:00
Patrick Bellasi
c2329bd80e fix: AdbConnection: added automatic detection of new line separators
The newline separator is a property of AdbConnection while the adb_shell is
just a method of the android module, thus we do not have a "self" pointer
to and AdbConnection from within the adb_shell function.

This patch fixes 8de24b5 by exposing the newline_separator used by adb_shell
as a parameter of that method and using the AdbConnection::newline_separator
to properly initialize it at executue() time.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-03-28 12:29:45 +01:00
setrofim
10978b0fd7 Merge pull request #29 from ep1cman/fixes
AdbConnection: added automatic detection of new line separators
2016-03-23 15:20:58 +00:00
Sebastian Goscik
8de24b5601 AdbConnection: added automatic detection of new line separators 2016-03-23 15:10:26 +00:00
Morten Rasmussen
192fb52cae Fix typos in overview documentation 2016-03-21 15:15:26 +00: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
setrofim
91f4f97a0b Merge pull request #25 from mdigiorgio/bg-as_root
ssh: add possibility to run command in background as root
2016-03-01 14:37:51 +00:00
Michele Di Giorgio
3bf3017f85 ssh: add possibility to run command in background as root
Executing a command as root was not possible when running it in background.
This is done in a similar way as with a standard execute call.

This was also a bug in ssh.py because if you tried to run a background command
on the target, the background function in target.py was passing the as_root
parameter which was not present in ssh.py.

Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
2016-03-01 11:12:10 +00:00
setrofim
95aaa2662e Merge pull request #17 from derkling/ftrace_optional_confs
FTrace: optional function and events
2016-02-26 08:23:46 +00:00
setrofim
fbe4c4b730 Merge pull request #24 from derkling/cgroup-fixups
cgroup: demote info logging statement
2016-02-26 08:23:05 +00:00
Patrick Bellasi
7112cfef3a cgroup: demote info logging statement
The info statements are clobbering the "normal" output of devlib users.
This patch demote the logging to debug level. The user can still
log-report these information from the corresponding functions call site.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-25 18:47:39 +00:00
Patrick Bellasi
32defe1ce3 ftrace: demote info logging statement
This is the only info statement which is thus clobbering the "normal"
output of a client ueser for that devlib. This patch demote the logging
to debug level. The user can still log-report the output file which is also
an input parameter.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-25 18:47:31 +00:00
Patrick Bellasi
78aa774e25 ftrace: disable trace events not available in the target kernel
In general we could be interested to define a common configuration to use
across different kernels. Thus, for a given set of experiments, some
trace events can be present only on some kernels and not others.

This patch introduces a check for the availability of trace events by
ensuring that we consider only those available in the kernel in use
in the target. In case of a trace event is not supported in the target
kernel we still log a warning.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-25 18:47:31 +00:00
Patrick Bellasi
d7bbad3aac ftrace: disable tracing of functions not available in the target kernel
In general we could be interested to defined a common configuration to use
across different kernels. Thus, for a given set of experiments, some
functions can be present only on some kernels and not others.

This patch updates the check for the availability of functions to profile by
ensuring that we consider only functions available in the kernel in use
in the target. In case of a function cannot be profiled in the target kernel
we log a warning instead of raising an exception.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-25 18:47:31 +00:00
Patrick Bellasi
a8dfd2e744 ftrace: bugfix start marker injection
The start marker must be inserted when tracing has been already enabled.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-25 18:47:31 +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
setrofim
9c89ca0437 Merge pull request #22 from derkling/cgroup-fixups
Cgroup fixups
2016-02-24 14:32:13 +00:00
setrofim
3f804a42fe Merge pull request #23 from ep1cman/fixes
uname: Fixed calls to uname to use busybox
2016-02-24 14:30:46 +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
Patrick Bellasi
e2e5e687e9 cgroups: use splitlines instead of split('\n')
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-24 11:22:48 +00:00
Patrick Bellasi
a65ff13617 cgroups: fix attributes reporting for controller with only one attribute
The current code used to read the attributes values for a controller uses
a "grep '' CONTROLLER.*" under the assumption that the output is a list of
   file:value
However, if there is a single controller attribute, grep does not report
the file name in output thus returning an empty list at the python side.

This patch fix that issue by also switching to the usage of a shutil
implementation of the attributes parsing code.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-24 11:22:48 +00:00
setrofim
615f1ce5e8 Merge pull request #21 from ep1cman/fixes
Fixes
2016-02-23 17:15:00 +00:00
Sebastian Goscik
f5b7c82f52 AndroidTarget & LinuxTarget: Added a model property 2016-02-23 17:11:26 +00:00
Sebastian Goscik
a7f6ddb05a LocalConnection: Added a password parameter
This means it can now be set programatically and not always require
a prompt.
2016-02-23 17:11:26 +00:00
setrofim
f420612b5b Merge pull request #19 from ep1cman/fixes
AndroidTarget: Added package data and extrenal storage path settings
2016-02-23 10:35:46 +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
setrofim
e7aea717cc Merge pull request #18 from ep1cman/fixes
Updates to support WA integration
2016-02-16 12:51:08 +00:00
Sebastian Goscik
0c11289e18 Android: Updated ANDROID_VERSION_MAP 2016-02-15 15:55:59 +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