From patchwork Tue Sep 13 03:05:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Spring Zhang X-Patchwork-Id: 4036 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 4BE5723EFB for ; Tue, 13 Sep 2011 03:05:15 +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 366B6A181DF for ; Tue, 13 Sep 2011 03:05:15 +0000 (UTC) Received: by fxe23 with SMTP id 23so190359fxe.11 for ; Mon, 12 Sep 2011 20:05:15 -0700 (PDT) Received: by 10.223.63.8 with SMTP id z8mr1001297fah.84.1315883114847; Mon, 12 Sep 2011 20:05:14 -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 m8cs22000lab; Mon, 12 Sep 2011 20:05:14 -0700 (PDT) Received: by 10.227.6.215 with SMTP id a23mr396416wba.44.1315883113709; Mon, 12 Sep 2011 20:05:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id fk9si246490wbb.116.2011.09.12.20.05.13 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Sep 2011 20:05:13 -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 1R3JJA-0002SP-V0 for ; Tue, 13 Sep 2011 03:05:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id DFE49E0615 for ; Tue, 13 Sep 2011 03:05:12 +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: 107 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 107: merge branch to fix bug 813919 which the lava-test-run always pass Message-Id: <20110913030512.7182.56693.launchpad@ackee.canonical.com> Date: Tue, 13 Sep 2011 03:05:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13910"; Instance="initZopeless config overlay" X-Launchpad-Hash: 3ab60f16ddbc9428c02dfe8fe3396f743980e9b0 Merge authors: Spring Zhang (qzhang) Related merge proposals: https://code.launchpad.net/~qzhang/lava-dispatcher/fix-813919/+merge/72552 proposed by: Spring Zhang (qzhang) review: Resubmit - Spring Zhang (qzhang) ------------------------------------------------------------ revno: 107 [merge] committer: Spring Zhang branch nick: fix-813919 timestamp: Tue 2011-09-13 11:03:18 +0800 message: merge branch to fix bug 813919 which the lava-test-run always pass 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-08 04:28:39 +0000 +++ lava_dispatcher/actions/lava-test.py 2011-09-10 03:24:21 +0000 @@ -87,11 +87,13 @@ client.run_cmd_tester('mkdir -p %s' % self.context.lava_result_dir) client.export_display() bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S") - client.run_cmd_tester( - 'lava-test run %s -o %s/%s.bundle' % ( - test_name, self.context.lava_result_dir, bundle_name), - timeout=timeout) - + cmd = ('lava-test run %s -o %s/%s.bundle' % ( + test_name, self.context.lava_result_dir, bundle_name)) + rc = client.run_cmd_tester(cmd, timeout=timeout) + if rc is None: + raise OperationFailed("test case getting return value failed") + elif rc != 0: + raise OperationFailed("test case failed with return value: %s" % rc) class cmd_lava_test_install(BaseAction): """ === modified file 'lava_dispatcher/client.py' --- lava_dispatcher/client.py 2011-09-10 03:02:04 +0000 +++ lava_dispatcher/client.py 2011-09-10 03:24:21 +0000 @@ -103,6 +103,8 @@ self.in_master_shell() except: raise + self.proc.sendline('export PS1="rc=$(echo \$?) $PS1"') + self.proc.expect(self.master_str) def boot_linaro_image(self): """ Reboot the system to the test image @@ -124,6 +126,12 @@ self.proc.expect("#", timeout=300) self.proc.sendline(boot_cmds[line]) self.in_test_shell() + # set PS1 to include return value of last command + # 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.expect(self.tester_str) def enter_uboot(self): self.proc.expect("Hit any key to stop autoboot") @@ -142,15 +150,26 @@ self.proc.sendline("hardreset") def run_shell_command(self, cmd, response=None, timeout=-1): + # return return-code if captured, else return None self.proc.sendline(cmd) + #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?)" + id = self.proc.expect([pattern1, pexpect.EOF, pexpect.TIMEOUT], + timeout=timeout) + if id == 0: + rc = int(self.proc.match.groups()[0]) + else: + rc = None if response: - self.proc.expect(response, timeout=timeout) + self.proc.expect(response, timeout=2) + return rc def run_cmd_master(self, cmd, timeout=-1): - self.run_shell_command(cmd, self.master_str, timeout) + return self.run_shell_command(cmd, self.master_str, timeout) def run_cmd_tester(self, cmd, timeout=-1): - self.run_shell_command(cmd, self.tester_str, timeout) + return self.run_shell_command(cmd, self.tester_str, timeout) def check_network_up(self): lava_server_ip = self.context.lava_server_ip