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 30 matching lines...) Expand all Loading... |
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 | 45 |
46 def setUp(self): | 46 def setUp(self): |
47 unittest.TestCase.setUp(self) | 47 unittest.TestCase.setUp(self) |
48 # Set these up as they are used often. | 48 # Set these up as they are used often. |
49 self.crosutils = os.path.join(os.path.dirname(__file__), '..') | 49 self.crosutils = os.path.join(os.path.dirname(__file__), '..') |
50 self.crosutilsbin = os.path.join(os.path.dirname(__file__)) | 50 self.crosutilsbin = os.path.join(os.path.dirname(__file__)) |
51 self.download_folder = os.path.join(self.crosutilsbin, 'latest_download') | 51 self.download_folder = os.path.join(self.crosutils, 'latest_download') |
| 52 if not os.path.exists(self.download_folder): |
| 53 os.makedirs(self.download_folder) |
52 | 54 |
53 def GetStatefulChangeFlag(self, stateful_change): | 55 def GetStatefulChangeFlag(self, stateful_change): |
54 """Returns the flag to pass to image_to_vm for the stateful change.""" | 56 """Returns the flag to pass to image_to_vm for the stateful change.""" |
55 stateful_change_flag = '' | 57 stateful_change_flag = '' |
56 if stateful_change: | 58 if stateful_change: |
57 stateful_change_flag = '--stateful_update_flag=%s' % stateful_change | 59 stateful_change_flag = '--stateful_update_flag=%s' % stateful_change |
58 | 60 |
59 return stateful_change_flag | 61 return stateful_change_flag |
60 | 62 |
61 def ParseGenerateTestReportOutput(self, output): | 63 def ParseGenerateTestReportOutput(self, output): |
(...skipping 20 matching lines...) Expand all Loading... |
82 except: | 84 except: |
83 Warning('Delta update failed, disabling delta updates and retrying.') | 85 Warning('Delta update failed, disabling delta updates and retrying.') |
84 self.use_delta_updates = False | 86 self.use_delta_updates = False |
85 self.source_image = '' | 87 self.source_image = '' |
86 self._UpdateImageReportError(image) | 88 self._UpdateImageReportError(image) |
87 else: | 89 else: |
88 self._UpdateImageReportError(image) | 90 self._UpdateImageReportError(image) |
89 | 91 |
90 def _UpdateImageReportError(self, image_path, stateful_change='old'): | 92 def _UpdateImageReportError(self, image_path, stateful_change='old'): |
91 """Calls UpdateImage and reports any error to the console. | 93 """Calls UpdateImage and reports any error to the console. |
92 | 94 |
93 Still throws the exception. | 95 Still throws the exception. |
94 """ | 96 """ |
95 try: | 97 try: |
96 self.UpdateImage(image_path, stateful_change) | 98 self.UpdateImage(image_path, stateful_change) |
97 except UpdateException as err: | 99 except UpdateException as err: |
98 # If the update fails, print it out | 100 # If the update fails, print it out |
99 Warning(err.stdout) | 101 Warning(err.stdout) |
100 raise | 102 raise |
101 | 103 |
102 def _AttemptUpdateWithPayloadExpectedFailure(self, payload, expected_msg): | 104 def _AttemptUpdateWithPayloadExpectedFailure(self, payload, expected_msg): |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 326 |
325 def setUp(self): | 327 def setUp(self): |
326 """Unit test overriden method. Is called before every test.""" | 328 """Unit test overriden method. Is called before every test.""" |
327 AUTest.setUp(self) | 329 AUTest.setUp(self) |
328 self._KillExistingVM(_KVM_PID_FILE) | 330 self._KillExistingVM(_KVM_PID_FILE) |
329 | 331 |
330 def PrepareBase(self, image_path): | 332 def PrepareBase(self, image_path): |
331 """Creates an update-able VM based on base image.""" | 333 """Creates an update-able VM based on base image.""" |
332 self.vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( | 334 self.vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( |
333 image_path) | 335 image_path) |
334 | 336 |
335 Info('Creating: %s' % self.vm_image_path) | 337 Info('Creating: %s' % self.vm_image_path) |
336 | 338 |
337 if not os.path.exists(self.vm_image_path): | 339 if not os.path.exists(self.vm_image_path): |
338 Info('Qemu image %s not found, creating one.' % self.vm_image_path) | 340 Info('Qemu image %s not found, creating one.' % self.vm_image_path) |
339 RunCommand(['%s/image_to_vm.sh' % self.crosutils, | 341 RunCommand(['%s/image_to_vm.sh' % self.crosutils, |
340 '--full', | 342 '--full', |
341 '--from=%s' % ReinterpretPathForChroot( | 343 '--from=%s' % ReinterpretPathForChroot( |
342 os.path.dirname(image_path)), | 344 os.path.dirname(image_path)), |
343 '--vdisk_size=%s' % _FULL_VDISK_SIZE, | 345 '--vdisk_size=%s' % _FULL_VDISK_SIZE, |
344 '--statefulfs_size=%s' % _FULL_STATEFULFS_SIZE, | 346 '--statefulfs_size=%s' % _FULL_STATEFULFS_SIZE, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 else: | 474 else: |
473 remote = options.remote | 475 remote = options.remote |
474 | 476 |
475 suite = unittest.TestLoader().loadTestsFromTestCase(RealAUTest) | 477 suite = unittest.TestLoader().loadTestsFromTestCase(RealAUTest) |
476 test_result = unittest.TextTestRunner(verbosity=2).run(suite) | 478 test_result = unittest.TextTestRunner(verbosity=2).run(suite) |
477 else: | 479 else: |
478 parser.error('Could not parse harness type %s.' % options.type) | 480 parser.error('Could not parse harness type %s.' % options.type) |
479 | 481 |
480 if not test_result.wasSuccessful(): | 482 if not test_result.wasSuccessful(): |
481 Die('Test harness was not successful') | 483 Die('Test harness was not successful') |
OLD | NEW |