OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
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 """Wrapper for tests that are run on builders.""" | 7 """Wrapper for tests that are run on builders.""" |
8 | 8 |
9 import fileinput | 9 import fileinput |
10 import optparse | 10 import optparse |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 fh.close() | 218 fh.close() |
219 | 219 |
220 version = zip_url.split('/')[-2] | 220 version = zip_url.split('/')[-2] |
221 if not _GreaterVersion(version, _NEW_STYLE_VERSION) == version: | 221 if not _GreaterVersion(version, _NEW_STYLE_VERSION) == version: |
222 # If the version isn't ready for new style, touch file to use old style. | 222 # If the version isn't ready for new style, touch file to use old style. |
223 old_style_touch_path = os.path.join(download_folder, '.use_e1000') | 223 old_style_touch_path = os.path.join(download_folder, '.use_e1000') |
224 fh = open(old_style_touch_path, 'w+') | 224 fh = open(old_style_touch_path, 'w+') |
225 fh.close() | 225 fh.close() |
226 | 226 |
227 | 227 |
228 def WipeDevServerCache(): | |
229 """Wipes the cache of the dev server.""" | |
230 RunCommand(['sudo', | |
231 './start_devserver', | |
232 '--clear_cache', | |
233 '--exit', | |
234 ], enter_chroot=True) | |
235 | |
236 | |
237 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base, | 228 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base, |
238 no_graphics, type, remote): | 229 no_graphics, type, remote, clean): |
239 """Runs the auto update test harness. | 230 """Runs the auto update test harness. |
240 | 231 |
241 The auto update test harness encapsulates testing the auto-update mechanism | 232 The auto update test harness encapsulates testing the auto-update mechanism |
242 for the latest image against the latest official image from the channel. This | 233 for the latest image against the latest official image from the channel. This |
243 also tests images with suite_Smoke (built-in as part of its verification | 234 also tests images with suite_Smoke (built-in as part of its verification |
244 process). | 235 process). |
245 | 236 |
246 Args: | 237 Args: |
247 board: the board for the latest image. | 238 board: the board for the latest image. |
248 channel: the channel to run the au test harness against. | 239 channel: the channel to run the au test harness against. |
249 latest_url_base: base url for getting latest links. | 240 latest_url_base: base url for getting latest links. |
250 zip_server_base: base url for zipped images. | 241 zip_server_base: base url for zipped images. |
251 no_graphics: boolean - If True, disable graphics during vm test. | 242 no_graphics: boolean - If True, disable graphics during vm test. |
252 type: which test harness to run. Possible values: real, vm. | 243 type: which test harness to run. Possible values: real, vm. |
253 remote: ip address for real test harness run. | 244 remote: ip address for real test harness run. |
| 245 clean: Clean the state of test harness before running. |
254 """ | 246 """ |
255 crosutils_root = os.path.join(os.path.dirname(__file__), '..') | 247 crosutils_root = os.path.join(os.path.dirname(__file__), '..') |
256 download_folder = os.path.abspath('latest_download') | 248 download_folder = os.path.abspath('latest_download') |
257 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) | 249 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) |
258 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) | 250 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) |
259 | 251 |
260 # Tests go here. | 252 # Tests go here. |
261 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], | 253 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], |
262 cwd=crosutils_root, redirect_stdout=True, | 254 cwd=crosutils_root, redirect_stdout=True, |
263 print_cmd=True).strip() | 255 print_cmd=True).strip() |
264 | 256 |
265 cmd = ['bin/cros_au_test_harness', | 257 cmd = ['bin/cros_au_test_harness', |
266 '--base_image=%s' % os.path.join(download_folder, | 258 '--base_image=%s' % os.path.join(download_folder, |
267 _IMAGE_TO_EXTRACT), | 259 _IMAGE_TO_EXTRACT), |
268 '--target_image=%s' % os.path.join(latest_image, | 260 '--target_image=%s' % os.path.join(latest_image, |
269 _IMAGE_TO_EXTRACT), | 261 _IMAGE_TO_EXTRACT), |
270 '--board=%s' % board, | 262 '--board=%s' % board, |
271 '--type=%s' % type, | 263 '--type=%s' % type, |
272 '--remote=%s' % remote, | 264 '--remote=%s' % remote, |
273 ] | 265 ] |
274 if no_graphics: cmd.append('--no_graphics') | 266 if no_graphics: cmd.append('--no_graphics') |
| 267 if clean: cmd.append('--clean') |
275 | 268 |
276 RunCommand(cmd, cwd=crosutils_root) | 269 RunCommand(cmd, cwd=crosutils_root) |
277 | 270 |
278 | 271 |
279 def main(): | 272 def main(): |
280 parser = optparse.OptionParser() | 273 parser = optparse.OptionParser() |
281 parser.add_option('-b', '--board', | 274 parser.add_option('-b', '--board', |
282 help='board for the image to compare against.') | 275 help='board for the image to compare against.') |
283 parser.add_option('-c', '--channel', | 276 parser.add_option('-c', '--channel', |
284 help='channel for the image to compare against.') | 277 help='channel for the image to compare against.') |
285 parser.add_option('--cache', default=False, action='store_true', | 278 parser.add_option('--cache', default=False, action='store_true', |
286 help='Cache payloads') | 279 help='Cache payloads') |
287 parser.add_option('-l', '--latestbase', | 280 parser.add_option('-l', '--latestbase', |
288 help='Base url for latest links.') | 281 help='Base url for latest links.') |
289 parser.add_option('-z', '--zipbase', | 282 parser.add_option('-z', '--zipbase', |
290 help='Base url for hosted images.') | 283 help='Base url for hosted images.') |
291 parser.add_option('--no_graphics', action='store_true', default=False, | 284 parser.add_option('--no_graphics', action='store_true', default=False, |
292 help='Disable graphics for the vm test.') | 285 help='Disable graphics for the vm test.') |
293 parser.add_option('--type', default='vm', | 286 parser.add_option('--type', default='vm', |
294 help='type of test to run: [vm, real]. Default: vm.') | 287 help='type of test to run: [vm, real]. Default: vm.') |
295 parser.add_option('--remote', default='0.0.0.0', | 288 parser.add_option('--remote', default='0.0.0.0', |
296 help='For real tests, ip address of the target machine.') | 289 help='For real tests, ip address of the target machine.') |
297 | 290 |
298 # Set the usage to include flags. | 291 # Set the usage to include flags. |
299 parser.set_usage(parser.format_help()) | 292 parser.set_usage(parser.format_help()) |
300 (options, args) = parser.parse_args() | 293 (options, args) = parser.parse_args() |
301 | 294 |
302 if args: | 295 if args: parser.error('Extra args found %s.' % args) |
303 parser.error('Extra args found %s.' % args) | 296 if not options.board: parser.error('Need board for image to compare against.') |
304 | 297 if not options.channel: parser.error('Need channel e.g. dev-channel.') |
305 if not options.board: | 298 if not options.zipbase: parser.error('Need zip url base to get images.') |
306 parser.error('Need board for image to compare against.') | |
307 | |
308 if not options.channel: | |
309 parser.error('Need channel for image to compare against.') | |
310 | |
311 if not options.zipbase: | |
312 parser.error('Need zip url base to get images.') | |
313 | |
314 if not options.cache: | |
315 Info('Wiping dev server cache.') | |
316 WipeDevServerCache() | |
317 | 299 |
318 RunAUTestHarness(options.board, options.channel, options.latestbase, | 300 RunAUTestHarness(options.board, options.channel, options.latestbase, |
319 options.zipbase, options.no_graphics, options.type, | 301 options.zipbase, options.no_graphics, options.type, |
320 options.remote) | 302 options.remote, not options.cache) |
321 | 303 |
322 | 304 |
323 if __name__ == '__main__': | 305 if __name__ == '__main__': |
324 main() | 306 main() |
325 | 307 |
OLD | NEW |