Exemplo n.º 1
0
def run_module_probe(test, params, env):
    """
    load/unload kernel modules several times.

    The test can run in two modes:

    - based on previous 'build' test: in case kernel modules were installed by a
      'build' test, we used the modules installed by the previous test.

    - based on own params: if no previous 'build' test was run,
      we assume pre-installed kernel modules.
    """
    installer_object = env.previous_installer()
    if installer_object is None:
        installer_object = base_installer.NoopInstaller(
            'noop', 'module_probe', test, params)
    logging.debug('installer object: %r', installer_object)

    # unload the modules before starting:
    installer_object.unload_modules()

    load_count = int(params.get("load_count", 100))
    try:
        for _ in range(load_count):
            try:
                installer_object.load_modules()
            except base_installer.NoModuleError, e:
                logging.error(e)
                break
            except Exception, e:
                raise error.TestFail("Failed to load modules [%r]: %s" %
                                     (installer_object.module_list, e))
Exemplo n.º 2
0
def run(test, params, env):
    """
    load/unload kernel modules several times.

    This tests the kernel pre-installed kernel modules
    """
    # Destory all vms for unload/load module kvm_intel/kvm_amd
    for vm in env.get_all_vms():
        if vm:
            vm.destroy()
            env.unregister_vm(vm.name)
    installer_object = base_installer.NoopInstaller('noop', 'module_probe',
                                                    test, params)
    test.log.debug('installer object: %r', installer_object)
    submodules = []
    modules_str = " "
    for module in installer_object.module_list:
        if " %s " % module in modules_str:
            continue
        tmp_list = [module]
        if linux_modules.module_is_loaded(module):
            tmp_list += linux_modules.get_submodules(module)
        modules_str += "%s " % " ".join(tmp_list)
        if len(tmp_list) > 1:
            for _ in submodules:
                if _[0] in tmp_list:
                    submodules.remove(_)
                    break
        submodules.append(tmp_list)

    installer_object.module_list = []
    for submodule_list in submodules:
        installer_object.module_list += submodule_list

    load_count = int(params.get("load_count", 100))
    try:
        # unload the modules before starting:
        installer_object.unload_modules()
        for _ in range(load_count):
            try:
                installer_object.load_modules()
            except base_installer.NoModuleError as e:
                test.log.error(e)
                break
            except Exception as e:
                test.fail("Failed to load modules [%r]: %s" %
                          (installer_object.module_list, e))
            installer_object.unload_modules()
    finally:
        try:
            installer_object.load_modules()
        except base_installer.NoModuleError:
            pass
Exemplo n.º 3
0
def run(test, params, env):
    """
    load/unload kernel modules several times.

    This tests the kernel pre-installed kernel modules
    """
    installer_object = base_installer.NoopInstaller('noop',
                                                    'module_probe',
                                                    test, params)
    logging.debug('installer object: %r', installer_object)
    submodules = []
    modules_str = " "
    for module in installer_object.module_list:
        if " %s " % module in modules_str:
            continue
        tmp_list = [module]
        if utils.module_is_loaded(module):
            tmp_list += utils.get_submodules(module)
        modules_str += "%s " % " ".join(tmp_list)
        if len(tmp_list) > 1:
            for _ in submodules:
                if _[0] in tmp_list:
                    submodules.remove(_)
                    break
        submodules.append(tmp_list)

    installer_object.module_list = []
    for submodule_list in submodules:
        installer_object.module_list += submodule_list

    load_count = int(params.get("load_count", 100))
    try:
        # unload the modules before starting:
        installer_object.unload_modules()
        for _ in range(load_count):
            try:
                installer_object.load_modules()
            except base_installer.NoModuleError, e:
                logging.error(e)
                break
            except Exception, e:
                raise error.TestFail("Failed to load modules [%r]: %s" %
                                     (installer_object.module_list, e))
Exemplo n.º 4
0
def run_module_probe(test, params, env):
    """
    load/unload kernel modules several times.

    The test can run in two modes:

    - based on previous 'build' test: in case kernel modules were installed by a
      'build' test, we used the modules installed by the previous test.

    - based on own params: if no previous 'build' test was run,
      we assume pre-installed kernel modules.
    """
    installer_object = env.previous_installer()
    if installer_object is None:
        installer_object = base_installer.NoopInstaller(
            'noop', 'module_probe', test, params)
    logging.debug('installer object: %r', installer_object)

    # unload the modules before starting:
    installer_object.unload_modules()

    load_count = int(params.get("load_count", 100))
    try:
        for _ in range(load_count):
            try:
                installer_object.load_modules()
            except Exception, e:
                raise error.TestFail("Failed to load modules [%r]: %s" %
                                     (installer_object.module_list, e))

            # unload using rmmod directly because utils.unload_module() (used by
            # installer) does too much (runs lsmod, checks for dependencies),
            # and we want to run the loop as fast as possible.
            for mod in reversed(installer_object.module_list):
                r = utils.system("rmmod %s" % (mod), ignore_status=True)
                if r != 0:
                    raise error.TestFail("Failed to unload module %s. "
                                         "exit status: %d" % (mod, r))
    finally:
        installer_object.load_modules()
Exemplo n.º 5
0
def run_module_probe(test, params, env):
    """
    load/unload kernel modules several times.

    This tests the kernel pre-installed kernel modules
    """
    installer_object = base_installer.NoopInstaller('noop', 'module_probe',
                                                    test, params)
    logging.debug('installer object: %r', installer_object)

    # unload the modules before starting:
    installer_object.unload_modules()

    load_count = int(params.get("load_count", 100))
    try:
        for _ in range(load_count):
            try:
                installer_object.load_modules()
            except base_installer.NoModuleError, e:
                logging.error(e)
                break
            except Exception, e:
                raise error.TestFail("Failed to load modules [%r]: %s" %
                                     (installer_object.module_list, e))