| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 | 440 |
| 441 class VirtualAUTest(unittest.TestCase, AUTest): | 441 class VirtualAUTest(unittest.TestCase, AUTest): |
| 442 """Test harness for updating virtual machines.""" | 442 """Test harness for updating virtual machines.""" |
| 443 vm_image_path = None | 443 vm_image_path = None |
| 444 | 444 |
| 445 def _KillExistingVM(self, pid_file): | 445 def _KillExistingVM(self, pid_file): |
| 446 if os.path.exists(pid_file): | 446 if os.path.exists(pid_file): |
| 447 Warning('Existing %s found. Deleting and killing process' % | 447 Warning('Existing %s found. Deleting and killing process' % |
| 448 pid_file) | 448 pid_file) |
| 449 pid = RunCommand(['sudo', 'cat', pid_file], redirect_stdout=True, | 449 RunCommand(['./cros_stop_vm', '--kvm_pid=%s' % pid_file], |
| 450 enter_chroot=False) | 450 cwd=self.crosutilsbin) |
| 451 if pid: | 451 |
| 452 RunCommand(['sudo', 'kill', pid.strip()], error_ok=True, | 452 assert not os.path.exists(pid_file) |
| 453 enter_chroot=False) | |
| 454 RunCommand(['sudo', 'rm', pid_file], enter_chroot=False) | |
| 455 | 453 |
| 456 def setUp(self): | 454 def setUp(self): |
| 457 """Unit test overriden method. Is called before every test.""" | 455 """Unit test overriden method. Is called before every test.""" |
| 458 AUTest.setUp(self) | 456 AUTest.setUp(self) |
| 459 self._KillExistingVM(_KVM_PID_FILE) | 457 self._KillExistingVM(_KVM_PID_FILE) |
| 460 | 458 |
| 461 def PrepareBase(self, image_path): | 459 def PrepareBase(self, image_path): |
| 462 """Creates an update-able VM based on base image.""" | 460 """Creates an update-able VM based on base image.""" |
| 463 self.vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( | 461 self.vm_image_path = '%s/chromiumos_qemu_image.bin' % os.path.dirname( |
| 464 image_path) | 462 image_path) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 elif options.type == 'real': test_class = RealAUTest | 627 elif options.type == 'real': test_class = RealAUTest |
| 630 else: parser.error('Could not parse harness type %s.' % options.type) | 628 else: parser.error('Could not parse harness type %s.' % options.type) |
| 631 | 629 |
| 632 remote = options.remote | 630 remote = options.remote |
| 633 | 631 |
| 634 test_suite = test_loader.loadTestsFromTestCase(test_class) | 632 test_suite = test_loader.loadTestsFromTestCase(test_class) |
| 635 test_result = unittest.TextTestRunner(verbosity=2).run(test_suite) | 633 test_result = unittest.TextTestRunner(verbosity=2).run(test_suite) |
| 636 | 634 |
| 637 if not test_result.wasSuccessful(): | 635 if not test_result.wasSuccessful(): |
| 638 Die('Test harness was not successful') | 636 Die('Test harness was not successful') |
| OLD | NEW |