Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: bin/cros_au_test_harness.py

Issue 5988006: Add new script to stop a kvm using vm library and use in harness. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix docstring Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | bin/cros_stop_vm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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')
OLDNEW
« no previous file with comments | « no previous file | bin/cros_stop_vm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698