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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 """Overrides unittest.TestCase.tearDown and called after every test.""" | 125 """Overrides unittest.TestCase.tearDown and called after every test.""" |
126 self.worker.CleanUp() | 126 self.worker.CleanUp() |
127 | 127 |
128 def testUpdateKeepStateful(self): | 128 def testUpdateKeepStateful(self): |
129 """Tests if we can update normally. | 129 """Tests if we can update normally. |
130 | 130 |
131 This test checks that we can update by updating the stateful partition | 131 This test checks that we can update by updating the stateful partition |
132 rather than wiping it. | 132 rather than wiping it. |
133 """ | 133 """ |
134 self.worker.InitializeResultsDirectory() | 134 self.worker.InitializeResultsDirectory() |
135 # Just make sure some tests pass on original image. Some old images | |
136 # don't pass many tests. | |
137 self.worker.PrepareBase(self.base_image_path) | 135 self.worker.PrepareBase(self.base_image_path) |
138 # TODO(sosa): move to 100% once we start testing using the autotest paired | |
139 # with the dev channel. | |
140 percent_passed = self.worker.VerifyImage(self, 10) | |
141 | 136 |
142 # Update to - all tests should pass on new image. | 137 # Update to |
143 self.worker.PerformUpdate(self.target_image_path, self.base_image_path) | 138 self.worker.PerformUpdate(self.target_image_path, self.base_image_path) |
144 percent_passed = self.worker.VerifyImage(self) | 139 self.worker.VerifyImage(self) |
145 | 140 |
146 # Update from - same percentage should pass that originally passed. | 141 # Update from |
147 self.worker.PerformUpdate(self.base_image_path, self.target_image_path) | 142 self.worker.PerformUpdate(self.target_image_path, self.target_image_path) |
148 self.worker.VerifyImage(self, percent_passed) | 143 self.worker.VerifyImage(self) |
149 | 144 |
150 def testUpdateWipeStateful(self): | 145 def testUpdateWipeStateful(self): |
151 """Tests if we can update after cleaning the stateful partition. | 146 """Tests if we can update after cleaning the stateful partition. |
152 | 147 |
153 This test checks that we can update successfully after wiping the | 148 This test checks that we can update successfully after wiping the |
154 stateful partition. | 149 stateful partition. |
155 """ | 150 """ |
156 self.worker.InitializeResultsDirectory() | 151 self.worker.InitializeResultsDirectory() |
157 # Just make sure some tests pass on original image. Some old images | |
158 # don't pass many tests. | |
159 self.worker.PrepareBase(self.base_image_path) | 152 self.worker.PrepareBase(self.base_image_path) |
160 percent_passed = self.worker.VerifyImage(self, 10) | |
161 | 153 |
162 # Update to - all tests should pass on new image. | 154 # Update to |
163 self.worker.PerformUpdate(self.target_image_path, self.base_image_path, | 155 self.worker.PerformUpdate(self.target_image_path, self.base_image_path, |
164 'clean') | 156 'clean') |
165 self.worker.VerifyImage(self) | 157 self.worker.VerifyImage(self) |
166 | 158 |
167 # Update from - same percentage should pass that originally passed. | 159 # Update from |
168 self.worker.PerformUpdate(self.base_image_path, self.target_image_path, | 160 self.worker.PerformUpdate(self.target_image_path, self.target_image_path, |
169 'clean') | 161 'clean') |
170 self.worker.VerifyImage(self, percent_passed) | 162 self.worker.VerifyImage(self) |
171 | 163 |
172 def testInterruptedUpdate(self): | 164 def testInterruptedUpdate(self): |
173 """Tests what happens if we interrupt payload delivery 3 times.""" | 165 """Tests what happens if we interrupt payload delivery 3 times.""" |
174 | 166 |
175 class InterruptionFilter(cros_test_proxy.Filter): | 167 class InterruptionFilter(cros_test_proxy.Filter): |
176 """This filter causes the proxy to interrupt the download 3 times | 168 """This filter causes the proxy to interrupt the download 3 times |
177 | 169 |
178 It does this by closing the first three connections to transfer | 170 It does this by closing the first three connections to transfer |
179 2M total in the outbound connection after they transfer the | 171 2M total in the outbound connection after they transfer the |
180 2M. | 172 2M. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ | 271 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ |
280 'autest-images/corrupted_image.gz' | 272 'autest-images/corrupted_image.gz' |
281 payload = os.path.join(self.download_folder, 'corrupted.gz') | 273 payload = os.path.join(self.download_folder, 'corrupted.gz') |
282 | 274 |
283 # Read from the URL and write to the local file | 275 # Read from the URL and write to the local file |
284 urllib.urlretrieve(url, payload) | 276 urllib.urlretrieve(url, payload) |
285 | 277 |
286 # This update is expected to fail... | 278 # This update is expected to fail... |
287 expected_msg = 'zlib inflate() error:-3' | 279 expected_msg = 'zlib inflate() error:-3' |
288 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) | 280 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) |
OLD | NEW |