def test(self):
     """
     Creates namespace on the device.
     """
     for pci_addr in self.pci_devices.split(" "):
         driver = pci.get_driver(pci_addr)
         for _ in range(self.count):
             self.log.info("iteration:%s for PCI_ID = %s" % (_, pci_addr))
             cmd = "echo -n %s > /sys/bus/pci/drivers/%s/unbind" \
                 % (pci_addr, driver)
             process.run(cmd, shell=True, sudo=True)
             time.sleep(5)
             cmd = 'ls /sys/bus/pci/drivers/%s' % driver
             process.run(cmd, shell=True)
             if os.path.exists("/sys/bus/pci/drivers/%s/%s"
                               % (driver, pci_addr)):
                 self.return_code = 1
             else:
                 self.log.info("successfully unbinded %s" % pci_addr)
             cmd = "echo -n %s > /sys/bus/pci/drivers/%s/bind" \
                 % (pci_addr, driver)
             process.run(cmd, shell=True, sudo=True)
             time.sleep(5)
             cmd = 'ls /sys/bus/pci/drivers/%s' % driver
             process.run(cmd, shell=True)
             if not os.path.exists("/sys/bus/pci/drivers/%s/%s"
                                   % (driver, pci_addr)):
                 self.return_code = 2
             else:
                 self.log.info("successfully binded back %s" % pci_addr)
             if self.return_code == 1:
                 self.fail('%s not unbound in itertion=%s' % (pci_addr, _))
             if self.return_code == 2:
                 self.fail('%s not bound back itertion=%s' % (pci_addr, _))
 def setUp(self):
     """
     Setup the device.
     """
     self.return_code = 0
     self.slot = self.params.get('pci_device', default='0001:01:00.0')
     self.driver = pci.get_driver(self.slot)
     if not self.driver:
         self.cancel("%s does not exist" % self.slot)
 def setUp(self):
     """
     Setup the device.
     """
     self.return_code = 0
     self.slot = self.params.get('pci_device', default='0001:01:00.0')
     self.driver = pci.get_driver(self.slot)
     if not self.driver:
         self.cancel("%s does not exist" % self.slot)
 def setUp(self):
     '''
     To check and install dependencies for the test
     '''
     sm = SoftwareManager()
     for pkg in ["ethtool", "net-tools"]:
         if not sm.check_installed(pkg) and not sm.install(pkg):
             self.cancel("%s package is need to test" % pkg)
     interfaces = netifaces.interfaces()
     self.iface = self.params.get("interface")
     if self.iface not in interfaces:
         self.cancel("%s interface is not available" % self.iface)
     cmd = "ethtool -i %s" % self.iface
     for line in process.system_output(cmd, shell=True).decode("utf-8") \
                                                       .splitlines():
         if 'bus-info' in line:
             self.businfo = line.split()[-1]
     self.log.info(self.businfo)
     self.driver = pci.get_driver(self.businfo)
Exemple #5
0
    def test(self):
        """
        Begining the test here
        """
        pci_addrs = []
        if self.module:
            for modl in self.module.split(' '):
                self.mod_list.append(modl)
        elif self.only_io is True:
            for pci_addrs in pci.get_pci_addresses():
                self.mod_list.append(pci.get_driver(pci_addrs))
        else:
            cmd = "find /lib/modules/%s/ -name /*.ko" % self.uname
            for line in process.getoutput(cmd).splitlines():
                driver = process.getoutput(line.split('/')[-1])
                self.mod_list.append(driver.split('.')[0])
        for mod in self.mod_list:
            if self.built_in_module(mod) is True:
                self.mod_list.remove(mod)
        self.log.info("\n\n final list : %s" % self.mod_list)
        self.module_load_unload(list(set(self.mod_list)))

        if self.error_modules:
            self.fail("Failed Modules: %s" % self.error_modules)