1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-19 12:24:32 +00:00

Merge pull request #161 from ep1cman/fixes

Added sqlite3 binary & changed kick_off signature
This commit is contained in:
setrofim 2016-05-09 17:36:04 +01:00
commit 2cf08cf448
6 changed files with 43 additions and 4 deletions

View File

@ -24,6 +24,8 @@ import threading
from subprocess import CalledProcessError from subprocess import CalledProcessError
from wlauto.core.extension import Parameter from wlauto.core.extension import Parameter
from wlauto.common.resources import Executable
from wlauto.core.resource import NO_ONE
from wlauto.common.linux.device import BaseLinuxDevice, PsEntry from wlauto.common.linux.device import BaseLinuxDevice, PsEntry
from wlauto.exceptions import DeviceError, WorkerThreadError, TimeoutError, DeviceNotRespondingError from wlauto.exceptions import DeviceError, WorkerThreadError, TimeoutError, DeviceNotRespondingError
from wlauto.utils.misc import convert_new_lines from wlauto.utils.misc import convert_new_lines
@ -193,6 +195,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
self._is_ready = True self._is_ready = True
def initialize(self, context): def initialize(self, context):
self.sqlite = self.deploy_sqlite3(context) # pylint: disable=attribute-defined-outside-init
if self.is_rooted: if self.is_rooted:
self.disable_screen_lock() self.disable_screen_lock()
self.disable_selinux() self.disable_selinux()
@ -442,7 +445,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
else: else:
return adb_shell(self.adb_name, command, timeout, check_exit_code, as_root) return adb_shell(self.adb_name, command, timeout, check_exit_code, as_root)
def kick_off(self, command): def kick_off(self, command, as_root=True):
""" """
Like execute but closes adb session and returns immediately, leaving the command running on the Like execute but closes adb session and returns immediately, leaving the command running on the
device (this is different from execute(background=True) which keeps adb connection open and returns device (this is different from execute(background=True) which keeps adb connection open and returns
@ -453,7 +456,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
Added in version 2.1.4 Added in version 2.1.4
""" """
if not self.is_rooted: if not self.is_rooted or not as_root:
raise DeviceError('kick_off uses busybox\'s nohup applet and so can only be run a rooted device.') raise DeviceError('kick_off uses busybox\'s nohup applet and so can only be run a rooted device.')
try: try:
command = 'cd {} && busybox nohup {}'.format(self.working_directory, command) command = 'cd {} && busybox nohup {}'.format(self.working_directory, command)
@ -529,6 +532,11 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
return props[prop] return props[prop]
return props return props
def deploy_sqlite3(self, context):
host_file = context.resolver.get(Executable(NO_ONE, self.abi, 'sqlite3'))
target_file = self.install_if_needed(host_file)
return target_file
# Android-specific methods. These either rely on specifics of adb or other # Android-specific methods. These either rely on specifics of adb or other
# Android-only concepts in their interface and/or implementation. # Android-only concepts in their interface and/or implementation.
@ -629,7 +637,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
""" """
lockdb = '/data/system/locksettings.db' lockdb = '/data/system/locksettings.db'
sqlcommand = "update locksettings set value='0' where name='screenlock.disabled';" sqlcommand = "update locksettings set value='0' where name='screenlock.disabled';"
self.execute('sqlite3 {} "{}"'.format(lockdb, sqlcommand), as_root=True) self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True)
def disable_selinux(self): def disable_selinux(self):
# This may be invoked from intialize() so we can't use execute() or the # This may be invoked from intialize() so we can't use execute() or the

Binary file not shown.

Binary file not shown.

View File

@ -207,7 +207,7 @@ class Gem5AndroidDevice(BaseGem5Device, AndroidDevice):
""" """
lockdb = '/data/system/locksettings.db' lockdb = '/data/system/locksettings.db'
sqlcommand = "update locksettings set value=\'0\' where name=\'screenlock.disabled\';" sqlcommand = "update locksettings set value=\'0\' where name=\'screenlock.disabled\';"
self.execute('sqlite3 {} "{}"'.format(lockdb, sqlcommand), as_root=True) self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True)
def capture_screen(self, filepath): def capture_screen(self, filepath):
if BaseGem5Device.capture_screen(self, filepath): if BaseGem5Device.capture_screen(self, filepath):

11
wlauto/external/sqlite/README vendored Normal file
View File

@ -0,0 +1,11 @@
For WA we use a slightly modified version of sqlite3 so that it can
be built statically. We used the amalgamated sqlite3 version 3.12.2.
which is under the public domain.
https://www.sqlite.org/download.html
Build command:
gcc shell.c sqlite3.c -lpthread -ldl -static -O2 -fPIC -DPIC -DSQLITE_OMIT_LOAD_EXTENSION
You will need to apply the diff in static.patch

20
wlauto/external/sqlite/static.patch vendored Normal file
View File

@ -0,0 +1,20 @@
--- shell.c 2016-05-09 15:35:26.952309563 +0100
+++ shell.c.bak 2016-05-09 15:33:41.991259588 +0100
@@ -4503,7 +4503,7 @@
static char *home_dir = NULL;
if( home_dir ) return home_dir;
+/*#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
-#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
&& !defined(__RTP__) && !defined(_WRS_KERNEL)
{
struct passwd *pwent;
@@ -4512,7 +4512,7 @@
home_dir = pwent->pw_dir;
}
}
+#endif*/
-#endif
#if defined(_WIN32_WCE)
/* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()