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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 RunAUTestHarness(board, channel, latest_url_base, zip_server_base, | 228 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base, |
229 no_graphics, type, remote, clean): | 229 no_graphics, type, remote, clean, test_results_root): |
230 """Runs the auto update test harness. | 230 """Runs the auto update test harness. |
231 | 231 |
232 The auto update test harness encapsulates testing the auto-update mechanism | 232 The auto update test harness encapsulates testing the auto-update mechanism |
233 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 |
234 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 |
235 process). | 235 process). |
236 | 236 |
237 Args: | 237 Args: |
238 board: the board for the latest image. | 238 board: the board for the latest image. |
239 channel: the channel to run the au test harness against. | 239 channel: the channel to run the au test harness against. |
240 latest_url_base: base url for getting latest links. | 240 latest_url_base: base url for getting latest links. |
241 zip_server_base: base url for zipped images. | 241 zip_server_base: base url for zipped images. |
242 no_graphics: boolean - If True, disable graphics during vm test. | 242 no_graphics: boolean - If True, disable graphics during vm test. |
243 type: which test harness to run. Possible values: real, vm. | 243 type: which test harness to run. Possible values: real, vm. |
244 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. | 245 clean: Clean the state of test harness before running. |
| 246 test_results_root: Root directory to store au_test_harness results. |
246 """ | 247 """ |
247 crosutils_root = os.path.join(os.path.dirname(__file__), '..') | 248 crosutils_root = os.path.join(os.path.dirname(__file__), '..') |
248 download_folder = os.path.abspath('latest_download') | 249 download_folder = os.path.abspath('latest_download') |
249 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) | 250 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) |
250 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) | 251 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) |
251 | 252 |
252 # Tests go here. | 253 # Tests go here. |
253 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], | 254 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], |
254 cwd=crosutils_root, redirect_stdout=True, | 255 cwd=crosutils_root, redirect_stdout=True, |
255 print_cmd=True).strip() | 256 print_cmd=True).strip() |
256 | 257 |
257 update_engine_path = os.path.join(crosutils_root, '..', 'platform', | 258 update_engine_path = os.path.join(crosutils_root, '..', 'platform', |
258 'update_engine') | 259 'update_engine') |
259 | 260 |
260 cmd = ['bin/cros_au_test_harness', | 261 cmd = ['bin/cros_au_test_harness', |
261 '--base_image=%s' % os.path.join(download_folder, | 262 '--base_image=%s' % os.path.join(download_folder, |
262 _IMAGE_TO_EXTRACT), | 263 _IMAGE_TO_EXTRACT), |
263 '--target_image=%s' % os.path.join(latest_image, | 264 '--target_image=%s' % os.path.join(latest_image, |
264 _IMAGE_TO_EXTRACT), | 265 _IMAGE_TO_EXTRACT), |
265 '--board=%s' % board, | 266 '--board=%s' % board, |
266 '--type=%s' % type, | 267 '--type=%s' % type, |
267 '--remote=%s' % remote, | 268 '--remote=%s' % remote, |
268 '--private_key=%s' % os.path.join(update_engine_path, | 269 '--private_key=%s' % os.path.join(update_engine_path, |
269 'unittest_key.pem'), | 270 'unittest_key.pem'), |
270 '--public_key=%s' % os.path.join(update_engine_path, | 271 '--public_key=%s' % os.path.join(update_engine_path, |
271 'unittest_key.pub.pem'), | 272 'unittest_key.pub.pem'), |
272 ] | 273 ] |
| 274 if test_results_root: cmd.append('--test_results_root=%s' % test_results_root) |
273 if no_graphics: cmd.append('--no_graphics') | 275 if no_graphics: cmd.append('--no_graphics') |
274 if clean: cmd.append('--clean') | 276 if clean: cmd.append('--clean') |
275 | 277 |
276 RunCommand(cmd, cwd=crosutils_root) | 278 RunCommand(cmd, cwd=crosutils_root) |
277 | 279 |
278 | 280 |
279 def main(): | 281 def main(): |
280 parser = optparse.OptionParser() | 282 parser = optparse.OptionParser() |
281 parser.add_option('-b', '--board', | 283 parser.add_option('-b', '--board', |
282 help='board for the image to compare against.') | 284 help='board for the image to compare against.') |
283 parser.add_option('-c', '--channel', | 285 parser.add_option('-c', '--channel', |
284 help='channel for the image to compare against.') | 286 help='channel for the image to compare against.') |
285 parser.add_option('--cache', default=False, action='store_true', | 287 parser.add_option('--cache', default=False, action='store_true', |
286 help='Cache payloads') | 288 help='Cache payloads') |
287 parser.add_option('-l', '--latestbase', | 289 parser.add_option('-l', '--latestbase', |
288 help='Base url for latest links.') | 290 help='Base url for latest links.') |
289 parser.add_option('-z', '--zipbase', | 291 parser.add_option('-z', '--zipbase', |
290 help='Base url for hosted images.') | 292 help='Base url for hosted images.') |
291 parser.add_option('--no_graphics', action='store_true', default=False, | 293 parser.add_option('--no_graphics', action='store_true', default=False, |
292 help='Disable graphics for the vm test.') | 294 help='Disable graphics for the vm test.') |
| 295 parser.add_option('--test_results_root', default=None, |
| 296 help='Root directory to store test results. Should ' |
| 297 'be defined relative to chroot root.') |
293 parser.add_option('--type', default='vm', | 298 parser.add_option('--type', default='vm', |
294 help='type of test to run: [vm, real]. Default: vm.') | 299 help='type of test to run: [vm, real]. Default: vm.') |
295 parser.add_option('--remote', default='0.0.0.0', | 300 parser.add_option('--remote', default='0.0.0.0', |
296 help='For real tests, ip address of the target machine.') | 301 help='For real tests, ip address of the target machine.') |
297 | 302 |
298 # Set the usage to include flags. | 303 # Set the usage to include flags. |
299 parser.set_usage(parser.format_help()) | 304 parser.set_usage(parser.format_help()) |
300 (options, args) = parser.parse_args() | 305 (options, args) = parser.parse_args() |
301 | 306 |
302 if args: parser.error('Extra args found %s.' % args) | 307 if args: parser.error('Extra args found %s.' % args) |
303 if not options.board: parser.error('Need board for image to compare against.') | 308 if not options.board: parser.error('Need board for image to compare against.') |
304 if not options.channel: parser.error('Need channel e.g. dev-channel.') | 309 if not options.channel: parser.error('Need channel e.g. dev-channel.') |
305 if not options.zipbase: parser.error('Need zip url base to get images.') | 310 if not options.zipbase: parser.error('Need zip url base to get images.') |
306 | 311 |
307 RunAUTestHarness(options.board, options.channel, options.latestbase, | 312 RunAUTestHarness(options.board, options.channel, options.latestbase, |
308 options.zipbase, options.no_graphics, options.type, | 313 options.zipbase, options.no_graphics, options.type, |
309 options.remote, not options.cache) | 314 options.remote, not options.cache) |
310 | 315 |
311 | 316 |
312 if __name__ == '__main__': | 317 if __name__ == '__main__': |
313 main() | 318 main() |
314 | 319 |
OLD | NEW |