Chromium Code Reviews| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 zip_dir = os.path.join(zip_base, latest_version) | 137 zip_dir = os.path.join(zip_base, latest_version) |
| 138 zip_name = GetLatestLinkFromPage(zip_dir, | 138 zip_name = GetLatestLinkFromPage(zip_dir, |
| 139 'ChromeOS-\d+\.\d+\.\d+\.\d+-.*\.zip') | 139 'ChromeOS-\d+\.\d+\.\d+\.\d+-.*\.zip') |
| 140 return os.path.join(zip_dir, zip_name) | 140 return os.path.join(zip_dir, zip_name) |
| 141 | 141 |
| 142 | 142 |
| 143 def GetLatestZipUrl(board, channel, zip_server_base): | 143 def GetLatestZipUrl(board, channel, zip_server_base): |
| 144 """Returns the url of the latest image zip for the given arguments. | 144 """Returns the url of the latest image zip for the given arguments. |
| 145 | 145 |
| 146 If the latest does not exist, tries to find the rc equivalent. | 146 If the latest does not exist, tries to find the rc equivalent. If neither |
| 147 exist, returns None. | |
| 147 | 148 |
| 148 Args: | 149 Args: |
| 149 board: board for the image zip. | 150 board: board for the image zip. |
| 150 channel: channel for the image zip. | 151 channel: channel for the image zip. |
| 151 zip_server_base: base url for zipped images. | 152 zip_server_base: base url for zipped images. |
| 152 """ | 153 """ |
| 153 try: | 154 try: |
| 154 return GetNewestLinkFromZipBase(board, channel, zip_server_base) | 155 return GetNewestLinkFromZipBase(board, channel, zip_server_base) |
| 155 except: | 156 except: |
| 156 cros_lib.Warning('Failed to get url from standard zip base. Trying rc.') | 157 cros_lib.Warning('Failed to get url from zip base.') |
| 158 try: | |
| 157 return GetNewestLinkFromZipBase(board + '-rc', channel, zip_server_base) | 159 return GetNewestLinkFromZipBase(board + '-rc', channel, zip_server_base) |
| 160 except: | |
|
dgarrett
2011/04/05 23:36:38
I know you're just following pattern, but these re
| |
| 161 cros_lib.Warning('Failed to get url from zip base for release candidates.') | |
| 162 return None | |
| 158 | 163 |
| 159 | 164 |
| 160 def GrabZipAndExtractImage(zip_url, download_folder, image_name) : | 165 def GrabZipAndExtractImage(zip_url, download_folder, image_name) : |
| 161 """Downloads the zip and extracts the given image. | 166 """Downloads the zip and extracts the given image. |
| 162 | 167 |
| 163 Doesn't re-download if matching version found already in download folder. | 168 Doesn't re-download if matching version found already in download folder. |
| 164 Args: | 169 Args: |
| 165 zip_url - url for the image. | 170 zip_url - url for the image. |
| 166 download_folder - download folder to store zip file and extracted images. | 171 download_folder - download folder to store zip file and extracted images. |
| 167 image_name - name of the image to extract from the zip file. | 172 image_name - name of the image to extract from the zip file. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 board: the board for the latest image. | 240 board: the board for the latest image. |
| 236 channel: the channel to run the au test harness against. | 241 channel: the channel to run the au test harness against. |
| 237 zip_server_base: base url for zipped images. | 242 zip_server_base: base url for zipped images. |
| 238 no_graphics: boolean - If True, disable graphics during vm test. | 243 no_graphics: boolean - If True, disable graphics during vm test. |
| 239 type: which test harness to run. Possible values: real, vm. | 244 type: which test harness to run. Possible values: real, vm. |
| 240 remote: ip address for real test harness run. | 245 remote: ip address for real test harness run. |
| 241 clean: Clean the state of test harness before running. | 246 clean: Clean the state of test harness before running. |
| 242 test_results_root: Root directory to store au_test_harness results. | 247 test_results_root: Root directory to store au_test_harness results. |
| 243 """ | 248 """ |
| 244 crosutils_root = os.path.join(constants.SOURCE_ROOT, 'src', 'scripts') | 249 crosutils_root = os.path.join(constants.SOURCE_ROOT, 'src', 'scripts') |
| 250 | |
| 251 # Grab the latest image we've built. | |
| 252 return_object = cros_lib.RunCommand( | |
| 253 ['./get_latest_image.sh', '--board=%s' % board], cwd=crosutils_root, | |
| 254 redirect_stdout=True, print_cmd=True) | |
| 255 | |
| 256 latest_image_dir = return_object.output.strip() | |
| 257 target_image = os.path.join(latest_image_dir, _IMAGE_TO_EXTRACT) | |
| 258 | |
| 259 # Grab the latest official build for this board to use as the base image. | |
| 260 # If it doesn't exist, run the update test against itself. | |
| 245 download_folder = os.path.abspath('latest_download') | 261 download_folder = os.path.abspath('latest_download') |
| 246 zip_url = GetLatestZipUrl(board, channel, zip_server_base) | 262 zip_url = GetLatestZipUrl(board, channel, zip_server_base) |
| 247 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) | |
| 248 | 263 |
| 249 # Tests go here. | 264 base_image = None |
| 250 return_object = cros_lib.RunCommand( | 265 if zip_url: |
| 251 ['./get_latest_image.sh', '--board=%s' % board], cwd=crosutils_root, | 266 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) |
| 252 redirect_stdout=True, print_cmd=True) | 267 base_image = os.path.join(download_folder, _IMAGE_TO_EXTRACT) |
| 253 | 268 else: |
| 254 latest_image = return_object.output.strip() | 269 base_image = target_image |
| 255 | 270 |
| 256 update_engine_path = os.path.join(crosutils_root, '..', 'platform', | 271 update_engine_path = os.path.join(crosutils_root, '..', 'platform', |
| 257 'update_engine') | 272 'update_engine') |
| 258 | 273 |
| 259 private_key_path = os.path.join(update_engine_path, 'unittest_key.pem') | 274 private_key_path = os.path.join(update_engine_path, 'unittest_key.pem') |
| 260 public_key_path = GeneratePublicKey(private_key_path) | 275 public_key_path = GeneratePublicKey(private_key_path) |
| 261 | 276 |
| 262 cmd = ['bin/cros_au_test_harness', | 277 cmd = ['bin/cros_au_test_harness', |
| 263 '--base_image=%s' % os.path.join(download_folder, | 278 '--base_image=%s' % base_image, |
| 264 _IMAGE_TO_EXTRACT), | 279 '--target_image=%s' % target_image, |
| 265 '--target_image=%s' % os.path.join(latest_image, | |
| 266 _IMAGE_TO_EXTRACT), | |
| 267 '--board=%s' % board, | 280 '--board=%s' % board, |
| 268 '--type=%s' % type, | 281 '--type=%s' % type, |
| 269 '--remote=%s' % remote, | 282 '--remote=%s' % remote, |
| 270 '--private_key=%s' % private_key_path, | 283 '--private_key=%s' % private_key_path, |
| 271 '--public_key=%s' % public_key_path, | 284 '--public_key=%s' % public_key_path, |
| 272 ] | 285 ] |
| 273 if test_results_root: cmd.append('--test_results_root=%s' % test_results_root) | 286 if test_results_root: cmd.append('--test_results_root=%s' % test_results_root) |
| 274 if no_graphics: cmd.append('--no_graphics') | 287 if no_graphics: cmd.append('--no_graphics') |
| 275 if clean: cmd.append('--clean') | 288 if clean: cmd.append('--clean') |
| 276 | 289 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 307 if not options.zipbase: parser.error('Need zip url base to get images.') | 320 if not options.zipbase: parser.error('Need zip url base to get images.') |
| 308 | 321 |
| 309 RunAUTestHarness(options.board, options.channel, options.zipbase, | 322 RunAUTestHarness(options.board, options.channel, options.zipbase, |
| 310 options.no_graphics, options.type, options.remote, | 323 options.no_graphics, options.type, options.remote, |
| 311 not options.cache, options.test_results_root) | 324 not options.cache, options.test_results_root) |
| 312 | 325 |
| 313 | 326 |
| 314 if __name__ == '__main__': | 327 if __name__ == '__main__': |
| 315 main() | 328 main() |
| 316 | 329 |
| OLD | NEW |