OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2011 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 """This module runs a suite of Auto Update tests. | 7 """This module runs a suite of Auto Update tests. |
8 | 8 |
9 The tests can be run on either a virtual machine or actual device depending | 9 The tests can be run on either a virtual machine or actual device depending |
10 on parameters given. Specific tests can be run by invoking --test_prefix. | 10 on parameters given. Specific tests can be run by invoking --test_prefix. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 Args: | 47 Args: |
48 options: options from parsed parser. | 48 options: options from parsed parser. |
49 Returns: | 49 Returns: |
50 Dictionary of Update Identifiers->Relative cache locations. | 50 Dictionary of Update Identifiers->Relative cache locations. |
51 Raises: | 51 Raises: |
52 update_exception.UpdateException if we fail to generate an update. | 52 update_exception.UpdateException if we fail to generate an update. |
53 """ | 53 """ |
54 def _GenerateVMUpdate(target, src, private_key_path): | 54 def _GenerateVMUpdate(target, src, private_key_path): |
55 """Generates an update using the devserver.""" | 55 """Generates an update using the devserver.""" |
56 command = ['./enter_chroot.sh', | 56 command = ['sudo', |
57 '--', | |
58 'sudo', | |
59 'start_devserver', | 57 'start_devserver', |
60 '--pregenerate_update', | 58 '--pregenerate_update', |
61 '--exit', | 59 '--exit', |
62 ] | 60 ] |
63 # Add actual args to command. | 61 # Add actual args to command. |
64 command.append('--image=%s' % cros_lib.ReinterpretPathForChroot(target)) | 62 command.append('--image=%s' % cros_lib.ReinterpretPathForChroot(target)) |
65 if src: command.append('--src_image=%s' % | 63 if src: command.append('--src_image=%s' % |
66 cros_lib.ReinterpretPathForChroot(src)) | 64 cros_lib.ReinterpretPathForChroot(src)) |
67 if options.type == 'vm': command.append('--for_vm') | 65 if options.type == 'vm': command.append('--for_vm') |
68 if private_key_path: | 66 if private_key_path: |
69 command.append('--private_key=%s' % | 67 command.append('--private_key=%s' % |
70 cros_lib.ReinterpretPathForChroot(private_key_path)) | 68 cros_lib.ReinterpretPathForChroot(private_key_path)) |
71 | 69 |
72 return cros_lib.RunCommandCaptureOutput(command, combine_stdout_stderr=True, | 70 return cros_lib.RunCommandCaptureOutput(command, combine_stdout_stderr=True, |
73 print_cmd=True) | 71 enter_chroot=True, |
| 72 print_cmd=True, |
| 73 cwd=cros_lib.GetCrosUtilsPath()) |
74 | 74 |
75 # Use dummy class to mock out updates that would be run as part of a test. | 75 # Use dummy class to mock out updates that would be run as part of a test. |
76 test_suite = _PrepareTestSuite(options, use_dummy_worker=True) | 76 test_suite = _PrepareTestSuite(options, use_dummy_worker=True) |
77 test_result = unittest.TextTestRunner(verbosity=0).run(test_suite) | 77 test_result = unittest.TextTestRunner(verbosity=0).run(test_suite) |
78 if not test_result.wasSuccessful(): | 78 if not test_result.wasSuccessful(): |
79 raise update_exception.UpdateException(1, | 79 raise update_exception.UpdateException(1, |
80 'Error finding updates to generate.') | 80 'Error finding updates to generate.') |
81 | 81 |
82 cros_lib.Info('The following delta updates are required.') | 82 cros_lib.Info('The following delta updates are required.') |
83 update_ids = [] | 83 update_ids = [] |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if not test_result.wasSuccessful(): | 161 if not test_result.wasSuccessful(): |
162 cros_lib.Die('Test harness was not successful') | 162 cros_lib.Die('Test harness was not successful') |
163 | 163 |
164 | 164 |
165 def _CleanPreviousWork(options): | 165 def _CleanPreviousWork(options): |
166 """Cleans up previous work from the devserver cache and local image cache.""" | 166 """Cleans up previous work from the devserver cache and local image cache.""" |
167 cros_lib.Info('Cleaning up previous work.') | 167 cros_lib.Info('Cleaning up previous work.') |
168 # Wipe devserver cache. | 168 # Wipe devserver cache. |
169 cros_lib.RunCommandCaptureOutput( | 169 cros_lib.RunCommandCaptureOutput( |
170 ['sudo', 'start_devserver', '--clear_cache', '--exit', ], | 170 ['sudo', 'start_devserver', '--clear_cache', '--exit', ], |
171 enter_chroot=True, print_cmd=False, combine_stdout_stderr=True) | 171 enter_chroot=True, print_cmd=False, combine_stdout_stderr=True, |
| 172 cwd=cros_lib.GetCrosUtilsPath()) |
172 | 173 |
173 # Clean previous vm images if they exist. | 174 # Clean previous vm images if they exist. |
174 if options.type == 'vm': | 175 if options.type == 'vm': |
175 target_vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( | 176 target_vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( |
176 options.target_image) | 177 options.target_image) |
177 base_vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( | 178 base_vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( |
178 options.base_image) | 179 options.base_image) |
179 if os.path.exists(target_vm_image_path): os.remove(target_vm_image_path) | 180 if os.path.exists(target_vm_image_path): os.remove(target_vm_image_path) |
180 if os.path.exists(base_vm_image_path): os.remove(base_vm_image_path) | 181 if os.path.exists(base_vm_image_path): os.remove(base_vm_image_path) |
181 | 182 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 if options.public_key: | 272 if options.public_key: |
272 cros_lib.Info('Cleaning up. Removing keys added as part of testing.') | 273 cros_lib.Info('Cleaning up. Removing keys added as part of testing.') |
273 target_directory = os.path.dirname(options.target_image) | 274 target_directory = os.path.dirname(options.target_image) |
274 for key_manager in au_test.AUTest.public_key_managers: | 275 for key_manager in au_test.AUTest.public_key_managers: |
275 if key_manager.image_path.startswith(target_directory): | 276 if key_manager.image_path.startswith(target_directory): |
276 key_manager.RemoveKeyFromImage() | 277 key_manager.RemoveKeyFromImage() |
277 | 278 |
278 | 279 |
279 if __name__ == '__main__': | 280 if __name__ == '__main__': |
280 main() | 281 main() |
OLD | NEW |