OLD | NEW |
1 import re, commands, logging, os | 1 import re, commands, logging, os |
2 from autotest_lib.client.common_lib import error, utils | 2 from autotest_lib.client.common_lib import error, utils |
3 import kvm_subprocess, kvm_test_utils, kvm_utils, installer | 3 from autotest_lib.client.virt import kvm_installer |
4 | 4 |
5 | 5 |
6 def run_module_probe(test, params, env): | 6 def run_module_probe(test, params, env): |
7 """ | 7 """ |
8 load/unload KVM modules several times. | 8 load/unload KVM modules several times. |
9 | 9 |
10 The test can run in two modes: | 10 The test can run in two modes: |
11 | 11 |
12 - based on previous 'build' test: in case KVM modules were installed by a | 12 - based on previous 'build' test: in case KVM modules were installed by a |
13 'build' test, we used the modules installed by the previous test. | 13 'build' test, we used the modules installed by the previous test. |
14 | 14 |
15 - based on own params: if no previous 'build' test was run, | 15 - based on own params: if no previous 'build' test was run, |
16 we assume a pre-installed KVM module. Some parameters that | 16 we assume a pre-installed KVM module. Some parameters that |
17 work for the 'build' can be used, then, such as 'extra_modules'. | 17 work for the 'build' can be used, then, such as 'extra_modules'. |
18 """ | 18 """ |
19 | 19 |
20 installer_object = env.previous_installer() | 20 installer_object = env.previous_installer() |
21 if installer_object is None: | 21 if installer_object is None: |
22 installer_object = installer.PreInstalledKvm() | 22 installer_object = kvm_installer.PreInstalledKvm() |
23 installer_object.set_install_params(test, params) | 23 installer_object.set_install_params(test, params) |
24 | 24 |
25 logging.debug('installer object: %r', installer_object) | 25 logging.debug('installer object: %r', installer_object) |
26 | 26 |
27 mod_str = params.get("mod_list") | 27 mod_str = params.get("mod_list") |
28 if mod_str: | 28 if mod_str: |
29 mod_list = re.split("[, ]", mod_str) | 29 mod_list = re.split("[, ]", mod_str) |
30 logging.debug("mod list will be: %r", mod_list) | 30 logging.debug("mod list will be: %r", mod_list) |
31 else: | 31 else: |
32 mod_list = installer_object.full_module_list() | 32 mod_list = installer_object.full_module_list() |
(...skipping 14 matching lines...) Expand all Loading... |
47 # unload using rmmod directly because utils.unload_module() (used by | 47 # unload using rmmod directly because utils.unload_module() (used by |
48 # installer) does too much (runs lsmod, checks for dependencies), | 48 # installer) does too much (runs lsmod, checks for dependencies), |
49 # and we want to run the loop as fast as possible. | 49 # and we want to run the loop as fast as possible. |
50 for mod in reversed(mod_list): | 50 for mod in reversed(mod_list): |
51 r = utils.system("rmmod %s" % (mod), ignore_status=True) | 51 r = utils.system("rmmod %s" % (mod), ignore_status=True) |
52 if r <> 0: | 52 if r <> 0: |
53 raise error.TestFail("Failed to unload module %s. " | 53 raise error.TestFail("Failed to unload module %s. " |
54 "exit status: %d" % (mod, r)) | 54 "exit status: %d" % (mod, r)) |
55 finally: | 55 finally: |
56 installer_object.load_modules() | 56 installer_object.load_modules() |
OLD | NEW |