OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # | 2 # |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 AUTHOR = "Chrome OS Team" | 7 AUTHOR = "Chrome OS Team" |
8 NAME = "Factory" | 8 NAME = "Factory" |
9 TIME = "LONG" | 9 TIME = "LONG" |
10 TEST_CATEGORY = "Functional" | 10 TEST_CATEGORY = "Functional" |
11 TEST_CLASS = "suite" | 11 TEST_CLASS = "suite" |
12 TEST_TYPE = "client" | 12 TEST_TYPE = "client" |
13 | 13 |
14 DOC = """ | 14 DOC = """ |
15 This suite executed all of the factory tests, and incorporates an | 15 This suite executed all of the factory tests, and incorporates an |
16 X-windows GTK-based UI to highlight testing results and to allow | 16 X-windows GTK-based UI to highlight testing results and to allow |
17 factory operators to switch between tests, and to re-run tests, all | 17 factory operators to switch between tests, and to re-run tests, all |
18 on-demand via keyboard shortcuts. | 18 on-demand via keyboard shortcuts. |
19 | 19 |
20 The UI is implemented as a seperate process (see _FACTORY_UI_PATH), | 20 The UI is implemented as a seperate process (see _FACTORY_UI_PATH), |
21 which means that interprocess communication is needed between this | 21 which means that interprocess communication is needed between this |
22 control, the UI, and the tests (which are forked children of this | 22 control, the UI, and the tests (which are forked children of this |
23 control process). """ | 23 control process). """ |
24 | 24 |
25 | 25 |
26 import imp | 26 import imp |
27 import os | 27 import os |
28 import pprint | 28 import pprint |
| 29 import signal |
| 30 import traceback |
29 | 31 |
30 imp.load_source('common', job.autodir + '/bin/common.py') | 32 imp.load_source('common', job.autodir + '/bin/common.py') |
31 | 33 |
32 from autotest_lib.client.bin import factory | 34 from autotest_lib.client.bin import factory |
33 from autotest_lib.client.bin import parallel | 35 from autotest_lib.client.bin import parallel |
34 | 36 |
35 | 37 |
36 FACTORY_UI_PATH = job.autodir + '/bin/factory_ui' | 38 FACTORY_UI_PATH = job.autodir + '/bin/factory_ui' |
37 FACTORY_STATE_SERVER_PATH = job.autodir + '/bin/factory_state.py' | 39 FACTORY_STATE_SERVER_PATH = job.autodir + '/bin/factory_state.py' |
38 STATUS_FILE_PATH = job.autodir + '/results/default/status' | 40 STATUS_FILE_PATH = job.autodir + '/results/default/status' |
39 TEST_LIST_PATH = job.autodir + '/site_tests/suite_Factory/test_list' | 41 TEST_LIST_PATH = job.autodir + '/site_tests/suite_Factory/test_list' |
40 | 42 |
41 | 43 |
42 # Hack to grab the pid for forked tests. | 44 # Hack to grab the pid for forked tests. |
43 | 45 |
44 from autotest_lib.client.bin.parallel import fork_waitfor as orig_fork_waitfor | 46 from autotest_lib.client.bin.parallel import fork_waitfor as orig_fork_waitfor |
45 | 47 |
46 def new_fork_waitfor(tmp, pid): | 48 def factory_fork_waitfor(tmp, pid): |
47 factory.set_shared_data('active_test_data', (tmp, pid)) | 49 factory.set_shared_data('active_test_data', (tmp, pid)) |
48 try: | 50 (pid, status) = os.waitpid(pid, 0) |
49 orig_fork_waitfor(tmp, pid) | 51 parallel._check_for_subprocess_exception(tmp, pid) |
50 except os.error, e: | 52 if status == signal.SIGTERM: |
51 raise error.TestError('Test Interrupted (maybe keyboard shortcut)') | 53 raise error.TestError('Test TERMINATED (return code = %s),\n' |
| 54 'Maybe caused by hitting keyboard shotcut.' % |
| 55 status) |
| 56 elif status: |
| 57 raise error.TestError("Test FAILED with return code: %d" % (status)) |
52 | 58 |
53 parallel.fork_waitfor = new_fork_waitfor | 59 parallel.fork_waitfor = factory_fork_waitfor |
54 | 60 |
55 | 61 |
56 # These definitions are expose these classes directly into this | 62 # These definitions are expose these classes directly into this |
57 # namespace, so that the following exec'ed file can have cleaner | 63 # namespace, so that the following exec'ed file can have cleaner |
58 # syntax. These are done in this fashion, as opposed to "from factory | 64 # syntax. These are done in this fashion, as opposed to "from factory |
59 # import <class>" to work-around Python namespace wackiness -- the | 65 # import <class>" to work-around Python namespace wackiness -- the |
60 # from syntax does not work, creating new classes. | 66 # from syntax does not work, creating new classes. |
61 OperatorTest = factory.OperatorTest | 67 OperatorTest = factory.OperatorTest |
62 InformationScreen = factory.InformationScreen | 68 InformationScreen = factory.InformationScreen |
63 AutomatedSequence = factory.AutomatedSequence | 69 AutomatedSequence = factory.AutomatedSequence |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 144 |
139 def notify(self, test, status): | 145 def notify(self, test, status): |
140 self.notify_fd.write(' ') | 146 self.notify_fd.write(' ') |
141 self.notify_fd.flush() | 147 self.notify_fd.flush() |
142 try: | 148 try: |
143 state_server_process = start_state_server() | 149 state_server_process = start_state_server() |
144 ui_process = start_ui() | 150 ui_process = start_ui() |
145 ui_notify_fd = ui_process.stdin | 151 ui_notify_fd = ui_process.stdin |
146 ui_notify_obj = FactoryUINotifyObject(ui_notify_fd) | 152 ui_notify_obj = FactoryUINotifyObject(ui_notify_fd) |
147 main_loop(next_subtest_info, ui_notify_obj.notify) | 153 main_loop(next_subtest_info, ui_notify_obj.notify) |
| 154 except: |
| 155 factory.log('suite_Factory failed with exception: ' + |
| 156 traceback.format_exc()) |
| 157 # To fix a broken status tree, force a step_init here. |
| 158 job.next_step([step_init]) |
148 finally: | 159 finally: |
149 stop_process(ui_process, 'ui') | 160 stop_process(ui_process, 'ui') |
150 stop_process(state_server_process, 'state server') | 161 stop_process(state_server_process, 'state server') |
151 | 162 |
152 def main_loop(next_subtest_info, notify_callback): | 163 def main_loop(next_subtest_info, notify_callback): |
153 test_db = factory.TestDatabase(TEST_LIST) | 164 test_db = factory.TestDatabase(TEST_LIST) |
154 status_map = factory.StatusMap(TEST_LIST, STATUS_FILE_PATH, | 165 status_map = factory.StatusMap(TEST_LIST, STATUS_FILE_PATH, |
155 status_change_callback=notify_callback) | 166 status_change_callback=notify_callback) |
156 | 167 |
157 # initialize factory test states | 168 # initialize factory test states |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 213 |
203 test = find_next_test_to_run(status_map, test_db) | 214 test = find_next_test_to_run(status_map, test_db) |
204 while test is not None: | 215 while test is not None: |
205 unique_id_str = test_db.get_unique_id_str(test) | 216 unique_id_str = test_db.get_unique_id_str(test) |
206 factory.log('control running test %s' % unique_id_str) | 217 factory.log('control running test %s' % unique_id_str) |
207 if isinstance(test, factory.AutomatedSequence): | 218 if isinstance(test, factory.AutomatedSequence): |
208 shortcut_target = run_automated_sequence(test) | 219 shortcut_target = run_automated_sequence(test) |
209 else: | 220 else: |
210 shortcut_target = control_state.run_test(test) | 221 shortcut_target = control_state.run_test(test) |
211 test = shortcut_target or find_next_test_to_run(status_map, test_db) | 222 test = shortcut_target or find_next_test_to_run(status_map, test_db) |
OLD | NEW |