diff mbox

[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
State Accepted
Headers show

Commit Message

Spring Zhang Sept. 13, 2011, 3:05 a.m. UTC
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 <spring.zhang@linaro.org>
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
diff mbox

Patch

=== 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