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 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import re | 9 import re |
10 import sys | 10 import sys |
(...skipping 24 matching lines...) Expand all Loading... |
35 class UpdateException(Exception): | 35 class UpdateException(Exception): |
36 """Exception thrown when UpdateImage or UpdateUsingPayload fail""" | 36 """Exception thrown when UpdateImage or UpdateUsingPayload fail""" |
37 def __init__(self, code, stdout): | 37 def __init__(self, code, stdout): |
38 self.code = code | 38 self.code = code |
39 self.stdout = stdout | 39 self.stdout = stdout |
40 | 40 |
41 class AUTest(object): | 41 class AUTest(object): |
42 """Abstract interface that defines an Auto Update test.""" | 42 """Abstract interface that defines an Auto Update test.""" |
43 source_image = '' | 43 source_image = '' |
44 use_delta_updates = False | 44 use_delta_updates = False |
| 45 verbose = False |
45 | 46 |
46 def setUp(self): | 47 def setUp(self): |
47 unittest.TestCase.setUp(self) | 48 unittest.TestCase.setUp(self) |
48 # Set these up as they are used often. | 49 # Set these up as they are used often. |
49 self.crosutils = os.path.join(os.path.dirname(__file__), '..') | 50 self.crosutils = os.path.join(os.path.dirname(__file__), '..') |
50 self.crosutilsbin = os.path.join(os.path.dirname(__file__)) | 51 self.crosutilsbin = os.path.join(os.path.dirname(__file__)) |
51 self.download_folder = os.path.join(self.crosutils, 'latest_download') | 52 self.download_folder = os.path.join(self.crosutils, 'latest_download') |
52 if not os.path.exists(self.download_folder): | 53 if not os.path.exists(self.download_folder): |
53 os.makedirs(self.download_folder) | 54 os.makedirs(self.download_folder) |
54 | 55 |
(...skipping 18 matching lines...) Expand all Loading... |
73 break | 74 break |
74 | 75 |
75 return int(percent_passed) | 76 return int(percent_passed) |
76 | 77 |
77 # TODO(sosa) - Remove try and convert function to DeltaUpdateImage(). | 78 # TODO(sosa) - Remove try and convert function to DeltaUpdateImage(). |
78 def TryDeltaAndFallbackToFull(self, src_image, image, stateful_change='old'): | 79 def TryDeltaAndFallbackToFull(self, src_image, image, stateful_change='old'): |
79 """Tries the delta update first if set and falls back to full update.""" | 80 """Tries the delta update first if set and falls back to full update.""" |
80 if self.use_delta_updates: | 81 if self.use_delta_updates: |
81 try: | 82 try: |
82 self.source_image = src_image | 83 self.source_image = src_image |
83 self.UpdateImage(image) | 84 self._UpdateImageReportError(image) |
84 except: | 85 except: |
85 Warning('Delta update failed, disabling delta updates and retrying.') | 86 Warning('Delta update failed, disabling delta updates and retrying.') |
86 self.use_delta_updates = False | 87 self.use_delta_updates = False |
87 self.source_image = '' | 88 self.source_image = '' |
88 self._UpdateImageReportError(image) | 89 self._UpdateImageReportError(image) |
89 else: | 90 else: |
90 self._UpdateImageReportError(image) | 91 self._UpdateImageReportError(image) |
91 | 92 |
92 def _UpdateImageReportError(self, image_path, stateful_change='old'): | 93 def _UpdateImageReportError(self, image_path, stateful_change='old'): |
93 """Calls UpdateImage and reports any error to the console. | 94 """Calls UpdateImage and reports any error to the console. |
94 | 95 |
95 Still throws the exception. | 96 Still throws the exception. |
96 """ | 97 """ |
97 try: | 98 try: |
98 self.UpdateImage(image_path, stateful_change) | 99 self.UpdateImage(image_path, stateful_change) |
99 except UpdateException as err: | 100 except UpdateException as err: |
100 # If the update fails, print it out | 101 # If the update fails, print it out |
101 Warning(err.stdout) | 102 Warning(err.stdout) |
102 raise | 103 raise |
103 | 104 |
104 def _AttemptUpdateWithPayloadExpectedFailure(self, payload, expected_msg): | 105 def _AttemptUpdateWithPayloadExpectedFailure(self, payload, expected_msg): |
105 # This update is expected to fail... | 106 # This update is expected to fail... |
106 try: | 107 try: |
107 self.UpdateUsingPayload(payload) | 108 self.UpdateUsingPayload(payload) |
108 except UpdateException as err: | 109 except UpdateException as err: |
109 # Will raise ValueError if expected is not found. | 110 # Will raise ValueError if expected is not found. |
110 if re.search(re.escape(expected_msg), err.stdout, re.MULTILINE): | 111 if re.search(re.escape(expected_msg), err.stdout, re.MULTILINE): |
111 return | 112 return |
112 | 113 |
113 Warning("Didn't find '%s' in:" % expected_msg) | 114 Warning("Didn't find '%s' in:" % expected_msg) |
114 Warning(err.stdout) | 115 Warning(err.stdout) |
115 self.fail('We managed to update when failure was expected') | 116 self.fail('We managed to update when failure was expected') |
116 | 117 |
117 def PrepareBase(self, image_path): | 118 def PrepareBase(self, image_path): |
118 """Prepares target with base_image_path.""" | 119 """Prepares target with base_image_path.""" |
119 pass | 120 pass |
120 | 121 |
121 def UpdateImage(self, image_path, stateful_change='old'): | 122 def UpdateImage(self, image_path, stateful_change='old'): |
122 """Updates target with the image given by the image_path. | 123 """Updates target with the image given by the image_path. |
123 | 124 |
124 Args: | 125 Args: |
125 image_path: Path to the image to update with. This image must be a test | 126 image_path: Path to the image to update with. This image must be a test |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 163 |
163 Args: | 164 Args: |
164 unittest: Handle to the unittest. | 165 unittest: Handle to the unittest. |
165 output: stdout from a test run. | 166 output: stdout from a test run. |
166 percent_required_to_pass: percentage required to pass. This should be | 167 percent_required_to_pass: percentage required to pass. This should be |
167 fall between 0-100. | 168 fall between 0-100. |
168 Returns: | 169 Returns: |
169 percent that passed. | 170 percent that passed. |
170 """ | 171 """ |
171 Info('Output from VerifyImage():') | 172 Info('Output from VerifyImage():') |
172 print output | 173 print >> sys.stderr, output |
| 174 sys.stderr.flush() |
173 percent_passed = self.ParseGenerateTestReportOutput(output) | 175 percent_passed = self.ParseGenerateTestReportOutput(output) |
174 Info('Percent passed: %d vs. Percent required: %d' % ( | 176 Info('Percent passed: %d vs. Percent required: %d' % ( |
175 percent_passed, percent_required_to_pass)) | 177 percent_passed, percent_required_to_pass)) |
176 unittest.assertTrue(percent_passed >= | 178 unittest.assertTrue(percent_passed >= |
177 percent_required_to_pass) | 179 percent_required_to_pass) |
178 return percent_passed | 180 return percent_passed |
179 | 181 |
180 def testFullUpdateKeepStateful(self): | 182 def testFullUpdateKeepStateful(self): |
181 """Tests if we can update normally. | 183 """Tests if we can update normally. |
182 | 184 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 232 |
231 # Image can be updated at: | 233 # Image can be updated at: |
232 # ~chrome-eng/chromeos/localmirror/autest-images | 234 # ~chrome-eng/chromeos/localmirror/autest-images |
233 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ | 235 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ |
234 'autest-images/truncated_image.gz' | 236 'autest-images/truncated_image.gz' |
235 payload = os.path.join(self.download_folder, 'truncated_image.gz') | 237 payload = os.path.join(self.download_folder, 'truncated_image.gz') |
236 | 238 |
237 # Read from the URL and write to the local file | 239 # Read from the URL and write to the local file |
238 urllib.urlretrieve(url, payload) | 240 urllib.urlretrieve(url, payload) |
239 | 241 |
240 expected_msg='download_hash_data == update_check_response_hash failed' | 242 expected_msg = 'download_hash_data == update_check_response_hash failed' |
241 self._AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) | 243 self._AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) |
242 | 244 |
243 def testCorruptedUpdate(self): | 245 def testCorruptedUpdate(self): |
244 """Tests what happens if we attempt to update with a corrupted payload.""" | 246 """Tests what happens if we attempt to update with a corrupted payload.""" |
245 # Preload with the version we are trying to test. | 247 # Preload with the version we are trying to test. |
246 self.PrepareBase(image_path=target_image_path) | 248 self.PrepareBase(image_path=target_image_path) |
247 | 249 |
248 # Image can be updated at: | 250 # Image can be updated at: |
249 # ~chrome-eng/chromeos/localmirror/autest-images | 251 # ~chrome-eng/chromeos/localmirror/autest-images |
250 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ | 252 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ |
251 'autest-images/corrupted_image.gz' | 253 'autest-images/corrupted_image.gz' |
252 payload = os.path.join(self.download_folder, 'corrupted.gz') | 254 payload = os.path.join(self.download_folder, 'corrupted.gz') |
253 | 255 |
254 # Read from the URL and write to the local file | 256 # Read from the URL and write to the local file |
255 urllib.urlretrieve(url, payload) | 257 urllib.urlretrieve(url, payload) |
256 | 258 |
257 # This update is expected to fail... | 259 # This update is expected to fail... |
258 expected_msg='zlib inflate() error:-3' | 260 expected_msg = 'zlib inflate() error:-3' |
259 self._AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) | 261 self._AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) |
260 | 262 |
261 class RealAUTest(unittest.TestCase, AUTest): | 263 class RealAUTest(unittest.TestCase, AUTest): |
262 """Test harness for updating real images.""" | 264 """Test harness for updating real images.""" |
263 | 265 |
264 def setUp(self): | 266 def setUp(self): |
265 AUTest.setUp(self) | 267 AUTest.setUp(self) |
266 | 268 |
267 def PrepareBase(self, image_path): | 269 def PrepareBase(self, image_path): |
268 """Auto-update to base image to prepare for test.""" | 270 """Auto-update to base image to prepare for test.""" |
269 self._UpdateImageReportError(image_path) | 271 self._UpdateImageReportError(image_path) |
270 | 272 |
271 def UpdateImage(self, image_path, stateful_change='old'): | 273 def UpdateImage(self, image_path, stateful_change='old'): |
272 """Updates a remote image using image_to_live.sh.""" | 274 """Updates a remote image using image_to_live.sh.""" |
273 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) | 275 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
| 276 cmd = ['%s/image_to_live.sh' % self.crosutils, |
| 277 '--image=%s' % image_path, |
| 278 '--remote=%s' % remote, |
| 279 stateful_change_flag, |
| 280 '--verify', |
| 281 '--src_image=%s' % self.source_image |
| 282 ] |
274 | 283 |
275 (code, stdout, stderr) = RunCommandCaptureOutput([ | 284 if self.verbose: |
276 '%s/image_to_live.sh' % self.crosutils, | 285 try: |
277 '--image=%s' % image_path, | 286 RunCommand(cmd) |
278 '--remote=%s' % remote, | 287 except Exception, e: |
279 stateful_change_flag, | 288 raise UpdateException(1, e.message) |
280 '--verify', | 289 else: |
281 '--src_image=%s' % self.source_image | 290 (code, stdout, stderr) = RunCommandCaptureOutput(cmd) |
282 ]) | 291 if code != 0: |
283 | 292 raise UpdateException(code, stdout) |
284 if code != 0: | |
285 raise UpdateException(code, stdout) | |
286 | 293 |
287 def UpdateUsingPayload(self, update_path, stateful_change='old'): | 294 def UpdateUsingPayload(self, update_path, stateful_change='old'): |
288 """Updates a remote image using image_to_live.sh.""" | 295 """Updates a remote image using image_to_live.sh.""" |
289 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) | 296 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
| 297 cmd = ['%s/image_to_live.sh' % self.crosutils, |
| 298 '--payload=%s' % update_path, |
| 299 '--remote=%s' % remote, |
| 300 stateful_change_flag, |
| 301 '--verify', |
| 302 ] |
290 | 303 |
291 (code, stdout, stderr) = RunCommandCaptureOutput([ | 304 if self.verbose: |
292 '%s/image_to_live.sh' % self.crosutils, | 305 try: |
293 '--payload=%s' % update_path, | 306 RunCommand(cmd) |
294 '--remote=%s' % remote, | 307 except Exception, e: |
295 stateful_change_flag, | 308 raise UpdateException(1, e.message) |
296 '--verify', | 309 else: |
297 ]) | 310 (code, stdout, stderr) = RunCommandCaptureOutput(cmd) |
298 | 311 if code != 0: |
299 if code != 0: | 312 raise UpdateException(code, stdout) |
300 raise UpdateException(code, stdout) | |
301 | 313 |
302 def VerifyImage(self, percent_required_to_pass): | 314 def VerifyImage(self, percent_required_to_pass): |
303 """Verifies an image using run_remote_tests.sh with verification suite.""" | 315 """Verifies an image using run_remote_tests.sh with verification suite.""" |
304 output = RunCommand([ | 316 output = RunCommand([ |
305 '%s/run_remote_tests.sh' % self.crosutils, | 317 '%s/run_remote_tests.sh' % self.crosutils, |
306 '--remote=%s' % remote, | 318 '--remote=%s' % remote, |
307 _VERIFY_SUITE, | 319 _VERIFY_SUITE, |
308 ], error_ok=True, enter_chroot=False, redirect_stdout=True) | 320 ], error_ok=True, enter_chroot=False, redirect_stdout=True) |
309 return self.CommonVerifyImage(self, output, percent_required_to_pass) | 321 return self.CommonVerifyImage(self, output, percent_required_to_pass) |
310 | 322 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 Info('Testing for %s' % self.vm_image_path) | 365 Info('Testing for %s' % self.vm_image_path) |
354 | 366 |
355 self.assertTrue(os.path.exists(self.vm_image_path)) | 367 self.assertTrue(os.path.exists(self.vm_image_path)) |
356 | 368 |
357 def UpdateImage(self, image_path, stateful_change='old'): | 369 def UpdateImage(self, image_path, stateful_change='old'): |
358 """Updates VM image with image_path.""" | 370 """Updates VM image with image_path.""" |
359 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) | 371 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
360 if self.source_image == base_image_path: | 372 if self.source_image == base_image_path: |
361 self.source_image = self.vm_image_path | 373 self.source_image = self.vm_image_path |
362 | 374 |
363 (code, stdout, stderr) = RunCommandCaptureOutput([ | 375 cmd = ['%s/cros_run_vm_update' % self.crosutilsbin, |
364 '%s/cros_run_vm_update' % self.crosutilsbin, | 376 '--update_image_path=%s' % image_path, |
365 '--update_image_path=%s' % image_path, | 377 '--vm_image_path=%s' % self.vm_image_path, |
366 '--vm_image_path=%s' % self.vm_image_path, | 378 '--snapshot', |
367 '--snapshot', | 379 vm_graphics_flag, |
368 vm_graphics_flag, | 380 '--persist', |
369 '--persist', | 381 '--kvm_pid=%s' % _KVM_PID_FILE, |
370 '--kvm_pid=%s' % _KVM_PID_FILE, | 382 stateful_change_flag, |
371 stateful_change_flag, | 383 '--src_image=%s' % self.source_image, |
372 '--src_image=%s' % self.source_image, | 384 ] |
373 ]) | 385 if self.verbose: |
374 | 386 try: |
375 if code != 0: | 387 RunCommand(cmd) |
376 raise UpdateException(code, stdout) | 388 except Exception, e: |
| 389 raise UpdateException(1, e.message) |
| 390 else: |
| 391 (code, stdout, stderr) = RunCommandCaptureOutput(cmd) |
| 392 if code != 0: |
| 393 raise UpdateException(code, stdout) |
377 | 394 |
378 def UpdateUsingPayload(self, update_path, stateful_change='old'): | 395 def UpdateUsingPayload(self, update_path, stateful_change='old'): |
379 """Updates a remote image using image_to_live.sh.""" | 396 """Updates a remote image using image_to_live.sh.""" |
380 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) | 397 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
381 if self.source_image == base_image_path: | 398 if self.source_image == base_image_path: |
382 self.source_image = self.vm_image_path | 399 self.source_image = self.vm_image_path |
383 | 400 |
384 (code, stdout, stderr) = RunCommandCaptureOutput([ | 401 cmd = ['%s/cros_run_vm_update' % self.crosutilsbin, |
385 '%s/cros_run_vm_update' % self.crosutilsbin, | 402 '--payload=%s' % update_path, |
386 '--payload=%s' % update_path, | 403 '--vm_image_path=%s' % self.vm_image_path, |
387 '--vm_image_path=%s' % self.vm_image_path, | 404 '--snapshot', |
388 '--snapshot', | 405 vm_graphics_flag, |
389 vm_graphics_flag, | 406 '--persist', |
390 '--persist', | 407 '--kvm_pid=%s' % _KVM_PID_FILE, |
391 '--kvm_pid=%s' % _KVM_PID_FILE, | 408 stateful_change_flag, |
392 stateful_change_flag, | 409 '--src_image=%s' % self.source_image, |
393 '--src_image=%s' % self.source_image, | 410 ] |
394 ]) | |
395 | 411 |
396 if code != 0: | 412 if self.verbose: |
397 raise UpdateException(code, stdout) | 413 try: |
| 414 RunCommand(cmd) |
| 415 except Exception, e: |
| 416 raise UpdateException(1, e.message) |
| 417 else: |
| 418 (code, stdout, stderr) = RunCommandCaptureOutput(cmd) |
| 419 if code != 0: |
| 420 raise UpdateException(code, stdout) |
398 | 421 |
399 def VerifyImage(self, percent_required_to_pass): | 422 def VerifyImage(self, percent_required_to_pass): |
400 """Runs vm smoke suite to verify image.""" | 423 """Runs vm smoke suite to verify image.""" |
401 # image_to_live already verifies lsb-release matching. This is just | 424 # image_to_live already verifies lsb-release matching. This is just |
402 # for additional steps. | 425 # for additional steps. |
403 | 426 |
404 commandWithArgs = ['%s/cros_run_vm_test' % self.crosutilsbin, | 427 commandWithArgs = ['%s/cros_run_vm_test' % self.crosutilsbin, |
405 '--image_path=%s' % self.vm_image_path, | 428 '--image_path=%s' % self.vm_image_path, |
406 '--snapshot', | 429 '--snapshot', |
407 '--persist', | 430 '--persist', |
408 '--kvm_pid=%s' % _KVM_PID_FILE, | 431 '--kvm_pid=%s' % _KVM_PID_FILE, |
409 _VERIFY_SUITE, | 432 _VERIFY_SUITE, |
410 ] | 433 ] |
411 | 434 |
412 if vm_graphics_flag: | 435 if vm_graphics_flag: |
413 commandWithArgs.append(vm_graphics_flag) | 436 commandWithArgs.append(vm_graphics_flag) |
414 | 437 |
415 output = RunCommand(commandWithArgs, error_ok=True, enter_chroot=False, | 438 output = RunCommand(commandWithArgs, error_ok=True, enter_chroot=False, |
416 redirect_stdout=True) | 439 redirect_stdout=True) |
417 return self.CommonVerifyImage(self, output, percent_required_to_pass) | 440 return self.CommonVerifyImage(self, output, percent_required_to_pass) |
418 | 441 |
419 | 442 |
420 if __name__ == '__main__': | 443 if __name__ == '__main__': |
421 parser = optparse.OptionParser() | 444 parser = optparse.OptionParser() |
422 parser.add_option('-b', '--base_image', | 445 parser.add_option('-b', '--base_image', |
423 help='path to the base image.') | 446 help='path to the base image.') |
424 parser.add_option('-t', '--target_image', | |
425 help='path to the target image.') | |
426 parser.add_option('-r', '--board', | 447 parser.add_option('-r', '--board', |
427 help='board for the images.') | 448 help='board for the images.') |
428 parser.add_option('-p', '--type', default='vm', | |
429 help='type of test to run: [vm, real]. Default: vm.') | |
430 parser.add_option('-m', '--remote', | |
431 help='Remote address for real test.') | |
432 parser.add_option('--no_graphics', action='store_true', | |
433 help='Disable graphics for the vm test.') | |
434 parser.add_option('--no_delta', action='store_false', default=True, | 449 parser.add_option('--no_delta', action='store_false', default=True, |
435 dest='delta', | 450 dest='delta', |
436 help='Disable using delta updates.') | 451 help='Disable using delta updates.') |
| 452 parser.add_option('--no_graphics', action='store_true', |
| 453 help='Disable graphics for the vm test.') |
| 454 parser.add_option('-m', '--remote', |
| 455 help='Remote address for real test.') |
437 parser.add_option('-q', '--quick_test', default=False, action='store_true', | 456 parser.add_option('-q', '--quick_test', default=False, action='store_true', |
438 help='Use a basic test to verify image.') | 457 help='Use a basic test to verify image.') |
| 458 parser.add_option('-t', '--target_image', |
| 459 help='path to the target image.') |
| 460 parser.add_option('--test_prefix', default='test', |
| 461 help='Only runs tests with specific prefix i.e. ' |
| 462 'testFullUpdateWipeStateful.') |
| 463 parser.add_option('-p', '--type', default='vm', |
| 464 help='type of test to run: [vm, real]. Default: vm.') |
| 465 parser.add_option('--verbose', default=False, action='store_true', |
| 466 help='Print out rather than capture output as much as ' |
| 467 'possible.') |
439 # Set the usage to include flags. | 468 # Set the usage to include flags. |
440 parser.set_usage(parser.format_help()) | 469 parser.set_usage(parser.format_help()) |
441 # Parse existing sys.argv so we can pass rest to unittest.main. | 470 # Parse existing sys.argv so we can pass rest to unittest.main. |
442 (options, sys.argv) = parser.parse_args(sys.argv) | 471 (options, sys.argv) = parser.parse_args(sys.argv) |
443 | 472 |
| 473 AUTest.verbose = options.verbose |
444 base_image_path = options.base_image | 474 base_image_path = options.base_image |
445 target_image_path = options.target_image | 475 target_image_path = options.target_image |
446 board = options.board | 476 board = options.board |
447 | 477 |
448 if not base_image_path: | 478 if not base_image_path: |
449 parser.error('Need path to base image for vm.') | 479 parser.error('Need path to base image for vm.') |
450 elif not os.path.exists(base_image_path): | 480 elif not os.path.exists(base_image_path): |
451 Die('%s does not exist' % base_image_path) | 481 Die('%s does not exist' % base_image_path) |
452 | 482 |
453 if not target_image_path: | 483 if not target_image_path: |
454 parser.error('Need path to target image to update with.') | 484 parser.error('Need path to target image to update with.') |
455 elif not os.path.exists(target_image_path): | 485 elif not os.path.exists(target_image_path): |
456 Die('%s does not exist' % target_image_path) | 486 Die('%s does not exist' % target_image_path) |
457 | 487 |
458 if not board: | 488 if not board: |
459 parser.error('Need board to convert base image to vm.') | 489 parser.error('Need board to convert base image to vm.') |
460 | 490 |
461 # Communicate flags to tests. | 491 # Communicate flags to tests. |
462 vm_graphics_flag = '' | 492 vm_graphics_flag = '' |
463 if options.no_graphics: vm_graphics_flag = '--no_graphics' | 493 if options.no_graphics: vm_graphics_flag = '--no_graphics' |
464 if options.quick_test: _VERIFY_SUITE = 'build_RootFilesystemSize' | 494 if options.quick_test: _VERIFY_SUITE = 'build_RootFilesystemSize' |
465 AUTest.use_delta_updates = options.delta | 495 AUTest.use_delta_updates = options.delta |
466 | 496 |
467 # Only run the test harness we care about. | 497 # Only run the test harness we care about. |
468 if options.type == 'vm': | 498 test_loader = unittest.TestLoader() |
469 suite = unittest.TestLoader().loadTestsFromTestCase(VirtualAUTest) | 499 test_loader.testMethodPrefix = options.test_prefix |
470 test_result = unittest.TextTestRunner(verbosity=2).run(suite) | |
471 elif options.type == 'real': | |
472 if not options.remote: | |
473 parser.error('Real tests require a remote test machine.') | |
474 else: | |
475 remote = options.remote | |
476 | 500 |
477 suite = unittest.TestLoader().loadTestsFromTestCase(RealAUTest) | 501 if options.type == 'vm': test_class = VirtualAUTest |
478 test_result = unittest.TextTestRunner(verbosity=2).run(suite) | 502 elif options.type == 'real': test_class = RealAUTest |
479 else: | 503 else: parser.error('Could not parse harness type %s.' % options.type) |
480 parser.error('Could not parse harness type %s.' % options.type) | 504 |
| 505 test_suite = test_loader.loadTestsFromTestCase(test_class) |
| 506 test_result = unittest.TextTestRunner(verbosity=2).run(test_suite) |
481 | 507 |
482 if not test_result.wasSuccessful(): | 508 if not test_result.wasSuccessful(): |
483 Die('Test harness was not successful') | 509 Die('Test harness was not successful') |
OLD | NEW |