diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 532: change to use Launcher information in logcat to check the display of home screen

Message ID 20130121024517.23539.68036.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Yongqin Liu Jan. 21, 2013, 2:45 a.m. UTC
Merge authors:
  Yongqin Liu (liuyq0307)
Related merge proposals:
  https://code.launchpad.net/~liuyq0307/lava-dispatcher/check-home-screen/+merge/143643
  proposed by: Yongqin Liu (liuyq0307)
  review: Approve - Andy Doan (doanac)
------------------------------------------------------------
revno: 532 [merge]
committer: Yongqin Liu <yongqin.liu@linaro.org>
branch nick: lava-dispatcher
timestamp: Mon 2013-01-21 10:44:08 +0800
message:
  change to use Launcher information in logcat to check the display of home screen
modified:
  lava_dispatcher/client/base.py
  lava_dispatcher/config.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/base.py'
--- lava_dispatcher/client/base.py	2013-01-14 16:29:38 +0000
+++ lava_dispatcher/client/base.py	2013-01-19 03:43:23 +0000
@@ -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'
--- lava_dispatcher/config.py	2013-01-10 21:37:58 +0000
+++ lava_dispatcher/config.py	2013-01-18 11:08:24 +0000
@@ -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")