diff --git a/io/pci/pci_info_lscfg.py b/io/pci/pci_info_lscfg.py deleted file mode 100755 index 434deaf0e..000000000 --- a/io/pci/pci_info_lscfg.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# See LICENSE for more details. -# -# Copyright: 2022 IBM -# Author: Maram Srimannarayana Murthy - -""" -PCI CFG Test. -Needs to be run as root. -""" - -from avocado import Test -from avocado.utils.software_manager import SoftwareManager -from avocado.utils import pci -from avocado.utils import process - - -class PciLscfgInfo(Test): - ''' - Check lscfg info with lspci info - ''' - - def setUp(self): - ''' - To check and install dependencies for the test - ''' - smm = SoftwareManager() - for pkg in ["lsvpd", "pciutils"]: - if not smm.check_installed(pkg) and not smm.install(pkg): - self.cancel("{pkg} package is need to test") - - def test(self): - ''' - Capture data from lscfg and lspci then compare data - ''' - error = [] - for pci_addr in pci.get_pci_addresses(): - self.log.info("Checking for PCI Address: %s\n\n", pci_addr) - pci_info_dict = pci.get_pci_info(pci_addr) - self.log.info(pci_info_dict) - cfg_output = pci.get_cfg(pci_addr) - self.log.info(cfg_output) - if cfg_output and pci_info_dict: - if 'YL' in cfg_output and 'PhySlot' in pci_info_dict: - # Physical Slot Match - self.log.info("Physical Slot from lscfg is %s" - " and lspci is %s", - cfg_output['YL'], pci_info_dict['PhySlot']) - cfg_output['YL'] = \ - cfg_output['YL'][:cfg_output['YL'].rfind('-')] - if(cfg_output['YL'] == pci_info_dict['PhySlot']): - self.log.info("Physical Slot matched") - else: - error.append("Physical slot info didn't match") - # Sub Device ID match - if ('subvendor_device' in cfg_output and - 'SDevice' in pci_info_dict): - self.log.info("Device iD from lscfg is %s" - " and lspci is %s", - cfg_output['subvendor_device'][4:], - pci_info_dict['SDevice']) - if(cfg_output['subvendor_device'][4:] - == pci_info_dict['SDevice']): - self.log.info("Sub Device ID matched") - else: - error.append("Device ID info didn't match") - # Subvendor ID Match - if ('subvendor_device' in cfg_output and - 'SVendor' in pci_info_dict): - self.log.info("Subvendor ID from lscfg is %s" - "and lspci is %s", - cfg_output['subvendor_device'], - pci_info_dict['SVendor']) - if(cfg_output['subvendor_device'][0:4] == - pci_info_dict['SVendor']): - self.log.info("Sub vendor ID matched") - else: - error.append("Sub vendor ID didn't match") - # PCI Slot ID Match - if 'pci_id' in cfg_output and 'Slot' in pci_info_dict: - self.log.info("PCI ID from lscfg is %s and lspci is %s", - cfg_output['pci_id'], pci_info_dict['Slot']) - if(cfg_output['pci_id'] == - pci_info_dict['Slot']): - self.log.info("PCI Slot ID matched") - else: - error.append("PCI slot ID didn't match") - # PCI Config Space Check - if process.system(f"lspci -xxxx -s {pci_addr}", - sudo=True): - error.append(pci_addr + " : pci_config_space") - if error: - self.fail(f"Errors for above pci addresses: {error}") diff --git a/io/pci/pci_info_lscfg.py.data/Readme.txt b/io/pci/pci_info_lscfg.py.data/Readme.txt deleted file mode 100644 index 4f14b6e3f..000000000 --- a/io/pci/pci_info_lscfg.py.data/Readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -This Test fetch the information from lscfg of pci devices using -pci adress and compares this data with lspci data. Comparision is -done for all the pci devices available in the server. diff --git a/io/pci/pci_info_lsvpd.py b/io/pci/pci_info_lsvpd.py deleted file mode 100755 index 2074a611a..000000000 --- a/io/pci/pci_info_lsvpd.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# See LICENSE for more details. -# -# Copyright: 2016 IBM -# Author: Naresh Bannoth - -""" -PCI VPD Test. -Needs to be run as root. -""" - -from avocado import Test -from avocado.utils.software_manager.manager import SoftwareManager -from avocado.utils import pci -from avocado.utils import process - - -class PciLsvpdInfo(Test): - ''' - check lsvpd info - ''' - - def setUp(self): - ''' - To check and install dependencies for the test - ''' - smm = SoftwareManager() - for pkg in ["lsvpd", "pciutils"]: - if not smm.check_installed(pkg) and not smm.install(pkg): - self.cancel("%s package is need to test" % pkg) - if process.system("vpdupdate", ignore_status=True, shell=True): - self.fail("VPD Update fails") - - def test(self): - ''' - Test - ''' - error = [] - for pci_addr in pci.get_pci_addresses(): - self.log.info("Checking for PCI Address: %s\n\n", pci_addr) - vpd_output = pci.get_vpd(pci_addr) - if vpd_output: - - # Slot Match - if 'slot' in vpd_output: - sys_slot = pci.get_slot_from_sysfs(pci_addr) - if sys_slot: - sys_slot = sys_slot.strip('\0') - vpd_slot = vpd_output['slot'] - self.log.info("Slot from sysfs: %s", sys_slot) - self.log.info("Slot from lsvpd: %s", vpd_slot) - if sys_slot in [sys_slot, vpd_slot[:vpd_slot.rfind('-')]]: - self.log.info("=======>>> slot matches perfectly\n\n") - else: - error.append(pci_addr + "-> slot") - self.log.info("--->>Slot Numbers not Matched\n\n") - else: - self.log.error("Slot info not available in vpd output\n") - - # Device ID match - sys_pci_id_output = pci.get_pci_id_from_sysfs(pci_addr) - vpd_dev_id = vpd_output['pci_id'][4:] - sysfs_dev_id = sys_pci_id_output[5:-10] - sysfs_sdev_id = sys_pci_id_output[15:] - self.log.info("Device ID from sysfs: %s", sysfs_dev_id) - self.log.info("Sub Device ID from sysfs: %s", sysfs_sdev_id) - self.log.info("Device ID from vpd: %s", vpd_dev_id) - if vpd_dev_id == sysfs_sdev_id or vpd_dev_id == sysfs_dev_id: - self.log.info("=======>>Device ID Match Success\n\n") - else: - self.log.error("----->>Device ID did not Match\n\n") - error.append(pci_addr + "-> Device_id") - - # Subvendor ID Match - sysfs_subvendor_id = sys_pci_id_output[10:-5] - vpd_subvendor_id = vpd_output['pci_id'][:4] - self.log.info("Subvendor ID frm sysfs: %s", sysfs_subvendor_id) - self.log.info("Subvendor ID from vpd : %s", vpd_subvendor_id) - if sysfs_subvendor_id == vpd_subvendor_id: - self.log.info("======>>>Subvendor ID Match Success\n\n") - else: - self.log.error("---->>Subvendor_id Not Matched\n\n") - error.append(pci_addr + "-> Subvendor_id") - - # PCI ID Match - lspci_pci_id = pci.get_pci_id(pci_addr) - self.log.info(" PCI ID from Sysfs: %s", sys_pci_id_output) - self.log.info("PCI ID from Vpd : %s", lspci_pci_id) - - if sys_pci_id_output == lspci_pci_id: - self.log.info("======>>>> All PCI ID match Success\n\n") - else: - self.log.error("---->>>PCI info Did not Matches\n\n") - error.append(pci_addr + "-> pci_id") - - # PCI Config Space Check - if process.system("lspci -xxxx -s %s" % pci_addr, - ignore_status=True, sudo=True): - error.append(pci_addr + "->pci_config_space") - - if error: - self.fail("Errors for above pci addresses: %s" % error) diff --git a/io/pci/pci_info_lsvpd.py.data/Readme.txt b/io/pci/pci_info_lsvpd.py.data/Readme.txt deleted file mode 100644 index e017223c0..000000000 --- a/io/pci/pci_info_lsvpd.py.data/Readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -This Test fetch the information from lsvpd of pci devices using -pci adress and compares this data with sysfs data. Comparision is -done for all the pci devices available in the server. diff --git a/ras/ras_lsvpd.py b/ras/ras_lsvpd.py index b2e9bfb61..57692ce72 100644 --- a/ras/ras_lsvpd.py +++ b/ras/ras_lsvpd.py @@ -17,6 +17,7 @@ import os import shutil +from avocado.utils import pci from avocado import Test from avocado.utils import process, distro, build, archive from avocado import skipIf @@ -264,3 +265,141 @@ def test_locking_mechanism(self): self.fail("Database corruption detected") else: self.log.info("Locking mechanism prevented database corruption") + + @skipIf(IS_KVM_GUEST, "This test is not supported on KVM guest platform") + def test_pci_lsvpd(self): + ''' + Verify data from sysfs and lsvpd tool output match correctly. + ''' + if process.system("vpdupdate", ignore_status=True, shell=True): + self.fail("VPD Update fails") + + error = [] + for pci_addr in pci.get_pci_addresses(): + self.log.info("Checking for PCI Address: %s\n\n", pci_addr) + vpd_output = pci.get_vpd(pci_addr) + if vpd_output: + + # Slot Match + if 'slot' in vpd_output: + sys_slot = pci.get_slot_from_sysfs(pci_addr) + if sys_slot: + sys_slot = sys_slot.strip('\0') + vpd_slot = vpd_output['slot'] + self.log.info("Slot from sysfs: %s", sys_slot) + self.log.info("Slot from lsvpd: %s", vpd_slot) + if sys_slot in [sys_slot, vpd_slot[:vpd_slot.rfind('-')]]: + self.log.info("=======>>> slot matches perfectly\n\n") + else: + error.append(pci_addr + "-> slot") + self.log.info("--->>Slot Numbers not Matched\n\n") + else: + self.log.error("Slot info not available in vpd output\n") + + # Device ID match + sys_pci_id_output = pci.get_pci_id_from_sysfs(pci_addr) + vpd_dev_id = vpd_output['pci_id'][4:] + sysfs_dev_id = sys_pci_id_output[5:-10] + sysfs_sdev_id = sys_pci_id_output[15:] + self.log.info("Device ID from sysfs: %s", sysfs_dev_id) + self.log.info("Sub Device ID from sysfs: %s", sysfs_sdev_id) + self.log.info("Device ID from vpd: %s", vpd_dev_id) + if vpd_dev_id == sysfs_sdev_id or vpd_dev_id == sysfs_dev_id: + self.log.info("=======>>Device ID Match Success\n\n") + else: + self.log.error("----->>Device ID did not Match\n\n") + error.append(pci_addr + "-> Device_id") + + # Subvendor ID Match + sysfs_subvendor_id = sys_pci_id_output[10:-5] + vpd_subvendor_id = vpd_output['pci_id'][:4] + self.log.info("Subvendor ID frm sysfs: %s", sysfs_subvendor_id) + self.log.info("Subvendor ID from vpd : %s", vpd_subvendor_id) + if sysfs_subvendor_id == vpd_subvendor_id: + self.log.info("======>>>Subvendor ID Match Success\n\n") + else: + self.log.error("---->>Subvendor_id Not Matched\n\n") + error.append(pci_addr + "-> Subvendor_id") + + # PCI ID Match + lspci_pci_id = pci.get_pci_id(pci_addr) + self.log.info(" PCI ID from Sysfs: %s", sys_pci_id_output) + self.log.info("PCI ID from Vpd : %s", lspci_pci_id) + + if sys_pci_id_output == lspci_pci_id: + self.log.info("======>>>> All PCI ID match Success\n\n") + else: + self.log.error("---->>>PCI info Did not Matches\n\n") + error.append(pci_addr + "-> pci_id") + + # PCI Config Space Check + if process.system("lspci -xxxx -s %s" % pci_addr, + ignore_status=True, sudo=True): + error.append(pci_addr + "->pci_config_space") + + if error: + self.fail("Errors for above pci addresses: %s" % error) + + @skipIf(IS_KVM_GUEST, "This test is not supported on KVM guest platform") + def test_pci_lscfg(self): + ''' + Capture data from lscfg and lspci then compare data + ''' + error = [] + for pci_addr in pci.get_pci_addresses(): + self.log.info("Checking for PCI Address: %s\n\n", pci_addr) + pci_info_dict = pci.get_pci_info(pci_addr) + self.log.info(pci_info_dict) + cfg_output = pci.get_cfg(pci_addr) + self.log.info(cfg_output) + if cfg_output and pci_info_dict: + if 'YL' in cfg_output and 'PhySlot' in pci_info_dict: + # Physical Slot Match + self.log.info("Physical Slot from lscfg is %s" + " and lspci is %s", + cfg_output['YL'], pci_info_dict['PhySlot']) + cfg_output['YL'] = \ + cfg_output['YL'][:cfg_output['YL'].rfind('-')] + if (cfg_output['YL'] == pci_info_dict['PhySlot']): + self.log.info("Physical Slot matched") + else: + error.append("Physical slot info didn't match") + # Sub Device ID match + if ('subvendor_device' in cfg_output and + 'SDevice' in pci_info_dict): + self.log.info("Device iD from lscfg is %s" + " and lspci is %s", + cfg_output['subvendor_device'][4:], + pci_info_dict['SDevice']) + if (cfg_output['subvendor_device'][4:] + == pci_info_dict['SDevice']): + self.log.info("Sub Device ID matched") + else: + error.append("Device ID info didn't match") + # Subvendor ID Match + if ('subvendor_device' in cfg_output and + 'SVendor' in pci_info_dict): + self.log.info("Subvendor ID from lscfg is %s" + "and lspci is %s", + cfg_output['subvendor_device'], + pci_info_dict['SVendor']) + if (cfg_output['subvendor_device'][0:4] == + pci_info_dict['SVendor']): + self.log.info("Sub vendor ID matched") + else: + error.append("Sub vendor ID didn't match") + # PCI Slot ID Match + if 'pci_id' in cfg_output and 'Slot' in pci_info_dict: + self.log.info("PCI ID from lscfg is %s and lspci is %s", + cfg_output['pci_id'], pci_info_dict['Slot']) + if (cfg_output['pci_id'] == + pci_info_dict['Slot']): + self.log.info("PCI Slot ID matched") + else: + error.append("PCI slot ID didn't match") + # PCI Config Space Check + if process.system(f"lspci -xxxx -s {pci_addr}", + sudo=True): + error.append(pci_addr + " : pci_config_space") + if error: + self.fail(f"Errors for above pci addresses: {error}")