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 implementation of an au_worker for virtual machines.""" | 5 """Module containing implementation of an au_worker for virtual machines.""" |
6 | 6 |
7 import os | 7 import os |
8 import threading | 8 import threading |
9 import unittest | 9 import unittest |
10 | 10 |
11 import cros_build_lib as cros_lib | 11 import cros_build_lib as cros_lib |
12 | 12 |
13 import au_worker | 13 import au_worker |
14 | 14 |
15 | 15 |
16 class VMAUWorker(au_worker.AUWorker): | 16 class VMAUWorker(au_worker.AUWorker): |
17 """Test harness for updating virtual machines.""" | 17 """Test harness for updating virtual machines.""" |
18 | 18 |
19 # Class variables used to acquire individual VM variables per test. | 19 # Class variables used to acquire individual VM variables per test. |
20 _vm_lock = threading.Lock() | 20 _vm_lock = threading.Lock() |
21 _next_port = 9222 | 21 _next_port = 9222 |
22 | 22 |
23 def __init__(self, options): | 23 def __init__(self, options, test_results_root): |
24 """Processes vm-specific options.""" | 24 """Processes vm-specific options.""" |
25 au_worker.AUWorker.__init__(self, options) | 25 au_worker.AUWorker.__init__(self, options, test_results_root) |
26 self.graphics_flag = '' | 26 self.graphics_flag = '' |
27 if options.no_graphics: self.graphics_flag = '--no_graphics' | 27 if options.no_graphics: self.graphics_flag = '--no_graphics' |
28 if not self.board: cros_lib.Die('Need board to convert base image to vm.') | 28 if not self.board: cros_lib.Die('Need board to convert base image to vm.') |
29 | 29 |
30 self._AcquireUniquePortAndPidFile() | 30 self._AcquireUniquePortAndPidFile() |
31 self._KillExistingVM(self._kvm_pid_file) | 31 self._KillExistingVM(self._kvm_pid_file) |
32 | 32 |
33 def _KillExistingVM(self, pid_file): | 33 def _KillExistingVM(self, pid_file): |
34 """Kills an existing VM specified by the pid_file.""" | 34 """Kills an existing VM specified by the pid_file.""" |
35 if os.path.exists(pid_file): | 35 if os.path.exists(pid_file): |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 '--persist', | 88 '--persist', |
89 '--kvm_pid=%s' % self._kvm_pid_file, | 89 '--kvm_pid=%s' % self._kvm_pid_file, |
90 '--ssh_port=%s' % self._ssh_port, | 90 '--ssh_port=%s' % self._ssh_port, |
91 stateful_change_flag, | 91 stateful_change_flag, |
92 ] | 92 ] |
93 if proxy_port: cmd.append('--proxy_port=%s' % proxy_port) | 93 if proxy_port: cmd.append('--proxy_port=%s' % proxy_port) |
94 self.RunUpdateCmd(cmd) | 94 self.RunUpdateCmd(cmd) |
95 | 95 |
96 def VerifyImage(self, unittest, percent_required_to_pass=100): | 96 def VerifyImage(self, unittest, percent_required_to_pass=100): |
97 """Runs vm smoke suite to verify image.""" | 97 """Runs vm smoke suite to verify image.""" |
| 98 test_directory = self.GetNextResultsPath('verify') |
98 # image_to_live already verifies lsb-release matching. This is just | 99 # image_to_live already verifies lsb-release matching. This is just |
99 # for additional steps. | 100 # for additional steps. |
100 commandWithArgs = ['%s/cros_run_vm_test' % self.crosutilsbin, | 101 commandWithArgs = ['%s/cros_run_vm_test' % self.crosutilsbin, |
101 '--image_path=%s' % self.vm_image_path, | 102 '--image_path=%s' % self.vm_image_path, |
102 '--snapshot', | 103 '--snapshot', |
103 '--persist', | 104 '--persist', |
104 '--kvm_pid=%s' % self._kvm_pid_file, | 105 '--kvm_pid=%s' % self._kvm_pid_file, |
105 '--ssh_port=%s' % self._ssh_port, | 106 '--ssh_port=%s' % self._ssh_port, |
| 107 '--results_dir_root=%s' % test_directory, |
106 self.verify_suite, | 108 self.verify_suite, |
107 ] | 109 ] |
108 if self.graphics_flag: commandWithArgs.append(self.graphics_flag) | 110 if self.graphics_flag: commandWithArgs.append(self.graphics_flag) |
109 output = cros_lib.RunCommand(commandWithArgs, error_ok=True, | 111 output = cros_lib.RunCommand(commandWithArgs, error_ok=True, |
110 enter_chroot=False, redirect_stdout=True) | 112 enter_chroot=False, redirect_stdout=True) |
111 return self.AssertEnoughTestsPassed(unittest, output, | 113 return self.AssertEnoughTestsPassed(unittest, output, |
112 percent_required_to_pass) | 114 percent_required_to_pass) |
113 | 115 |
OLD | NEW |