=== modified file 'lava_dispatcher/actions/lava-test.py'
@@ -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'
@@ -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