From patchwork Thu Nov 1 07:36:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 12644 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7AF7823EF7 for ; Thu, 1 Nov 2012 07:36:17 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 049FEA182D9 for ; Thu, 1 Nov 2012 07:36:16 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so1659101iag.11 for ; Thu, 01 Nov 2012 00:36:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=9xXaDEcZVwuCnjkQ2Rm2yVwYTwfFee+42u3R7fIbsRw=; b=mliX6bMGdoLXFJKrWg0gcu9crJliXOnvGSxWTIfwT+/Jw760/5fRvuckfxKDcwzGlP 87s4rn6bLMM5MfbuuMkN+vmlPNWoqxEsjYgUuoF075hneMCQ5YQ9aXzGxm8Yx9tiasB0 YnRAiIqC6kvcAJdjy3V0b4QgM4ruZaZeoXlCdTUBe+Y3haCWhIy+O4jdcmWcvRsxod11 IqxVL0BOUkEaET0OZKJVSo//USNhUJe3fY43SZ9UraE+aq83/h2vWDqLa4Yejm697SrL NPZBE9N4zsiPgRKQLOKFSWVFdAj3/NOsak1mR9vdv1/csqYsBMzu5OClHbLEcMMjRiHp +pog== Received: by 10.43.7.132 with SMTP id oo4mr33704363icb.6.1351755376445; Thu, 01 Nov 2012 00:36:16 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp748455igt; Thu, 1 Nov 2012 00:36:15 -0700 (PDT) Received: by 10.180.77.231 with SMTP id v7mr578009wiw.9.1351755374479; Thu, 01 Nov 2012 00:36:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id v7si6079728wiw.37.2012.11.01.00.36.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Nov 2012 00:36:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TTpK1-0003jd-9T for ; Thu, 01 Nov 2012 07:36:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 39466E02C7 for ; Thu, 1 Nov 2012 07:36:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 431 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 431: when waiting for a prompt, send the occasional newline to see if a prompt has appeared but was ma... Message-Id: <20121101073613.27856.29205.launchpad@ackee.canonical.com> Date: Thu, 01 Nov 2012 07:36:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16218"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 915e1f9758f39588c64084272983adfe407bb720 X-Gm-Message-State: ALoCoQn+/kODueqEK4OzBEsjxS5oaFYDDga679hra0QdJGhOANp6okiRXdE/QqZUQXevKCJ3Rg3C Merge authors: Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 431 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Thu 2012-11-01 08:35:50 +0100 message: when waiting for a prompt, send the occasional newline to see if a prompt has appeared but was mangled by a kernel log message or serial corruption modified: lava_dispatcher/client/base.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 === modified file 'lava_dispatcher/client/base.py' --- lava_dispatcher/client/base.py 2012-10-18 16:29:08 +0000 +++ lava_dispatcher/client/base.py 2012-10-31 15:33:04 +0000 @@ -34,6 +34,32 @@ from lava_dispatcher.test_data import create_attachment +def wait_for_prompt(connection, prompt_pattern, timeout): + # One of the challenges we face is that kernel log messages can appear + # half way through a shell prompt. So, if things are taking a while, + # we send a newline along to maybe provoke a new prompt. We wait for + # half the timeout period and then wait for one tenth of the timeout + # 6 times (so we wait for 1.1 times the timeout period overall). + prompt_wait_count = 0 + if timeout == -1: + timeout = connection.timeout + partial_timeout = timeout / 2.0 + while True: + try: + connection.expect(prompt_pattern, timeout=partial_timeout) + except pexpect.TIMEOUT: + if prompt_wait_count < 6: + logging.warning('Sending newline in case of corruption.') + prompt_wait_count += 1 + partial_timeout = timeout / 10 + connection.sendline('') + continue + else: + raise + else: + break + + class CommandRunner(object): """A convenient way to run a shell command and wait for a shell prompt. @@ -89,7 +115,9 @@ else: self.match_id = None self.match = None - self._connection.expect(self._prompt_str, timeout=timeout) + + wait_for_prompt(self._connection, self._prompt_str, timeout) + if self._prompt_str_includes_rc: rc = int(self._connection.match.group(1)) if rc != 0 and not failok: @@ -365,7 +393,7 @@ self._boot_linaro_image() timeout = self.config.boot_linaro_timeout TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN'] - self.proc.expect(TESTER_PS1_PATTERN, timeout=timeout) + wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) self.setup_proxy(TESTER_PS1_PATTERN) logging.info("System is in test image now") @@ -386,10 +414,10 @@ def boot_linaro_android_image(self): """Reboot the system to the test android image.""" self._boot_linaro_android_image() - match_id = self.proc.expect( - [self.target_device.deployment_data['TESTER_PS1'], pexpect.TIMEOUT], - timeout=900) - if match_id == 1: + TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN'] + try: + wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=900) + except pexpect.TIMEOUT: raise OperationFailed("booting into android test image failed") #TODO: set up proxy