示例#1
0
    def setUp(self):
        """
        Setup the device.
        """
        if 'ppc' not in platform.processor():
            self.cancel("Processor is not ppc64")
        if os.path.exists('/proc/device-tree/bmc'):
            self.cancel("Test Unsupported! on this platform")
        if 'pSeries' in open('/proc/cpuinfo', 'r').read():
            for mdl in ['rpaphp', 'rpadlpar_io']:
                if not linux_modules.module_is_loaded(mdl):
                    linux_modules.load_module(mdl)
        elif 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            if not linux_modules.module_is_loaded("pnv_php"):
                linux_modules.load_module("pnv_php")
        self.dic = {}
        self.device = self.params.get('pci_devices', default="")
        self.peer_ip = self.params.get('peer_ip', default="")
        self.count = int(self.params.get('count', default='1'))
        if not self.device:
            self.cancel("PCI_address not given")
        self.device = self.device.split(" ")
        smm = SoftwareManager()
        if not smm.check_installed("pciutils") and not smm.install("pciutils"):
            self.cancel("pciutils package is need to test")

        for pci_addr in self.device:
            if not os.path.isdir('/sys/bus/pci/devices/%s' % pci_addr):
                self.cancel("%s not present in device path" % pci_addr)
            slot = pci.get_slot_from_sysfs(pci_addr)
            if not slot:
                self.cancel("slot number not available for: %s" % pci_addr)
            self.dic[pci_addr] = slot
示例#2
0
 def setUp(self):
     """
     Setup the device.
     """
     if 'ppc' not in platform.processor():
         self.cancel("Processor is not ppc64")
     if os.path.exists('/proc/device-tree/bmc'):
         self.cancel("Test Unsupported! on this platform")
     if cpu._list_matches(
             open('/proc/cpuinfo').readlines(), 'platform\t: pSeries\n'):
         self.power_vm = True
         for mdl in ['rpaphp', 'rpadlpar_io']:
             if not linux_modules.module_is_loaded(mdl):
                 linux_modules.load_module(mdl)
     elif cpu._list_matches(
             open('/proc/cpuinfo').readlines(), 'platform\t: PowerNV\n'):
         self.power_vm = False
         if not linux_modules.module_is_loaded("pnv_php"):
             linux_modules.load_module("pnv_php")
     self.dic = {}
     self.device = self.params.get('pci_devices', default=' ').split(",")
     self.count = int(self.params.get('count', default='1'))
     if not self.device:
         self.cancel("PCI_address not given")
     for pci_addr in self.device:
         if not os.path.isdir('/sys/bus/pci/devices/%s' % pci_addr):
             self.cancel("%s not present in device path" % pci_addr)
         slot = self.get_slot(pci_addr)
         if not slot:
             self.cancel("slot number not available for: %s" % pci_addr)
         self.dic[pci_addr] = slot
示例#3
0
 def module_load_unload(self, mod1):
     """
     Unloading and loading the given module
     """
     if linux_modules.module_is_loaded(mod1) is False:
         linux_modules.load_module(mod1)
         time.sleep(self.load_unload_sleep_time)
     sub_mod = linux_modules.get_submodules(mod1)
     if sub_mod:
         for mod in sub_mod:
             linux_modules.unload_module(mod)
             if linux_modules.module_is_loaded(mod) is True:
                 self.error_modules.append(mod)
                 break
     if linux_modules.unload_module(mod1) is False:
         self.fail("Unloading Module %s failed" % mod1)
     time.sleep(self.load_unload_sleep_time)
     cmd = "%s %s=%s" % (mod1, self.param_name, self.param_value)
     if linux_modules.load_module(cmd) is False:
         self.fail("Param %s = Value %s Failed for Module %s" %
                   (self.param_name, self.param_value, mod1))
     time.sleep(self.load_unload_sleep_time)
     if self.sysfs_chk:
         if self.sysfs_value_check() is False:
             self.fail("Sysfs check failed ")
     if not wait.wait_for(configure_network.is_interface_link_up,
                          timeout=120,
                          args=[self.ifaces]):
         self.fail("Link up of interface is taking longer than 120s")
     if not configure_network.ping_check(
             self.ifaces, self.peer, '1000', flood=True):
         self.fail("ping test failed")
示例#4
0
 def setUp(self):
     """
     Sets up NVMf configuration
     """
     self.nss = self.params.get('namespaces', default='')
     self.peer_ips = self.params.get('peer_ips', default='')
     if not self.nss or not self.peer_ips:
         self.cancel("No inputs provided")
     self.peer_user = self.params.get("peer_user", default="root")
     self.peer_password = self.params.get("peer_password", default=None)
     self.nss = self.nss.split(' ')
     self.peer_ips = self.peer_ips.split(' ')
     self.ids = range(1, len(self.peer_ips) + 1)
     if len(self.nss) != len(self.peer_ips):
         self.cancel("Count of namespace and peer ips mismatch")
     smm = SoftwareManager()
     if not smm.check_installed("nvme-cli") and not \
             smm.install("nvme-cli"):
         self.cancel('nvme-cli is needed for the test to be run')
     try:
         if not linux_modules.module_is_loaded("nvme-rdma"):
             linux_modules.load_module("nvme-rdma")
     except CmdError:
         self.cancel("nvme-rdma module not loadable")
     self.cfg_tmpl = self.get_data("nvmf_template.cfg")
     dirname = os.path.dirname(os.path.abspath(self.cfg_tmpl))
     self.cfg_file = os.path.join(dirname, "nvmf.cfg")
     self.nvmf_discovery_file = "/etc/nvme/discovery.conf"
示例#5
0
 def setUp(self):
     """
     Sets up NVMf configuration
     """
     self.nss = self.params.get('namespaces', default='')
     self.peer_ips = self.params.get('peer_ips', default='')
     if not self.nss or not self.peer_ips:
         self.cancel("No inputs provided")
     self.nss = self.nss.split(',')
     self.peer_ips = self.peer_ips.split(',')
     self.ids = range(1, len(self.peer_ips) + 1)
     if len(self.nss) != len(self.peer_ips):
         self.cancel("Count of namespace and peer ips mismatch")
     smm = SoftwareManager()
     if not smm.check_installed("nvme-cli") and not \
             smm.install("nvme-cli"):
         self.cancel('nvme-cli is needed for the test to be run')
     try:
         if not linux_modules.module_is_loaded("nvme-rdma"):
             linux_modules.load_module("nvme-rdma")
     except CmdError:
         self.cancel("nvme-rdma module not loadable")
     self.cfg_tmpl = self.get_data("nvmf_template.cfg")
     self.cfg_file = self.get_data("nvmf.cfg")
     self.nvmf_discovery_file = "/etc/nvme/discovery.conf"
示例#6
0
 def test(self):
     """
     Check for the IPIs before and after ipistorm module
     """
     pre_dbl_val = self.get_interrupts("DBL")
     pre_ipi_val = self.get_interrupts("IPI")
     if not linux_modules.module_is_loaded("ipistorm"):
         if process.system(
                 "insmod ./ipistorm.ko", ignore_status=True, shell=True, sudo=True):
             self.fail("Failed to insert ipistorm module")
     else:
         self.cancel(
             "Cannot verify the DBL interrupt with module already loaded")
     time.sleep(5)
     process.system("rmmod ipistorm", ignore_status=True, sudo=True)
     post_dbl_val = self.get_interrupts("DBL")
     post_ipi_val = self.get_interrupts("IPI")
     for idx, _ in enumerate(post_dbl_val):
         if (int(post_dbl_val[idx]) <= int(pre_dbl_val[idx])) or\
                 (int(post_ipi_val[idx]) <= int(pre_ipi_val[idx])):
             self.fail("Interrupts does not seemed to be used")
         else:
             self.log.info("Old DBL %s, New DBL: %s",
                           pre_dbl_val[idx], post_dbl_val[idx])
             self.log.info("Old IPI %s, New IPI: %s",
                           pre_ipi_val[idx], post_ipi_val[idx])
 def setUp(self):
     """
     get parameters
     """
     self.module = self.params.get('module', default=None)
     self.param_name = self.params.get('module_param_name', default=None)
     self.param_value = self.params.get('module_param_value', default=None)
     self.mpath_enabled = self.params.get('multipath_enabled',
                                          default=False)
     self.disk = self.params.get('disk', default=None)
     self.load_unload_sleep_time = 30
     self.error_modules = []
     self.uname = linux_modules.platform.uname()[2]
     if not self.module:
         self.cancel("Please provide the Module name")
     if not self.disk:
         self.cancel("Please provide the Disk name")
     if linux_modules.module_is_loaded(self.module) is False:
         linux_modules.load_module(self.module)
         time.sleep(self.load_unload_sleep_time)
     if self.built_in_module(self.module) is True:
         self.cancel("Module %s is Built-in Skipping " % self.module)
     if self.param_check() is False:
         self.cancel("Param %s is not Valid for Module %s" %
                     (self.param_name, self.module))
示例#8
0
class DiskSpace(unittest.TestCase):
    @unittest.skipIf(
        process.system("modinfo scsi_debug", shell=True, ignore_status=True),
        "Kernel mod 'scsi_debug' not available.")
    @unittest.skipIf(linux_modules.module_is_loaded("scsi_debug"),
                     "Kernel mod 'scsi_debug' is already loaded.")
    @unittest.skipIf(sys.platform.startswith('darwin'),
                     'macOS does not support scsi_debug module')
    @unittest.skipIf(not process.can_sudo(), "This test requires root or "
                     "passwordless sudo configured.")
    def test_get_diskspace(self):
        """
        Use scsi_debug device to check disk size
        """
        pre = glob.glob("/dev/sd*")
        process.system("modprobe scsi_debug", sudo=True)
        disks = set(glob.glob("/dev/sd*")).difference(pre)
        self.assertEqual(len(disks), 1,
                         "pre: %s\npost: %s" % (disks, glob.glob("/dev/sd*")))
        disk = disks.pop()
        self.assertEqual(lv_utils.get_diskspace(disk), "8388608")

    def tearDown(self):
        for _ in range(10):
            if process.run("modprobe -r scsi_debug",
                           ignore_status=True,
                           sudo=True).exit_status == 0:
                return
            time.sleep(0.05)
        raise RuntimeError("Failed to remove scsi_debug after testing")
示例#9
0
 def tearDown(self):
     """
     Restore back the default Parameters
     """
     self.log.info("Restoring Default param")
     linux_modules.unload_module(self.module)
     linux_modules.load_module(self.module)
     time.sleep(self.load_unload_sleep_time)
     if linux_modules.module_is_loaded(self.module) is False:
         self.fail("Cannot restore default values for Module : %s" %
                   self.module)
示例#10
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)
    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 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:
                logging.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
示例#11
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
示例#12
0
    def setUp(self):
        """
        Verifies if CONFIG_RCU_TORTURE_TEST is enabled
        """
        self.results = []
        self.log.info("Check if CONFIG_RCU_TORTURE_TEST is enabled\n")
        ret = linux_modules.check_kernel_config('CONFIG_RCU_TORTURE_TEST')
        if ret == linux_modules.ModuleConfig.NOT_SET:
            self.cancel("CONFIG_RCU_TORTURE_TEST is not set in .config !!\n")

        self.log.info("Check rcutorture module is already  loaded\n")
        if linux_modules.module_is_loaded('rcutorture'):
            linux_modules.unload_module('rcutorture')
示例#13
0
    def setUp(self):
        """
        Verifies if CONFIG_RCU_TORTURE_TEST is enabled
        """
        self.results = []
        self.log.info("Check if CONFIG_RCU_TORTURE_TEST is enabled\n")
        ret = linux_modules.check_kernel_config("CONFIG_RCU_TORTURE_TEST")
        if ret == 0:
            self.fail("CONFIG_RCU_TORTURE_TEST is not set in .config !!\n")

        self.log.info("Check rcutorture module is already  loaded\n")
        if linux_modules.module_is_loaded("rcutorture"):
            linux_modules.unload_module("rcutorture")
示例#14
0
    def setUp(self):
        """
        Check pre-requisites before running sensors command
        Testcase should be executed only on bare-metal environment.
        """
        s_mg = SoftwareManager()
        d_distro = distro.detect()
        if d_distro.name == "Ubuntu":
            if not s_mg.check_installed("lm-sensors") and not s_mg.install(
                    "lm-sensors"):
                self.cancel('Need sensors to run the test')
        elif d_distro.name == "SuSE":
            if not s_mg.check_installed("sensors") and not s_mg.install(
                    "sensors"):
                self.cancel('Need sensors to run the test')
        else:
            if not s_mg.check_installed("lm_sensors") and not s_mg.install(
                    "lm_sensors"):
                self.cancel('Need sensors to run the test')
        if d_distro.arch in ["ppc64", "ppc64le"]:
            if not cpu._list_matches(
                    open('/proc/cpuinfo').readlines(),
                    'platform\t: PowerNV\n'):
                self.cancel(
                    'sensors test is applicable to bare-metal environment.')

            config_check = linux_modules.check_kernel_config(
                'CONFIG_SENSORS_IBMPOWERNV')
            if config_check == 0:
                self.cancel('Config is not set')
            elif config_check == 1:
                if linux_modules.load_module('ibmpowernv'):
                    if linux_modules.module_is_loaded('ibmpowernv'):
                        self.log.info('Module Loaded Successfully')
                    else:
                        self.cancel('Module Loading Failed')
            else:
                self.log.info('Module is Built In')

        if not d_distro.name == "Ubuntu":
            try:
                process.run('service lm_sensors stop', sudo=True)
                process.run('service lm_sensors start', sudo=True)
                process.run('service lm_sensors status', sudo=True)
            except process.CmdError:
                self.error(
                    'Starting Service Failed. Make sure module is loaded')
        cmd = "yes | sudo sensors-detect"
        det_op = process.run(cmd, shell=True, ignore_status=True).stdout
        if 'no sensors were detected' in det_op:
            self.cancel('No sensors found to test !')
示例#15
0
 def setUp(self):
     """
     Setup the device.
     """
     if 'ppc' not in platform.processor():
         self.cancel("Processor is not ppc64")
     if os.path.exists('/proc/device-tree/bmc'):
         self.cancel("Test Unsupported! on this platform")
     cmd = "cat /proc/cpuinfo"
     if cpu._list_matches(open('/proc/cpuinfo').readlines(),
                          'platform\t: pSeries\n'):
         PowerVM = True
         for mdl in ['rpaphp', 'rpadlpar_io']:
             if not linux_modules.module_is_loaded(mdl):
                 linux_modules.load_module(mdl)
     elif cpu._list_matches(open('/proc/cpuinfo').readlines(),
                            'platform\t: PowerNV\n'):
         PowerVM = False
         if not linux_modules.module_is_loaded("pnv_php"):
             linux_modules.load_module("pnv_php")
     self.return_code = 0
     self.device = self.params.get('pci_device', default=' ')
     self.num_of_hotplug = int(self.params.get('num_of_hotplug', default='1'))
     if not os.path.isdir('/sys/bus/pci/devices/%s' % self.device):
         self.cancel("PCI device given does not exist")
     if PowerVM:
         devspec = genio.read_file("/sys/bus/pci/devices/%s/devspec"
                                   % self.device)
         self.slot = genio.read_file("/proc/device-tree/%s/ibm,loc-code"
                                     % devspec)
         self.slot = re.match(r'((\w+)[\.])+(\w+)-P(\d+)-C(\d+)|Slot(\d+)',
                              self.slot).group()
     else:
         self.slot = pci.get_pci_prop(self.device, "PhySlot")
     if not os.path.isdir('/sys/bus/pci/slots/%s' % self.slot):
         self.cancel("%s Slot not available" % self.slot)
     if not os.path.exists('/sys/bus/pci/slots/%s/power' % self.slot):
         self.cancel("%s Slot does not support hotplug" % self.slot)
 def setUp(self):
     """
     Setup the device.
     """
     cmd = "uname -p"
     if 'ppc' not in process.system_output(cmd, ignore_status=True):
         self.cancel("Processor is not ppc64")
     cmd = "cat /proc/cpuinfo"
     if cpu._list_matches(open('/proc/cpuinfo').readlines(),
                          'platform\t: pSeries\n'):
         PowerVM = True
         for mdl in ['rpaphp', 'rpadlpar_io']:
             if not linux_modules.module_is_loaded(mdl):
                 linux_modules.load_module(mdl)
     elif cpu._list_matches(open('/proc/cpuinfo').readlines(),
                            'platform\t: PowerNV\n'):
         PowerVM = False
         if not linux_modules.module_is_loaded("pnv_php"):
             linux_modules.load_module("pnv_php")
     self.return_code = 0
     self.device = self.params.get('pci_device', default=' ')
     self.num_of_hotplug = int(self.params.get('num_of_hotplug',
                               default='1'))
     if not os.path.isdir('/sys/bus/pci/devices/%s' % self.device):
         self.cancel("PCI device given does not exist")
     if PowerVM:
         devspec = genio.read_file("/sys/bus/pci/devices/%s/devspec"
                                   % self.device)
         self.slot = genio.read_file("/proc/device-tree/%s/ibm,loc-code"
                                     % devspec)
         self.slot = re.match(r'((\w+)[\.])+(\w+)-P(\d+)-C(\d+)|Slot(\d+)',
                              self.slot).group()
     else:
         self.slot = pci.get_pci_prop(self.device, "PhySlot")
     if not os.path.isdir('/sys/bus/pci/slots/%s' % self.slot):
         self.cancel("%s Slot not available" % self.slot)
     if not os.path.exists('/sys/bus/pci/slots/%s/power' % self.slot):
         self.cancel("%s Slot does not support hotplug" % self.slot)
示例#17
0
    def setUp(self):
        """
        Check pre-requisites before running sensors command
        Testcase should be executed only on bare-metal environment.
        """
        s_mg = SoftwareManager()
        d_distro = distro.detect()
        if d_distro.name == "Ubuntu":
            if not s_mg.check_installed("lm-sensors") and not s_mg.install(
                    "lm-sensors"):
                self.cancel('Need sensors to run the test')
        elif d_distro.name == "SuSE":
            if not s_mg.check_installed("sensors") and not s_mg.install(
                    "sensors"):
                self.cancel('Need sensors to run the test')
        else:
            if not s_mg.check_installed("lm_sensors") and not s_mg.install(
                    "lm_sensors"):
                self.cancel('Need sensors to run the test')
        if d_distro.arch in ["ppc64", "ppc64le"]:
            if not cpu._list_matches(open('/proc/cpuinfo').readlines(),
                                     'platform\t: PowerNV\n'):
                self.cancel(
                    'sensors test is applicable to bare-metal environment.')

            config_check = linux_modules.check_kernel_config(
                'CONFIG_SENSORS_IBMPOWERNV')
            if config_check == 0:
                self.cancel('Config is not set')
            elif config_check == 1:
                if linux_modules.load_module('ibmpowernv'):
                    if linux_modules.module_is_loaded('ibmpowernv'):
                        self.log.info('Module Loaded Successfully')
                    else:
                        self.cancel('Module Loading Failed')
            else:
                self.log.info('Module is Built In')

        if not d_distro.name == "Ubuntu":
            try:
                process.run('service lm_sensors stop', sudo=True)
                process.run('service lm_sensors start', sudo=True)
                process.run('service lm_sensors status', sudo=True)
            except process.CmdError:
                self.error(
                    'Starting Service Failed. Make sure module is loaded')
        cmd = "yes | sudo sensors-detect"
        det_op = process.run(cmd, shell=True, ignore_status=True).stdout
        if 'no sensors were detected' in det_op:
            self.cancel('No sensors found to test !')
示例#18
0
    def module_load_unload(self, module_list):
        """
        Unloading and loading the given module
        """
        for mod1 in module_list:
            if linux_modules.module_is_loaded(mod1) is False:
                linux_modules.load_module(mod1)
                time.sleep(self.load_unload_sleep_time)

        for mdl in module_list:
            for _ in range(0, self.iteration):
                sub_mod = self.get_depend_modules(mdl)
                if sub_mod:
                    for mod in sub_mod.split(' '):
                        if mod == 'multipath':
                            if self.flush_mpath(mdl) is False:
                                self.error_modules.append(mdl)
                                break
                        else:
                            self.log.info("unloading sub module %s " % mod)
                            linux_modules.unload_module(mod)
                            if linux_modules.module_is_loaded(mod) is True:
                                self.error_modules.append(mod)
                                break
                self.log.info("unloading module %s " % mdl)
                linux_modules.unload_module(mdl)
                time.sleep(self.load_unload_sleep_time)
                if linux_modules.module_is_loaded(mdl) is True:
                    self.error_modules.append(mdl)
                    break
                self.log.info("loading module : %s " % mdl)
                linux_modules.load_module(mdl)
                time.sleep(self.load_unload_sleep_time)
                if linux_modules.module_is_loaded(mdl) is False:
                    self.error_modules.append(mdl)
                    break
 def tearDown(self):
     """
     Restore back the default Parameters
     """
     self.log.info("Restoiring Default param")
     if self.mpath_enabled is True:
         if not wait.wait_for(self.is_mpath_flushed, timeout=90):
             self.fail("multipath is in USE and cannot be flushed")
     linux_modules.unload_module(self.module)
     linux_modules.load_module(self.module)
     time.sleep(self.load_unload_sleep_time)
     if linux_modules.module_is_loaded(self.module) is False:
         self.fail("Cannot restore default values for Module : %s" %
                   self.module)
     self.log.info("Restore of default param is success")
示例#20
0
    def setUp(self):
        smg = SoftwareManager()
        if 'SuSE' in distro.detect().name:
            if not smg.check_installed("kernel-source") and not\
                    smg.install("kernel-source"):
                self.cancel("Failed to install kernel-source for this test.")
            if not os.path.exists("/usr/src/linux"):
                self.cancel("kernel source missing after install")
            self.buldir = "/usr/src/linux"
            shutil.copy('/boot/config-%s' % platform.uname()[2],
                        '%s/.config' % self.buldir)
            os.chdir(self.buldir)
            process.system("sed -i 's/^.*CONFIG_SYSTEM_TRUSTED_KEYS/#&/g'\
                           .config",
                           shell=True,
                           sudo=True)
            process.system("sed -i 's/^.*CONFIG_SYSTEM_TRUSTED_KEYRING/#&/g' \
                           .config",
                           shell=True,
                           sudo=True)
            process.system("sed -i 's/^.*CONFIG_MODULE_SIG_KEY/#&/g' .config",
                           shell=True,
                           sudo=True)
            process.system("sed -i 's/^.*CONFIG_DEBUG_INFO_BTF/#&/g' .config",
                           shell=True,
                           sudo=True)
            process.system('make')
            process.system('make modules_install')
        """
        Verifies if CONFIG_RCU_TORTURE_TEST is enabled
        """
        self.results = []
        self.log.info("Check if CONFIG_RCU_TORTURE_TEST is enabled\n")
        ret = linux_modules.check_kernel_config('CONFIG_RCU_TORTURE_TEST')
        if ret == linux_modules.ModuleConfig.NOT_SET:
            self.cancel("CONFIG_RCU_TORTURE_TEST is not set in .config !!\n")

        self.log.info("Check rcutorture module is already  loaded\n")
        if linux_modules.module_is_loaded('rcutorture'):
            linux_modules.unload_module('rcutorture')
 def module_parameter_test(self):
     """
     Unloading and loading the given module
     """
     if self.mpath_enabled is True:
         if not wait.wait_for(self.is_mpath_flushed, timeout=90):
             self.fail("multipath is in USE and cannot be flushed")
     else:
         sub_mod = linux_modules.get_submodules(self.module)
         if sub_mod:
             for mod in sub_mod.split(' '):
                 linux_modules.unload_module(mod)
                 if linux_modules.module_is_loaded(mod) is True:
                     self.error_modules.append(mod)
                     break
     self.log.info("Testing %s=%s" % (self.param_name, self.param_value))
     self.log.info("unloading driver module: %s" % self.module)
     if linux_modules.unload_module(self.module) is False:
         self.fail("Unloading Module %s failed" % self.module)
     time.sleep(self.load_unload_sleep_time)
     self.log.info("loading driver with %s=%s" %
                   (self.param_name, self.param_value))
     cmd = "%s %s=%s" % (self.module, self.param_name, self.param_value)
     if linux_modules.load_module(cmd) is False:
         self.fail("Param %s = Value %s Failed for Module %s" %
                   (self.param_name, self.param_value, self.module))
     else:
         self.log.info("Driver module=%s loaded successfully" % cmd)
     self.log.info("checking sysfs for %s after successful load" % cmd)
     if self.sysfs_value_check() is False:
         self.fail("Sysfs check failed ")
     self.log.info("sysfs check for %s success" % cmd)
     self.log.info("Running DD after %s changed" % cmd)
     if self.dd_run() is False:
         self.fail("dd run failed on disk: %s" % self.disk)
     self.log.info("DD run for %s is success" % cmd)
示例#22
0
                asset.download_asset(os_asset, interactive=interactive,
                                     restore_image=restore_image)
            except AssertionError:
                pass    # Not all files are managed via asset

    check_modules = []
    if options.vt_type == "qemu":
        check_modules = arch.get_kvm_module_list()
    elif options.vt_type == "openvswitch":
        check_modules = ["openvswitch"]

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not linux_modules.module_is_loaded(module):
                logging.warning("Module %s is not loaded. You might want to "
                                "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    online_docs_url = 'http://avocado-vt.readthedocs.org/'
    logging.info("")
    step += 1
    logging.info("%d - If you wish, you may take a look at the online docs for "
                 "more info", step)
    logging.info("")
    logging.info(online_docs_url)
示例#23
0
            except AssertionError:
                pass  # Not all files are managed via asset

    check_modules = []
    if options.vt_type == "qemu":
        check_modules = arch.get_kvm_module_list()
    elif options.vt_type == "openvswitch":
        check_modules = ["openvswitch"]

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not linux_modules.module_is_loaded(module):
                logging.warning(
                    "Module %s is not loaded. You might want to "
                    "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    online_docs_url = 'http://avocado-vt.readthedocs.org/'
    logging.info("")
    step += 1
    logging.info(
        "%d - If you wish, you may take a look at the online docs for "
        "more info", step)
    logging.info("")
    logging.info(online_docs_url)
示例#24
0
 def tearDown(self):
     if linux_modules.module_is_loaded('rcutorture'):
         linux_modules.unload_module('rcutorture')
示例#25
0
def bootstrap(options, interactive=False):
    """
    Common virt test assistant module.

    :param options: Command line options.
    :param interactive: Whether to ask for confirmation.
    """
    if get_opt(options, 'yes_to_all'):
        interactive = False

    vt_type = get_opt(options, 'vt.type')
    LOG.info("Running bootstrap for %s", vt_type)
    step = 0

    LOG.info("")
    step += 1
    LOG.info("%d - Checking the mandatory programs and headers", step)
    guest_os = get_opt(options, 'vt.guest_os') or defaults.DEFAULT_GUEST_OS
    try:
        verify_mandatory_programs(vt_type, guest_os)
    except Exception as details:
        LOG.debug(details)
        LOG.debug('Install the missing programs and/or headers and '
                  're-run boostrap')
        sys.exit(1)

    LOG.info("")
    step += 1
    LOG.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(vt_type)

    LOG.info("")
    step += 1
    LOG.info("%d - Updating test providers repo configuration from local copy",
             step)
    tp_base_dir = data_dir.get_base_test_providers_dir()
    tp_local_dir = data_dir.get_test_providers_dir()
    dir_util.copy_tree(tp_base_dir, tp_local_dir)

    not_downloaded = asset.test_providers_not_downloaded()
    if not_downloaded:
        action = "Downloading"
    else:
        action = "Updating"
    if not get_opt(options, 'vt_no_downloads'):
        LOG.info("")
        step += 1
        LOG.info("%d - %s the test providers from remote repos", step, action)
        asset.download_all_test_providers(
            get_opt(options, 'vt_update_providers'))
    else:
        if not_downloaded:
            LOG.warn(
                "The following test providers have not been downloaded: %s",
                ", ".join(not_downloaded))

    LOG.info("")
    step += 1
    LOG.info("%d - Verifying directories", step)
    datadir = data_dir.get_data_dir()
    shared_dir = data_dir.get_shared_dir()
    sub_dir_list = ["images", "isos", "steps_data", "gpg", "downloads"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(datadir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            LOG.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            LOG.debug("Dir %s exists, not creating", sub_dir_path)

    base_backend_dir = data_dir.get_base_backend_dir()
    local_backend_dir = data_dir.get_local_backend_dir()
    LOG.info("")
    step += 1
    LOG.info("%d - Syncing backend dirs %s -> %s", step, base_backend_dir,
             local_backend_dir)
    dir_util.copy_tree(base_backend_dir, local_backend_dir)

    sync_download_dir(interactive)

    test_dir = data_dir.get_backend_dir(vt_type)
    if vt_type == 'libvirt':
        step = create_config_files(test_dir,
                                   shared_dir,
                                   interactive,
                                   vt_type,
                                   step,
                                   force_update=get_opt(
                                       options, 'vt_update_config'))
        create_subtests_cfg(vt_type)
        create_guest_os_cfg(vt_type)
        # Don't bother checking if changes can't be made
        if os.getuid() == 0:
            verify_selinux(datadir, os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(), interactive,
                           get_opt(options, 'vt_selinux_setup'))

    # lvsb test doesn't use any shared configs
    elif vt_type == 'lvsb':
        create_subtests_cfg(vt_type)
        if os.getuid() == 0:
            # Don't bother checking if changes can't be made
            verify_selinux(datadir, os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(), interactive,
                           get_opt(options, 'vt_selinux_setup'))
    else:  # Some other test
        step = create_config_files(test_dir,
                                   shared_dir,
                                   interactive,
                                   vt_type,
                                   step,
                                   force_update=get_opt(
                                       options, 'vt_update_config'))
        create_subtests_cfg(vt_type)
        create_guest_os_cfg(vt_type)
    create_host_os_cfg(options)

    if not (get_opt(options, 'vt_no_downloads')
            or get_opt(options, 'vt_skip_verify_download_assets')):
        LOG.info("")
        step += 1
        LOG.info("%s - Verifying (and possibly downloading) guest image", step)
        try:
            for os_info in get_guest_os_info_list(vt_type, guest_os):
                os_asset = os_info['asset']
                try:
                    asset.download_asset(os_asset,
                                         interactive=interactive,
                                         restore_image=True)
                except AssertionError:
                    pass  # Not all files are managed via asset

        except ValueError as details:
            LOG.error(details)
            sys.exit(1)

    check_modules = []
    if vt_type == "qemu":
        check_modules = arch.get_kvm_module_list()
    elif vt_type == "openvswitch":
        check_modules = ["openvswitch"]

    if check_modules:
        LOG.info("")
        step += 1
        LOG.info("%d - Checking for modules %s", step,
                 ", ".join(check_modules))
        for module in check_modules:
            if not linux_modules.module_is_loaded(module):
                LOG.warning(
                    "Module %s is not loaded. You might want to "
                    "load it", module)
            else:
                LOG.debug("Module %s loaded", module)

    LOG.info("")
    LOG.info("VT-BOOTSTRAP FINISHED")
    LOG.debug(
        "You may take a look at the following online docs for more info:")
    LOG.debug(" - http://avocado-vt.readthedocs.org/")
    LOG.debug(" - http://avocado-framework.readthedocs.org/")
 def test_is_module_loaded(self):
     with mock.patch('avocado.utils.linux_modules.open',
                     return_value=self._get_file_mock(self.PROC_MODULES_OUT)):
         self.assertTrue(linux_modules.module_is_loaded("rfcomm"))
         self.assertFalse(linux_modules.module_is_loaded("unknown_module"))
示例#27
0
 def test_is_module_loaded(self):
     with unittest.mock.patch('builtins.open',
                              return_value=self._get_file_mock(
                                  self.PROC_MODULES_OUT)):
         self.assertTrue(linux_modules.module_is_loaded("rfcomm"))
         self.assertFalse(linux_modules.module_is_loaded("unknown_module"))
示例#28
0
 def test_is_module_loaded(self):
     with unittest.mock.patch(
             'builtins.open',
             return_value=self._get_data_mock('proc_modules')):
         self.assertTrue(linux_modules.module_is_loaded("rfcomm"))
         self.assertFalse(linux_modules.module_is_loaded("unknown_module"))
示例#29
0
def bootstrap(options, interactive=False):
    """
    Common virt test assistant module.

    :param options: Command line options.
    :param interactive: Whether to ask for confirmation.
    """
    if options.yes_to_all:
        interactive = False

    LOG.info("Running bootstrap for %s", options.vt_type)
    step = 0

    LOG.info("")
    step += 1
    LOG.info("%d - Checking the mandatory programs and headers", step)
    guest_os = options.vt_guest_os or defaults.DEFAULT_GUEST_OS
    try:
        verify_mandatory_programs(options.vt_type, guest_os)
    except Exception as details:
        LOG.debug(details)
        LOG.debug('Install the missing programs and/or headers and '
                  're-run boostrap')
        sys.exit(1)

    LOG.info("")
    step += 1
    LOG.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(options.vt_type)

    LOG.info("")
    step += 1
    LOG.info("%d - Updating test providers repo configuration from local copy", step)
    tp_base_dir = data_dir.get_base_test_providers_dir()
    tp_local_dir = data_dir.get_test_providers_dir()
    dir_util.copy_tree(tp_base_dir, tp_local_dir)

    not_downloaded = asset.test_providers_not_downloaded()
    if not_downloaded:
        action = "Downloading"
    else:
        action = "Updating"
    if not options.vt_no_downloads:
        LOG.info("")
        step += 1
        LOG.info("%d - %s the test providers from remote repos", step, action)
        asset.download_all_test_providers(options.vt_update_providers)
    else:
        if not_downloaded:
            LOG.warn("The following test providers have not been downloaded: %s",
                     ", ".join(not_downloaded))

    LOG.info("")
    step += 1
    LOG.info("%d - Verifying directories", step)
    datadir = data_dir.get_data_dir()
    shared_dir = data_dir.get_shared_dir()
    sub_dir_list = ["images", "isos", "steps_data", "gpg", "downloads"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(datadir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            LOG.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            LOG.debug("Dir %s exists, not creating",
                      sub_dir_path)

    base_backend_dir = data_dir.get_base_backend_dir()
    local_backend_dir = data_dir.get_local_backend_dir()
    LOG.info("")
    step += 1
    LOG.info("%d - Syncing backend dirs %s -> %s", step, base_backend_dir,
             local_backend_dir)
    dir_util.copy_tree(base_backend_dir, local_backend_dir)

    sync_download_dir(interactive)

    test_dir = data_dir.get_backend_dir(options.vt_type)
    if options.vt_type == 'libvirt':
        step = create_config_files(test_dir, shared_dir, interactive,
                                   options.vt_type, step,
                                   force_update=options.vt_update_config)
        create_subtests_cfg(options.vt_type)
        create_guest_os_cfg(options.vt_type)
        # Don't bother checking if changes can't be made
        if os.getuid() == 0:
            verify_selinux(datadir,
                           os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(),
                           interactive, options.vt_selinux_setup)

    # lvsb test doesn't use any shared configs
    elif options.vt_type == 'lvsb':
        create_subtests_cfg(options.vt_type)
        if os.getuid() == 0:
            # Don't bother checking if changes can't be made
            verify_selinux(datadir,
                           os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(),
                           interactive, options.vt_selinux_setup)
    else:  # Some other test
        step = create_config_files(test_dir, shared_dir, interactive,
                                   options.vt_type, step,
                                   force_update=options.vt_update_config)
        create_subtests_cfg(options.vt_type)
        create_guest_os_cfg(options.vt_type)
    create_host_os_cfg(options)

    if not (options.vt_no_downloads or options.vt_skip_verify_download_assets):
        LOG.info("")
        step += 1
        LOG.info("%s - Verifying (and possibly downloading) guest image",
                 step)
        try:
            for os_info in get_guest_os_info_list(options.vt_type, guest_os):
                os_asset = os_info['asset']
                try:
                    asset.download_asset(os_asset, interactive=interactive,
                                         restore_image=True)
                except AssertionError:
                    pass    # Not all files are managed via asset

        except ValueError as details:
            LOG.error(details)
            sys.exit(1)

    check_modules = []
    if options.vt_type == "qemu":
        check_modules = arch.get_kvm_module_list()
    elif options.vt_type == "openvswitch":
        check_modules = ["openvswitch"]

    if check_modules:
        LOG.info("")
        step += 1
        LOG.info("%d - Checking for modules %s", step,
                 ", ".join(check_modules))
        for module in check_modules:
            if not linux_modules.module_is_loaded(module):
                LOG.warning("Module %s is not loaded. You might want to "
                            "load it", module)
            else:
                LOG.debug("Module %s loaded", module)

    LOG.info("")
    LOG.info("VT-BOOTSTRAP FINISHED")
    LOG.debug("You may take a look at the following online docs for more info:")
    LOG.debug(" - http://avocado-vt.readthedocs.org/")
    LOG.debug(" - http://avocado-framework.readthedocs.org/")