=== modified file 'lava_dispatcher/client/base.py'
@@ -35,6 +35,7 @@
GeneralError,
NetworkError,
OperationFailed,
+ CriticalError,
)
from lava_dispatcher.test_data import create_attachment
@@ -90,7 +91,8 @@
def wait_for_prompt(self, timeout = -1):
wait_for_prompt(self._connection, self._prompt_str, timeout)
- def run(self, cmd, response=None, timeout=-1, failok=False):
+ def run(self, cmd, response=None, timeout=-1,
+ failok=False, wait_prompt=True):
"""Run `cmd` and wait for a shell response.
:param cmd: The command to execute.
@@ -124,15 +126,19 @@
self.match_id = None
self.match = None
- self.wait_for_prompt(timeout)
+ if wait_prompt:
+ self.wait_for_prompt(timeout)
- if self._prompt_str_includes_rc:
- rc = int(self._connection.match.group(1))
- if rc != 0 and not failok:
- raise OperationFailed(
- "executing %r failed with code %s" % (cmd, rc))
+ if self._prompt_str_includes_rc:
+ rc = int(self._connection.match.group(1))
+ if rc != 0 and not failok:
+ raise OperationFailed(
+ "executing %r failed with code %s" % (cmd, rc))
+ else:
+ rc = None
else:
rc = None
+
return rc
@@ -290,17 +296,22 @@
"The android device(%s) isn't attached" % self._client.hostname)
def wait_home_screen(self):
- cmd = 'getprop init.svc.bootanim'
- tries = self._client.config.android_home_screen_tries
- for count in range(tries):
- logging.debug("Waiting for home screen (%d/%d)", count, tries)
- try:
- self.run(cmd, response=['stopped'], timeout=5)
- if self.match_id == 0:
- return True
- except pexpect.TIMEOUT:
- time.sleep(1)
- raise GeneralError('The home screen has not displayed')
+ timeout = self._client.config.android_home_screen_timeout
+ launcher_pat = ('Displayed com.android.launcher/'
+ 'com.android.launcher2.Launcher:')
+ #waiting for the home screen displayed
+ try:
+ self.run('logcat -s ActivityManager:I',
+ response=[launcher_pat],
+ timeout=timeout, wait_prompt=False)
+ except pexpect.TIMEOUT:
+ raise GeneralError('The home screen has not displayed')
+ finally:
+ #send ctrl+c to exit the logcat command,
+ #and make the latter command can be run on the normal
+ #command line session, instead of the session of logcat command
+ self._connection.sendcontrol("c")
+ self.run('')
def check_device_state(self):
(rc, output) = commands.getstatusoutput('adb devices')
@@ -439,8 +450,9 @@
"""Reboot the system to the test android image."""
self._boot_linaro_android_image()
TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN']
+ timeout = self.config.android_boot_prompt_timeout
try:
- wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=900)
+ wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout)
except pexpect.TIMEOUT:
raise OperationFailed("booting into android test image failed")
#TODO: set up proxy
=== modified file 'lava_dispatcher/config.py'
@@ -83,7 +83,8 @@
android_adb_over_usb = schema.BoolOption(default=False)
android_adb_over_tcp = schema.BoolOption(default=True)
android_wait_for_home_screen = schema.BoolOption(default=True)
- android_home_screen_tries = schema.IntOption(default=100)
+ android_home_screen_timeout = schema.IntOption(default=1800)
+ android_boot_prompt_timeout = schema.IntOption(default=1200)
android_orig_block_device = schema.StringOption(default="mmcblk0")
android_lava_block_device = schema.StringOption(default="mmcblk0")