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

Side by Side Diff: client/tests/kvm/kvm.py

Issue 6124004: Revert "Merge remote branch 'cros/upstream' into autotest-rebase" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 11 months 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 | « client/tests/kvm/installer.py ('k') | client/tests/kvm/kvm_preprocessing.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import sys, os, time, logging, imp 1 import sys, os, time, logging, imp
2 from autotest_lib.client.bin import test 2 from autotest_lib.client.bin import test
3 from autotest_lib.client.common_lib import error 3 from autotest_lib.client.common_lib import error
4 import kvm_utils, kvm_preprocessing 4 import kvm_utils, kvm_preprocessing
5 5
6 6
7 class kvm(test.test): 7 class kvm(test.test):
8 """ 8 """
9 Suite of KVM virtualization functional tests. 9 Suite of KVM virtualization functional tests.
10 Contains tests for testing both KVM kernel code and userspace code. 10 Contains tests for testing both KVM kernel code and userspace code.
11 11
12 @copyright: Red Hat 2008-2009 12 @copyright: Red Hat 2008-2009
13 @author: Uri Lublin (uril@redhat.com) 13 @author: Uri Lublin (uril@redhat.com)
14 @author: Dror Russo (drusso@redhat.com) 14 @author: Dror Russo (drusso@redhat.com)
15 @author: Michael Goldish (mgoldish@redhat.com) 15 @author: Michael Goldish (mgoldish@redhat.com)
16 @author: David Huff (dhuff@redhat.com) 16 @author: David Huff (dhuff@redhat.com)
17 @author: Alexey Eromenko (aeromenk@redhat.com) 17 @author: Alexey Eromenko (aeromenk@redhat.com)
18 @author: Mike Burns (mburns@redhat.com) 18 @author: Mike Burns (mburns@redhat.com)
19 19
20 @see: http://www.linux-kvm.org/page/KVM-Autotest/Client_Install 20 @see: http://www.linux-kvm.org/page/KVM-Autotest/Client_Install
21 (Online doc - Getting started with KVM testing) 21 (Online doc - Getting started with KVM testing)
22 """ 22 """
23 version = 1 23 version = 1
24 env_version = 1 24 env_version = 0
25 25
26 def run_once(self, params): 26 def run_once(self, params):
27 # Convert params to a Params object
28 params = kvm_utils.Params(params)
29
30 # Report the parameters we've received and write them as keyvals 27 # Report the parameters we've received and write them as keyvals
31 logging.debug("Test parameters:") 28 logging.debug("Test parameters:")
32 keys = params.keys() 29 keys = params.keys()
33 keys.sort() 30 keys.sort()
34 for key in keys: 31 for key in keys:
35 logging.debug(" %s = %s", key, params[key]) 32 logging.debug(" %s = %s", key, params[key])
36 self.write_test_keyval({key: params[key]}) 33 self.write_test_keyval({key: params[key]})
37 34
38 # Set the log file dir for the logging mechanism used by kvm_subprocess 35 # Set the log file dir for the logging mechanism used by kvm_subprocess
39 # (this must be done before unpickling env) 36 # (this must be done before unpickling env)
40 kvm_utils.set_log_file_dir(self.debugdir) 37 kvm_utils.set_log_file_dir(self.debugdir)
41 38
42 # Open the environment file 39 # Open the environment file
43 logging.info("Unpickling env. You may see some harmless error " 40 logging.info("Unpickling env. You may see some harmless error "
44 "messages.") 41 "messages.")
45 env_filename = os.path.join(self.bindir, params.get("env", "env")) 42 env_filename = os.path.join(self.bindir, params.get("env", "env"))
46 env = kvm_utils.Env(env_filename, self.env_version) 43 env = kvm_utils.load_env(env_filename, self.env_version)
44 logging.debug("Contents of environment: %s", env)
47 45
48 test_passed = False 46 test_passed = False
49 47
50 try: 48 try:
51 try: 49 try:
52 try: 50 try:
53 # Get the test routine corresponding to the specified 51 # Get the test routine corresponding to the specified
54 # test type 52 # test type
55 t_type = params.get("type") 53 t_type = params.get("type")
56 # Verify if we have the correspondent source file for it 54 # Verify if we have the correspondent source file for it
57 subtest_dir = os.path.join(self.bindir, "tests") 55 subtest_dir = os.path.join(self.bindir, "tests")
58 module_path = os.path.join(subtest_dir, "%s.py" % t_type) 56 module_path = os.path.join(subtest_dir, "%s.py" % t_type)
59 if not os.path.isfile(module_path): 57 if not os.path.isfile(module_path):
60 raise error.TestError("No %s.py test file found" % 58 raise error.TestError("No %s.py test file found" %
61 t_type) 59 t_type)
62 # Load the test module 60 # Load the test module
63 f, p, d = imp.find_module(t_type, [subtest_dir]) 61 f, p, d = imp.find_module(t_type, [subtest_dir])
64 test_module = imp.load_module(t_type, f, p, d) 62 test_module = imp.load_module(t_type, f, p, d)
65 f.close() 63 f.close()
66 64
67 # Preprocess 65 # Preprocess
68 try: 66 try:
69 kvm_preprocessing.preprocess(self, params, env) 67 kvm_preprocessing.preprocess(self, params, env)
70 finally: 68 finally:
71 env.save() 69 kvm_utils.dump_env(env, env_filename)
72 # Run the test function 70 # Run the test function
73 run_func = getattr(test_module, "run_%s" % t_type) 71 run_func = getattr(test_module, "run_%s" % t_type)
74 try: 72 try:
75 run_func(self, params, env) 73 run_func(self, params, env)
76 finally: 74 finally:
77 env.save() 75 kvm_utils.dump_env(env, env_filename)
78 test_passed = True 76 test_passed = True
79 77
80 except Exception, e: 78 except Exception, e:
81 logging.error("Test failed: %s: %s", 79 logging.error("Test failed: %s: %s",
82 e.__class__.__name__, e) 80 e.__class__.__name__, e)
83 try: 81 try:
84 kvm_preprocessing.postprocess_on_error( 82 kvm_preprocessing.postprocess_on_error(
85 self, params, env) 83 self, params, env)
86 finally: 84 finally:
87 env.save() 85 kvm_utils.dump_env(env, env_filename)
88 raise 86 raise
89 87
90 finally: 88 finally:
91 # Postprocess 89 # Postprocess
92 try: 90 try:
93 try: 91 try:
94 kvm_preprocessing.postprocess(self, params, env) 92 kvm_preprocessing.postprocess(self, params, env)
95 except Exception, e: 93 except Exception, e:
96 if test_passed: 94 if test_passed:
97 raise 95 raise
98 logging.error("Exception raised during " 96 logging.error("Exception raised during "
99 "postprocessing: %s", e) 97 "postprocessing: %s", e)
100 finally: 98 finally:
101 env.save() 99 kvm_utils.dump_env(env, env_filename)
100 logging.debug("Contents of environment: %s", env)
102 101
103 except Exception, e: 102 except Exception, e:
104 if params.get("abort_on_error") != "yes": 103 if params.get("abort_on_error") != "yes":
105 raise 104 raise
106 # Abort on error 105 # Abort on error
107 logging.info("Aborting job (%s)", e) 106 logging.info("Aborting job (%s)", e)
108 for vm in env.get_all_vms(): 107 for vm in kvm_utils.env_get_all_vms(env):
109 if vm.is_dead(): 108 if vm.is_dead():
110 continue 109 continue
111 logging.info("VM '%s' is alive.", vm.name) 110 logging.info("VM '%s' is alive.", vm.name)
112 for m in vm.monitors: 111 for m in vm.monitors:
113 logging.info("'%s' has a %s monitor unix socket at: %s", 112 logging.info("'%s' has a %s monitor unix socket at: %s",
114 vm.name, m.protocol, m.filename) 113 vm.name, m.protocol, m.filename)
115 logging.info("The command line used to start '%s' was:\n%s", 114 logging.info("The command line used to start '%s' was:\n%s",
116 vm.name, vm.make_qemu_command()) 115 vm.name, vm.make_qemu_command())
117 raise error.JobError("Abort requested (%s)" % e) 116 raise error.JobError("Abort requested (%s)" % e)
OLDNEW
« no previous file with comments | « client/tests/kvm/installer.py ('k') | client/tests/kvm/kvm_preprocessing.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698