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" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 | 66 |
67 # Hack to work around autotest's obsession with GRUB. | 67 # Hack to work around autotest's obsession with GRUB. |
68 job.bootloader.set_default = lambda x: None | 68 job.bootloader.set_default = lambda x: None |
69 job.bootloader.boot_once = lambda x: None | 69 job.bootloader.boot_once = lambda x: None |
70 | 70 |
71 | 71 |
72 def start_ui(): | 72 def start_ui(): |
73 ui_proc_args = [FACTORY_UI_PATH, TEST_LIST_PATH, | 73 ui_proc_args = [FACTORY_UI_PATH, TEST_LIST_PATH, |
74 STATUS_FILE_PATH, str(os.getpid())] | 74 STATUS_FILE_PATH, str(os.getpid())] |
75 factory.log('starting ui -- %s' % repr(ui_proc_args)) | 75 factory.log('starting ui %s' % repr(ui_proc_args)) |
76 sp = subprocess.Popen(ui_proc_args, stdout=subprocess.PIPE) | 76 sp = subprocess.Popen(ui_proc_args, stdout=subprocess.PIPE) |
77 factory.log('waiting for ui to come up...') | 77 factory.log('waiting for ui to come up...') |
78 factory.log('got message from UI : %s' % repr(sp.stdout.readline().strip())) | 78 factory.log('got message from ui : %s' % repr(sp.stdout.readline().strip())) |
79 | 79 |
80 | 80 |
81 def step_reboot_seq(tag_prefix, total_iterations, i=0): | 81 def step_reboot_seq(next_subtest_info, total_iterations, i=0): |
82 if i < total_iterations: | 82 if i < total_iterations: |
83 job.next_step_prepend([step_reboot_seq, tag_prefix, | 83 job.next_step_prepend([step_reboot_seq, next_subtest_info, |
84 total_iterations, i + 1]) | 84 total_iterations, i + 1]) |
85 factory.log('rebooting (iteration %d of %d)' % (i, total_iterations)) | 85 factory.log('rebooting (iteration %d of %d)' % (i, total_iterations)) |
86 job.reboot() | 86 job.reboot() |
87 else: | 87 else: |
88 step_init(intentional_reboot_subtest_tag_prefix=tag_prefix) | 88 step_init(next_subtest_info) |
89 | 89 |
90 | 90 |
91 def step_init(intentional_reboot_subtest_tag_prefix=None): | 91 def step_init(next_subtest_info=None): |
92 job.next_step([step_init]) | 92 job.next_step([step_init]) |
93 | 93 |
94 start_ui() | 94 start_ui() |
95 | 95 |
| 96 test_db = factory.TestDatabase(TEST_LIST) |
96 status_map = factory.StatusMap(TEST_LIST, STATUS_FILE_PATH) | 97 status_map = factory.StatusMap(TEST_LIST, STATUS_FILE_PATH) |
97 control_state = factory.ControlState( | 98 control_state = factory.ControlState( |
98 job, TEST_LIST, status_map, STATUS_FILE_PATH, | 99 job, TEST_LIST, test_db, status_map, STATUS_FILE_PATH, |
99 parallel.fork_nuke_subprocess) | 100 parallel.fork_nuke_subprocess) |
100 | 101 |
101 if intentional_reboot_subtest_tag_prefix: | 102 def run_automated_sequence(test, count, start_index=0): |
102 reboot_subtest = status_map.test_db.get_subtest_by_tag_prefix( | 103 for subtest in test.subtest_list[start_index:]: |
103 intentional_reboot_subtest_tag_prefix) | 104 if isinstance(subtest, factory.AutomatedRebootSubTest): |
104 control_state.run_test(reboot_subtest) | 105 next_subtest_info = (test_db.get_tag_prefix(subtest), count) |
| 106 step_reboot_seq(next_subtest_info, subtest.iterations) |
| 107 else: |
| 108 shortcut_target = control_state.run_test(subtest, count) |
| 109 status_map.read_new_data() |
| 110 if shortcut_target: |
| 111 return shortcut_target |
| 112 if status_map.lookup_status(test) == factory.FAILED: |
| 113 return None |
| 114 |
| 115 if next_subtest_info: |
| 116 tag_prefix, count = next_subtest_info |
| 117 reboot_subtest = test_db.get_subtest_by_tag_prefix(tag_prefix) |
| 118 control_state.run_test(reboot_subtest, count) |
105 status_map.read_new_data() | 119 status_map.read_new_data() |
| 120 automated_seq = test_db.get_subtest_parent(reboot_subtest) |
| 121 rst_index = automated_seq.subtest_list.index(reboot_subtest) |
| 122 run_automated_sequence(automated_seq, count, start_index=rst_index + 1) |
106 | 123 |
107 test = status_map.next_untested() | 124 test = status_map.next_untested() |
108 while test is not None: | 125 while test is not None: |
109 factory.log('next test = %s' % | 126 unique_id_str = test_db.get_unique_id_str(test) |
110 status_map.test_db.get_unique_details(test)) | 127 count = status_map.lookup_count(test) + 1 |
| 128 factory.log('control running test %s/%s' % (unique_id_str, count)) |
111 if isinstance(test, factory.AutomatedSequence): | 129 if isinstance(test, factory.AutomatedSequence): |
112 for subtest in test.subtest_list: | 130 shortcut_target = run_automated_sequence(test, count) |
113 if isinstance(subtest, factory.AutomatedRebootSubTest): | |
114 tag_prefix = status_map.test_db.get_tag_prefix(subtest) | |
115 step_reboot_seq(tag_prefix, subtest.iterations) | |
116 else: | |
117 control_state.run_test(subtest) | |
118 if control_state.activated_kbd_shortcut_test: | |
119 break | |
120 else: | 131 else: |
121 control_state.run_test(test) | 132 shortcut_target = control_state.run_test(test, count) |
122 status_map.read_new_data() | 133 status_map.read_new_data() |
123 test = (control_state.activated_kbd_shortcut_test or | 134 test = shortcut_target or status_map.next_untested() |
124 status_map.next_untested()) | |
OLD | NEW |