OLD | NEW |
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Module containing a test suite that is run to test auto updates.""" | 5 """Module containing a test suite that is run to test auto updates.""" |
6 | 6 |
7 import os | 7 import os |
8 import tempfile | 8 import tempfile |
9 import time | 9 import time |
10 import unittest | 10 import unittest |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 if not cls.base_image_path: | 51 if not cls.base_image_path: |
52 cros_lib.Die('Need path to base image for vm.') | 52 cros_lib.Die('Need path to base image for vm.') |
53 elif not os.path.exists(cls.base_image_path): | 53 elif not os.path.exists(cls.base_image_path): |
54 cros_lib.Die('%s does not exist' % cls.base_image_path) | 54 cros_lib.Die('%s does not exist' % cls.base_image_path) |
55 | 55 |
56 if not cls.target_image_path: | 56 if not cls.target_image_path: |
57 cros_lib.Die('Need path to target image to update with.') | 57 cros_lib.Die('Need path to target image to update with.') |
58 elif not os.path.exists(cls.target_image_path): | 58 elif not os.path.exists(cls.target_image_path): |
59 cros_lib.Die('%s does not exist' % cls.target_image_path) | 59 cros_lib.Die('%s does not exist' % cls.target_image_path) |
60 | 60 |
61 # Initialize test root. | 61 # Initialize test root. Test root path must be in the chroot. |
62 if not cls.test_results_root: | 62 if not cls.test_results_root: |
63 if options.test_results_root: | 63 if options.test_results_root: |
| 64 assert 'chroot/tmp' in options.test_results_root, \ |
| 65 'Must specify a test results root inside tmp in a chroot.' |
64 cls.test_results_root = options.test_results_root | 66 cls.test_results_root = options.test_results_root |
65 else: | 67 else: |
66 cls.test_results_root = tempfile.mkdtemp(prefix='au_test_harness') | 68 cls.test_results_root = tempfile.mkdtemp( |
| 69 prefix='au_test_harness', |
| 70 dir=cros_lib.PrependChrootPath('/tmp')) |
67 | 71 |
68 cros_lib.Info('Using %s as the test results root' % cls.test_results_root) | 72 cros_lib.Info('Using %s as the test results root' % cls.test_results_root) |
69 | 73 |
70 # Cache away options to instantiate workers later. | 74 # Cache away options to instantiate workers later. |
71 cls.options = options | 75 cls.options = options |
72 | 76 |
73 def AttemptUpdateWithPayloadExpectedFailure(self, payload, expected_msg): | 77 def AttemptUpdateWithPayloadExpectedFailure(self, payload, expected_msg): |
74 """Attempt a payload update, expect it to fail with expected log""" | 78 """Attempt a payload update, expect it to fail with expected log""" |
75 try: | 79 try: |
76 self.worker.UpdateUsingPayload(payload) | 80 self.worker.UpdateUsingPayload(payload) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ | 278 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ |
275 'autest-images/corrupted_image.gz' | 279 'autest-images/corrupted_image.gz' |
276 payload = os.path.join(self.download_folder, 'corrupted.gz') | 280 payload = os.path.join(self.download_folder, 'corrupted.gz') |
277 | 281 |
278 # Read from the URL and write to the local file | 282 # Read from the URL and write to the local file |
279 urllib.urlretrieve(url, payload) | 283 urllib.urlretrieve(url, payload) |
280 | 284 |
281 # This update is expected to fail... | 285 # This update is expected to fail... |
282 expected_msg = 'zlib inflate() error:-3' | 286 expected_msg = 'zlib inflate() error:-3' |
283 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) | 287 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) |
OLD | NEW |