Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: client/site_tests/suite_Factory/control

Issue 2857012: Batched update of factory tests. (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: finished comment Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 import time 28 import time
29 29
30 30
31 _FACTORY_LOG_PATH = '/var/log/factory.log' 31 _FACTORY_LOG_PATH = '/var/log/factory.log'
32 _RESULT_FILE_PATH = '/var/run/factory_test_result' 32 _RESULT_FILE_PATH = '/var/run/factory_test_result'
33 33
34 _REBOOT_SEQ_ITERATIONS = 2 34 _REBOOT_SEQ_ITERATIONS = 2
35 35
36 36
37 def XXX_log(s): 37 def XXX_log(s):
38 print >> sys.stderr, '--- XXX : ' + s 38 print >> sys.stderr, 'FACTORY: ' + s
39 39
40 40
41 # Hack to work around autotest's obsession with GRUB. 41 # Hack to work around autotest's obsession with GRUB.
42 job.bootloader.set_default = lambda x: None 42 job.bootloader.set_default = lambda x: None
43 job.bootloader.boot_once = lambda x: None 43 job.bootloader.boot_once = lambda x: None
44 44
45 45
46 # This is the definition of the test_data class, which holds 46 # This is the definition of the test_data class, which holds
47 # factory-specific information on the tests to be run. Specifically, 47 # factory-specific information on the tests to be run. Specifically,
48 # the order of items in the list reflect the order they are to be run 48 # the order of items in the list reflect the order they are to be run
(...skipping 23 matching lines...) Expand all
72 72
73 73
74 test_list = [ 74 test_list = [
75 test_data( 75 test_data(
76 label_en='start', 76 label_en='start',
77 formal_name='factory_Dummy', 77 formal_name='factory_Dummy',
78 trigger='a', 78 trigger='a',
79 dargs={'quit_key':ord(' '), 79 dargs={'quit_key':ord(' '),
80 'msg':'Hit SPACE to start testing...\n按 "空白鍵" 開始測試...'}), 80 'msg':'Hit SPACE to start testing...\n按 "空白鍵" 開始測試...'}),
81 test_data( 81 test_data(
82 label_en='sync',
83 formal_name='factory_ScriptWrapper',
84 trigger='s',
85 dargs={'cmdline':'/usr/local/autotest/exscr'}),
86 test_data(
87 label_en='leds',
88 formal_name='factory_Dummy',
89 trigger='l',
90 dargs={'msg':'LEDs test, one day...'}),
91 test_data(
92 label_en='usb',
93 formal_name='factory_ExternalStorage',
94 trigger='u'),
95 test_data(
96 label_en='display',
97 formal_name='factory_Display',
98 trigger='m'),
99 test_data(
100 label_en='camera',
101 formal_name='factory_Dummy',
102 trigger='c',
103 dargs={'msg':'camera test, one day...'}),
104 test_data(
105 label_en='keyboard',
106 label_zw='鍵盤',
107 formal_name='factory_Keyboard',
108 trigger='k',
109 dargs={'layout':'en_us'}),
110 test_data(
111 label_en='touchpad',
112 label_zw='觸控板',
113 formal_name='factory_Synaptics',
114 trigger='t'),
115 test_data(
82 label_en='run-in', 116 label_en='run-in',
83 formal_name='step_runin', 117 formal_name='step_runin',
84 automated_seq=[ 118 automated_seq=[
85 test_data( 119 test_data(
86 label_en='component validation', 120 label_en='component validation',
87 formal_name='hardware_Components'), 121 formal_name='hardware_Components',
122 dargs={'approved_db':'qualified_components'}),
88 test_data( 123 test_data(
89 label_en='gpio switch check', 124 label_en='gpio switch check',
90 formal_name='hardware_GPIOSwitches'), 125 formal_name='hardware_GPIOSwitches'),
91 test_data( 126 test_data(
92 label_en='system stress', 127 label_en='system stress',
93 formal_name='hardware_SAT'), 128 formal_name='hardware_SAT'),
94 test_data( 129 test_data(
95 label_en='reboot (%s times)' % _REBOOT_SEQ_ITERATIONS, 130 label_en='reboot (%s times)' % _REBOOT_SEQ_ITERATIONS,
96 formal_name='factory_RebootStub')], 131 formal_name='factory_RebootStub')],
97 trigger='r'), 132 trigger='r'),
98 test_data( 133 test_data(
99 label_en='camera', 134 label_en='end',
100 formal_name='factory_Dummy', 135 formal_name='factory_Dummy',
101 trigger='c', 136 trigger='e',
102 dargs={'msg':'camera test, one day...'}), 137 dargs={'msg':'end of testing...\n(chinese)...'}),
103 test_data(
104 label_en='keyboard',
105 label_zw='鍵盤',
106 formal_name='factory_Keyboard',
107 trigger='k',
108 dargs={'layout':'en_us'}),
109 test_data(
110 label_en='trackpad',
111 label_zw='觸控板',
112 formal_name='hardware_Touchpad',
113 trigger='t'),
114 ] 138 ]
115 139
116 for test in test_list: 140 for test in test_list:
117 test.tag_prefix = test.trigger 141 test.tag_prefix = test.trigger
118 for subtest in test.automated_seq: 142 for subtest in test.automated_seq:
119 subtest.tag_prefix = test.formal_name 143 subtest.tag_prefix = test.formal_name
120 144
121 def test_map_index(formal_name, tag_prefix): 145 def test_map_index(formal_name, tag_prefix):
122 return formal_name + '.' + tag_prefix 146 return formal_name + '.' + tag_prefix
123 147
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 self.send(('switch_to', trigger)) 180 self.send(('switch_to', trigger))
157 181
158 def recv(self): 182 def recv(self):
159 return eval(self._proc.stdout.readline().rstrip()) 183 return eval(self._proc.stdout.readline().rstrip())
160 184
161 def recv_target_test_update(self): 185 def recv_target_test_update(self):
162 update = self.recv() 186 update = self.recv()
163 XXX_log('control recv target test %s' % repr(update)) 187 XXX_log('control recv target test %s' % repr(update))
164 formal_name, tag_prefix, count = update 188 formal_name, tag_prefix, count = update
165 test = test_map.get(test_map_index(formal_name, tag_prefix), None) 189 test = test_map.get(test_map_index(formal_name, tag_prefix), None)
166 if test is not None: 190 return (test, count)
167 test.count = count
168 return test
169 191
170 192
171 def step_reboot_seq(i, tag): 193 def step_reboot_seq(i, tag):
172 if i < _REBOOT_SEQ_ITERATIONS: 194 if i < _REBOOT_SEQ_ITERATIONS:
173 job.next_step([step_reboot_seq, i + 1, tag]) 195 job.next_step_prepend([step_reboot_seq, i + 1, tag])
174 XXX_log('rebooting (iteration %d)' % i) 196 XXX_log('rebooting (iteration %d)' % i)
175 time.sleep(5) 197 time.sleep(5)
176 job.reboot() 198 job.reboot()
177 else: 199 else:
178 job.run_test('factory_RebootStub', tag=tag) 200 job.run_test('factory_RebootStub', tag=tag)
179 step_init() 201 step_init()
180 202
181 203
182 def step_runin(ui, tag): 204 def step_runin(ui, tag):
183 job.run_test('hardware_Components', 205 job.run_test('hardware_Components',
184 approved_db='qualified_components', 206 approved_db='qualified_components',
185 tag=tag) 207 tag=tag)
186 ui.send()
187 job.run_test('hardware_GPIOSwitches', tag=tag) 208 job.run_test('hardware_GPIOSwitches', tag=tag)
188 ui.send()
189 job.drop_caches_between_iterations = True 209 job.drop_caches_between_iterations = True
190 job.run_test('hardware_SAT', tag=tag) 210 job.run_test('hardware_SAT', tag=tag)
191 job.drop_caches_between_iterations = False 211 job.drop_caches_between_iterations = False
192 ui.send()
193 step_reboot_seq(0, tag) 212 step_reboot_seq(0, tag)
194 213
195 214
196 def step_init(): 215 def step_init():
197 216
198 '''Launch the factory UI, which will then make decisions on which 217 '''Launch the factory UI, which will then make decisions on which
199 tests to run in which order. This is to support user driven 218 tests to run in which order. This is to support user driven
200 out-of-order test execution based on keyboard shortcuts. 219 out-of-order test execution based on keyboard shortcuts.
201 220
202 For each test, a trigger (possibly None) is communicated to the 221 For each test, a trigger (possibly None) is communicated to the
203 UI, which then replies with the test name and a count number that 222 UI, which then replies with the test name and a count number that
204 becomes the autotest tag to allow repeated test execution while 223 becomes the autotest tag to allow repeated test execution while
205 preserving logs. 224 preserving logs.
206 225
207 When the tests themselves run, they are expected to look for 226 When the tests themselves run, they are expected to look for
208 (using the factory_test library) keyboard events that match test 227 (using the factory_test library) keyboard events that match test
209 switching triggers. When a trigger happens, it should be written 228 switching triggers. When a trigger happens, it should be written
210 to the _RESULT_FILE_PATH, which will be read after the test 229 to the _RESULT_FILE_PATH, which will be read after the test
211 completed and the result comminicated onwards to the UI.''' 230 completed and the result comminicated onwards to the UI.'''
212 231
232 job.next_step([step_init])
233
213 status_file_path = job.autodir + '/results/default/status' 234 status_file_path = job.autodir + '/results/default/status'
214 factory_ui_path = job.autodir + '/factory_ui' 235 factory_ui_path = job.autodir + '/deps/factory/ui'
215 236
216 ui = factory_ui(factory_ui_path) 237 ui = factory_ui(factory_ui_path)
217 238
218 ui.send(test_data_class_def) 239 ui.send(test_data_class_def)
219 ui.send(test_list) 240 ui.send(test_list)
220 ui.send(status_file_path) 241 ui.send(status_file_path)
221 ui.send(_FACTORY_LOG_PATH) 242 ui.send(_FACTORY_LOG_PATH)
222 243
223 test_widget_size = ui.recv() 244 test_widget_size = ui.recv()
224 XXX_log('received test_widget_size = %s' % repr(test_widget_size)) 245 XXX_log('received test_widget_size = %s' % repr(test_widget_size))
225 246
226 ui.send_cmd_next_test() 247 ui.send_cmd_next_test()
227 test = ui.recv_target_test_update() 248 test, test_count = ui.recv_target_test_update()
228 249
229 while test is not None: 250 while test is not None:
230 if test.automated_seq: 251 if test.automated_seq:
231 tag = '%s_%s' % (test.formal_name, test.count) 252 tag = '%s_%s' % (test.formal_name, test_count)
232 exec('%s(ui, "%s")' % (test.formal_name, tag)) 253 exec('%s(ui, "%s")' % (test.formal_name, tag))
233 result = None 254 result = None
234 else: 255 else:
235 dargs = test.dargs 256 dargs = test.dargs
236 dargs.update({ 257 dargs.update({
237 'tag': '%s_%s' % (test.tag_prefix, test.count), 258 'tag': '%s_%s' % (test.tag_prefix, test_count),
259 'test_tag_prefix': test.tag_prefix,
260 'test_count': test_count,
238 'test_widget_size': test_widget_size, 261 'test_widget_size': test_widget_size,
239 'trigger_set': trigger_set, 262 'trigger_set': trigger_set,
240 'result_file_path': _RESULT_FILE_PATH}) 263 'result_file_path': _RESULT_FILE_PATH})
241 with open(_RESULT_FILE_PATH, 'w') as file: 264 with open(_RESULT_FILE_PATH, 'w') as file:
242 file.write('None\n') 265 file.write('None\n')
243 job.run_test(test.formal_name, **dargs) 266 job.run_test(test.formal_name, **dargs)
244 with open(_RESULT_FILE_PATH, 'r') as file: 267 with open(_RESULT_FILE_PATH, 'r') as file:
245 result = eval(file.readline()) 268 result = eval(file.readline())
246 269
247 if result is not None: 270 if result is not None:
248 ui.send_cmd_switch_to(result) 271 ui.send_cmd_switch_to(result)
249 else: 272 else:
250 ui.send_cmd_next_test() 273 ui.send_cmd_next_test()
251 274
252 test = ui.recv_target_test_update() 275 test, test_count = ui.recv_target_test_update()
253 276
254 XXX_log('factory testing completed') 277 XXX_log('factory testing completed')
OLDNEW
« no previous file with comments | « client/site_tests/hardware_Touchpad/src/touchpad.png ('k') | client/site_tests/suite_Factory/control.config » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698