未验证 提交 9865f1d7 编写于 作者: L Lukáš Doktor

Merging pull request 1899

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>

* https://github.com/avocado-framework/avocado:
  Altered the way linux_modules checks loaded module
  linux_modules returns parameter type
......@@ -26,6 +26,7 @@ import logging
import platform
from . import process
from . import genio
LOG = logging.getLogger('avocado.test')
......@@ -99,7 +100,7 @@ def loaded_module_info(module_name):
:type module_name: str
:return: Dictionary of module name, size, submodules if present, filename,
version, number of modules using it, list of modules it is
dependent on, list of params
dependent on, list of dictionary of param name and type
:rtype: dict
"""
l_raw = process.system_output('/sbin/lsmod')
......@@ -119,7 +120,12 @@ def loaded_module_info(module_name):
elif key == 'depends':
value = items[1].split(',')
elif key == 'parm':
param_list.append(items[1].split(':')[0])
param_dic = {'type': None}
param_dic['name'] = items[1].split(':')[0]
param_type = re.search(r"\((\w+)\)", items[-1])
if param_type is not None:
param_dic['type'] = param_type.group(1)
param_list.append(param_dic)
if value:
modinfo_dic[key] = value
if param_list:
......@@ -184,11 +190,14 @@ def module_is_loaded(module_name):
:param module_name: Name of module to search for
:type module_name: str
:return: True is module is loaded
:return: True if module is loaded
:rtype: bool
"""
module_name = module_name.replace('-', '_')
return bool(loaded_module_info(module_name))
for line in genio.read_file("/proc/modules").splitlines():
if line.split(None, 1)[0] == module_name:
return True
return False
def get_loaded_modules():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册