Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions ras/ras_lsvpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,76 @@ def test_pci_lscfg(self):
error.append(pci_addr + " : pci_config_space")
if error:
self.fail(f"Errors for above pci addresses: {error}")

def test_spyre_lsvpd_validation(self):
if process.system("vpdupdate", ignore_status=True, shell=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation messed up.. please fix it

self.fail("vpdupate failed")

spyre_devices = []
for dev in os.listdir('/sys/bus/pci/devices'):
cls = f"/sys/bus/pci/devices/{dev}/class"
try:
with open(cls) as f:
if f.read().strip().startswith('0x1200'):
spyre_devices.append(dev)
except Exception:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse the avocado utils get_pci_class method

pass

if not spyre_devices:
self.cancel("Spyre accelerator not present")

lsvpd_out = self.run_cmd_out("lsvpd").upper()
lscfg_out = self.run_cmd_out("lscfg -VP").upper()

for dev in spyre_devices:
sysfs_vendor = self.run_cmd_out(
f"cat /sys/bus/pci/devices/{dev}/vendor").strip()
sysfs_device = self.run_cmd_out(
f"cat /sys/bus/pci/devices/{dev}/device").strip()
sysfs_subvendor = self.run_cmd_out(
f"cat /sys/bus/pci/devices/{dev}/subsystem_vendor").strip()
sysfs_subdevice = self.run_cmd_out(
f"cat /sys/bus/pci/devices/{dev}/subsystem_device").strip()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reuse pci utils


location_code = None
for line in lscfg_out.splitlines():
if dev in line:
parts = line.split()
if len(parts) > 1:
location_code = parts[-1]
break

if not location_code:
self.fail(f"Unable to find location code for Spyre device {dev}")

spyre_block = []
capture = False
for line in lsvpd_out.splitlines():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent messed up

if location_code in line:
capture = True
if capture:
if line.strip() == "" and spyre_block:
break
spyre_block.append(line)

if not spyre_block:
self.fail(f"No lsvpd entry found for Spyre device {dev}")

spyre_lsvpd = "\n".join(spyre_block)

ccin_vpd = self._extract_vpd_value(spyre_lsvpd, 'CCIN')
fc_vpd = self._extract_vpd_value(spyre_lsvpd, 'FC')
ec_vpd = self._extract_vpd_value(spyre_lsvpd, 'EC')
fw_vpd = self._extract_vpd_value(spyre_lsvpd, 'FW')

if not ccin_vpd:
self.fail(f"CCIN missing in lsvpd for Spyre device {dev}")

if not fc_vpd:
self.fail(f"Invalid FC value for Spyre device {dev}")

if not ec_vpd:
self.fail(f"Invalid EC value for Spyre device {dev}")

if not fw_vpd:
self.fail(f"Firmware value missing for Spyre device {dev}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optimize .. may be loop ?

31 changes: 31 additions & 0 deletions ras/sosreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,34 @@ def test_fs(self):
if is_fail:
self.fail(
"%s command(s) failed in sosreport tool verification" % is_fail)

def test_spyre_external_plugin(self):
self.is_fail = 0
directory_name = tempfile.mkdtemp()
output = self.run_cmd_out("%s --batch --tmp-dir=%s -o spyre-external" % (self.sos_cmd, directory_name))

tar_file = None
for line in output.splitlines():
if 'tar.xz' in line or 'tar.gz' in line:
tar_file = line.strip()
break

if not tar_file or not os.path.exists(tar_file):
self.is_fail += 1
self.log.info("sosreport archive not generated for spyre-external")
else:
tar_list = self.run_cmd_out("tar -tf %s" % tar_file)
found = False
if 'spyre' in tar_list:
found = True

if not found:
self.is_fail += 1
self.log.info("spyre-external did not capture expected files")

os.remove(tar_file)

shutil.rmtree(directory_name)

if self.is_fail >= 1:
self.fail("%s command(s) failed in sosreport spyre-external verification" % self.is_fail)