OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging, os | 5 import logging, os |
6 | 6 |
7 from autotest_lib.client.bin import site_login, site_ui_test | 7 from autotest_lib.client.bin import site_login, site_ui_test |
8 from autotest_lib.client.common_lib import error, site_ui, utils | 8 from autotest_lib.client.common_lib import error, site_ui, utils |
9 | 9 |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 dialog = site_ui.Dialog(question=TEMPLATE.format(header, tests), | 54 dialog = site_ui.Dialog(question=TEMPLATE.format(header, tests), |
55 choices=[]) | 55 choices=[]) |
56 result = dialog.get_result() | 56 result = dialog.get_result() |
57 | 57 |
58 header = html_button('Restart') | 58 header = html_button('Restart') |
59 | 59 |
60 # Run testcases from tests array. | 60 # Run testcases from tests array. |
61 for test in tests: | 61 for test in tests: |
62 cmd = test['cmd'] | 62 cmd = test['cmd'] |
63 logging.info("command launched: %s" % cmd) | 63 logging.info("command launched: %s" % cmd) |
64 utils.system(site_ui.xcommand(cmd)) | 64 ret = utils.system(site_ui.xcommand(cmd), ignore_status=True) |
65 | 65 |
66 test['result'] = html_button('Pass') + html_button('Fail') | 66 if ret == 0: |
67 dialog = site_ui.Dialog(question=TEMPLATE.format(header, tests), | 67 test['result'] = html_button('Pass') + html_button('Fail') |
68 choices=[]) | 68 dialog = site_ui.Dialog( |
69 # Store user's response if the testcase passed or failed. | 69 question=TEMPLATE.format(header, tests), choices=[]) |
70 result = dialog.get_result() | 70 # Store user's response if the testcase passed or failed. |
71 test['result'] = result if result else 'Timeout' | 71 result = dialog.get_result() |
| 72 test['result'] = result if result else 'Timeout' |
| 73 else: |
| 74 # If test return nonzero status, mark it as failed. |
| 75 test['result'] = 'Fail' |
72 | 76 |
73 # Test passed if all testcases passed. | 77 # Test passed if all testcases passed. |
74 passed = all(test['result'] == 'Pass' for test in tests) | 78 passed = all(test['result'] == 'Pass' for test in tests) |
75 header = ("Test %s.<br/>" % ("passed" if passed else "failed") + | 79 header = ("Test %s.<br/>" % ("passed" if passed else "failed") + |
76 html_button('Done') + html_button('Restart')) | 80 html_button('Done') + html_button('Restart')) |
77 # Show the summary screen. | 81 # Show the summary screen. |
78 dialog = site_ui.Dialog(question=TEMPLATE.format(header, tests), | 82 dialog = site_ui.Dialog(question=TEMPLATE.format(header, tests), |
79 choices=[]) | 83 choices=[]) |
80 result = dialog.get_result() | 84 result = dialog.get_result() |
81 | 85 |
82 # If user chose 'Restart', run the whole thing again. | 86 # If user chose 'Restart', run the whole thing again. |
83 if result != 'Restart': | 87 if result != 'Restart': |
84 break | 88 break |
85 | 89 |
86 if not passed: | 90 if not passed: |
87 raise error.TestFail('Failed: ' + | 91 raise error.TestFail('Failed: ' + |
88 ', '.join(test['desc'] for test in tests | 92 ', '.join(test['desc'] for test in tests |
89 if test['result'] != 'Pass')) | 93 if test['result'] != 'Pass')) |
OLD | NEW |