Index: bin/cros_au_test_harness.py |
diff --git a/bin/cros_au_test_harness.py b/bin/cros_au_test_harness.py |
index eacf837d1856df1d01b555ca2ee8eb9e8d59c125..c63fa2916c70b16059b676e40c1b1c8aea67daa1 100755 |
--- a/bin/cros_au_test_harness.py |
+++ b/bin/cros_au_test_harness.py |
@@ -30,6 +30,7 @@ global base_image_path |
global board |
global remote |
global target_image_path |
+global run_command |
global vm_graphics_flag |
class UpdateException(Exception): |
@@ -78,7 +79,7 @@ class AUTest(object): |
if self.use_delta_updates: |
try: |
self.source_image = src_image |
- self.UpdateImage(image) |
+ self._UpdateImageReportError(image) |
except: |
Warning('Delta update failed, disabling delta updates and retrying.') |
self.use_delta_updates = False |
@@ -89,7 +90,7 @@ class AUTest(object): |
def _UpdateImageReportError(self, image_path, stateful_change='old'): |
"""Calls UpdateImage and reports any error to the console. |
- |
+ |
Still throws the exception. |
""" |
try: |
@@ -167,7 +168,8 @@ class AUTest(object): |
percent that passed. |
""" |
Info('Output from VerifyImage():') |
- print output |
+ print >> sys.stderr, output |
+ sys.stderr.flush() |
percent_passed = self.ParseGenerateTestReportOutput(output) |
Info('Percent passed: %d vs. Percent required: %d' % ( |
percent_passed, percent_required_to_pass)) |
@@ -235,7 +237,7 @@ class AUTest(object): |
# Read from the URL and write to the local file |
urllib.urlretrieve(url, payload) |
- expected_msg='download_hash_data == update_check_response_hash failed' |
+ expected_msg = 'download_hash_data == update_check_response_hash failed' |
self._AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) |
def testCorruptedUpdate(self): |
@@ -253,7 +255,7 @@ class AUTest(object): |
urllib.urlretrieve(url, payload) |
# This update is expected to fail... |
- expected_msg='zlib inflate() error:-3' |
+ expected_msg = 'zlib inflate() error:-3' |
self._AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) |
class RealAUTest(unittest.TestCase, AUTest): |
@@ -270,7 +272,7 @@ class RealAUTest(unittest.TestCase, AUTest): |
"""Updates a remote image using image_to_live.sh.""" |
stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
- (code, stdout, stderr) = RunCommandCaptureOutput([ |
+ (code, stdout, stderr) = run_command([ |
'%s/image_to_live.sh' % self.crosutils, |
'--image=%s' % image_path, |
'--remote=%s' % remote, |
@@ -286,7 +288,7 @@ class RealAUTest(unittest.TestCase, AUTest): |
"""Updates a remote image using image_to_live.sh.""" |
stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
- (code, stdout, stderr) = RunCommandCaptureOutput([ |
+ (code, stdout, stderr) = run_command([ |
'%s/image_to_live.sh' % self.crosutils, |
'--payload=%s' % update_path, |
'--remote=%s' % remote, |
@@ -331,7 +333,7 @@ class VirtualAUTest(unittest.TestCase, AUTest): |
"""Creates an update-able VM based on base image.""" |
self.vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( |
image_path) |
- |
+ |
Info('Creating: %s' % self.vm_image_path) |
if not os.path.exists(self.vm_image_path): |
@@ -358,7 +360,7 @@ class VirtualAUTest(unittest.TestCase, AUTest): |
if self.source_image == base_image_path: |
self.source_image = self.vm_image_path |
- (code, stdout, stderr) = RunCommandCaptureOutput([ |
+ (code, stdout, stderr) = run_command([ |
'%s/cros_run_vm_update' % self.crosutilsbin, |
'--update_image_path=%s' % image_path, |
'--vm_image_path=%s' % self.vm_image_path, |
@@ -379,7 +381,7 @@ class VirtualAUTest(unittest.TestCase, AUTest): |
if self.source_image == base_image_path: |
self.source_image = self.vm_image_path |
- (code, stdout, stderr) = RunCommandCaptureOutput([ |
+ (code, stdout, stderr) = run_command([ |
'%s/cros_run_vm_update' % self.crosutilsbin, |
'--payload=%s' % update_path, |
'--vm_image_path=%s' % self.vm_image_path, |
@@ -419,21 +421,27 @@ if __name__ == '__main__': |
parser = optparse.OptionParser() |
parser.add_option('-b', '--base_image', |
help='path to the base image.') |
- parser.add_option('-t', '--target_image', |
- help='path to the target image.') |
parser.add_option('-r', '--board', |
help='board for the images.') |
- parser.add_option('-p', '--type', default='vm', |
- help='type of test to run: [vm, real]. Default: vm.') |
- parser.add_option('-m', '--remote', |
- help='Remote address for real test.') |
- parser.add_option('--no_graphics', action='store_true', |
- help='Disable graphics for the vm test.') |
parser.add_option('--no_delta', action='store_false', default=True, |
dest='delta', |
help='Disable using delta updates.') |
+ parser.add_option('--no_graphics', action='store_true', |
sosa
2010/12/03 22:33:28
I just sorted this by long name
|
+ help='Disable graphics for the vm test.') |
+ parser.add_option('-m', '--remote', |
+ help='Remote address for real test.') |
parser.add_option('-q', '--quick_test', default=False, action='store_true', |
help='Use a basic test to verify image.') |
+ parser.add_option('-t', '--target_image', |
+ help='path to the target image.') |
+ parser.add_option('--test_prefix', default='test', |
+ help='Only runs tests with specific prefix i.e. ' |
+ 'testFullUpdateWipeStateful.') |
+ parser.add_option('-p', '--type', default='vm', |
+ help='type of test to run: [vm, real]. Default: vm.') |
+ parser.add_option('--verbose', default=False, action='store_true', |
+ help='Print out rather than capture output as much as ' |
+ 'possible.') |
# Set the usage to include flags. |
parser.set_usage(parser.format_help()) |
# Parse existing sys.argv so we can pass rest to unittest.main. |
@@ -442,6 +450,8 @@ if __name__ == '__main__': |
base_image_path = options.base_image |
target_image_path = options.target_image |
board = options.board |
+ run_command = RunCommandCaptureOutput |
+ if options.verbose: run_command = RunCommand |
dgarrett
2010/12/06 18:35:23
This isn't quite what I thought you meant when we
|
if not base_image_path: |
parser.error('Need path to base image for vm.') |
@@ -463,19 +473,15 @@ if __name__ == '__main__': |
AUTest.use_delta_updates = options.delta |
# Only run the test harness we care about. |
- if options.type == 'vm': |
- suite = unittest.TestLoader().loadTestsFromTestCase(VirtualAUTest) |
- test_result = unittest.TextTestRunner(verbosity=2).run(suite) |
- elif options.type == 'real': |
- if not options.remote: |
- parser.error('Real tests require a remote test machine.') |
- else: |
- remote = options.remote |
+ test_loader = unittest.TestLoader() |
+ test_loader.testMethodPrefix = options.test_prefix |
sosa
2010/12/03 22:33:28
Cleaned this up to make it easier to read and put
|
+ |
+ if options.type == 'vm': test_class = VirtualAUTest |
+ elif options.type == 'real': test_class = RealAUTest |
+ else: parser.error('Could not parse harness type %s.' % options.type) |
- suite = unittest.TestLoader().loadTestsFromTestCase(RealAUTest) |
- test_result = unittest.TextTestRunner(verbosity=2).run(suite) |
- else: |
- parser.error('Could not parse harness type %s.' % options.type) |
+ test_suite = test_loader.loadTestsFromTestCase(test_class) |
+ test_result = unittest.TextTestRunner(verbosity=2).run(test_suite) |
if not test_result.wasSuccessful(): |
Die('Test harness was not successful') |