From patchwork Wed Sep 14 16:08:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Larson X-Patchwork-Id: 4075 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 ABBB823EF7 for ; Wed, 14 Sep 2011 16:13:26 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9D987A188F7 for ; Wed, 14 Sep 2011 16:13:26 +0000 (UTC) Received: by fxe23 with SMTP id 23so2532078fxe.11 for ; Wed, 14 Sep 2011 09:13:26 -0700 (PDT) Received: by 10.223.33.19 with SMTP id f19mr181025fad.122.1316016806464; Wed, 14 Sep 2011 09:13:26 -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.152.11.8 with SMTP id m8cs56731lab; Wed, 14 Sep 2011 09:13:26 -0700 (PDT) Received: by 10.216.133.74 with SMTP id p52mr1178464wei.93.1316016805589; Wed, 14 Sep 2011 09:13:25 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id n55si1267988wed.32.2011.09.14.09.13.25 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Sep 2011 09:13:25 -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 1R3s5U-0008Pe-F0 for ; Wed, 14 Sep 2011 16:13:24 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 897FBE174C for ; Wed, 14 Sep 2011 16:08: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: 109 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 109: Fix problem with return code detection in commands that specify a Message-Id: <20110914160813.11711.98541.launchpad@ackee.canonical.com> Date: Wed, 14 Sep 2011 16:08: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="13921"; Instance="initZopeless config overlay" X-Launchpad-Hash: 47264fe468e8800ab9747bd64bd30a833bcb069d Merge authors: Spring Zhang (qzhang) Related merge proposals: https://code.launchpad.net/~qzhang/lava-dispatcher/fix-lava-test-install/+merge/75352 proposed by: Spring Zhang (qzhang) review: Approve - Paul Larson (pwlars) review: Resubmit - Spring Zhang (qzhang) ------------------------------------------------------------ revno: 109 [merge] committer: Paul Larson branch nick: big-dispatcher-merge timestamp: Wed 2011-09-14 11:05:43 -0500 message: Fix problem with return code detection in commands that specify a response to expect. modified: lava_dispatcher/actions/lava-test.py lava_dispatcher/client.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/actions/lava-test.py' --- lava_dispatcher/actions/lava-test.py 2011-09-14 14:43:58 +0000 +++ lava_dispatcher/actions/lava-test.py 2011-09-14 16:05:43 +0000 @@ -71,7 +71,7 @@ try: client.run_shell_command( 'chroot /mnt/root lava-test help', - response="list-test", timeout=10) + response="list-test", timeout=60) except: tb = traceback.format_exc() client.sio.write(tb) === modified file 'lava_dispatcher/client.py' --- lava_dispatcher/client.py 2011-09-14 14:43:58 +0000 +++ lava_dispatcher/client.py 2011-09-14 16:05:43 +0000 @@ -103,7 +103,7 @@ self.in_master_shell() except: raise - self.proc.sendline('export PS1="rc=$(echo \$?) $PS1"') + self.proc.sendline('export PS1="$PS1 [rc=$(echo \$?)]: "') self.proc.expect(self.master_str) def boot_linaro_image(self): @@ -130,7 +130,7 @@ # Details: system PS1 is set in /etc/bash.bashrc and user PS1 is set in # /root/.bashrc, it is # "${debian_chroot:+($debian_chroot)}\u@\h:\w\$ " - self.proc.sendline('export PS1="rc=$(echo \$?) $PS1"') + self.proc.sendline('export PS1="$PS1 rc=$(echo \$?) "') self.proc.expect(self.tester_str) def enter_uboot(self): @@ -153,6 +153,16 @@ self.empty_pexpect_buffer() # return return-code if captured, else return None self.proc.sendline(cmd) + start_time = time.time() + if response: + self.proc.expect(response, timeout=timeout) + elapsed_time = int(time.time()-start_time) + # if reponse is master/tester string, make rc expect timeout to be + # 2 sec, else make it consume remained timeout + if response in [self.master_str, self.tester_str]: + timeout = 2 + else: + timeout = int(timeout-elapsed_time) #verify return value of last command, match one number at least #PS1 setting is in boot_linaro_image or boot_master_image pattern1 = "rc=(\d+\d?\d?)" @@ -162,8 +172,6 @@ rc = int(self.proc.match.groups()[0]) else: rc = None - if response: - self.proc.expect(response, timeout=2) return rc def run_cmd_master(self, cmd, timeout=-1):