Skip to content

Commit

Permalink
perf/perf_rawevents: enhance test to handle missing files and add sup…
Browse files Browse the repository at this point in the history
…port for P11

Modified `copy_files` method to handle cases where the source file
is `None` or does not exist. Simplified the retrieval of CPU revision
by using `cpu.get_revision()` instead of parsing `/proc/cpuinfo`.
Added support for testing Power11 revision `0082` by using Power10
files only since no event changes are there.

Signed-off-by: Disha Goel <[email protected]>
  • Loading branch information
disgoel committed Aug 6, 2024
1 parent f8d1883 commit d9ef3ce
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions perf/perf_rawevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@
import platform
import shutil
from avocado import Test
from avocado.utils import distro, process, genio
from avocado.utils import distro, process, genio, cpu
from avocado.utils.software_manager.manager import SoftwareManager


class PerfRawevents(Test):

"""
Tests raw events on Power8, Power9 and Power10 along with
Tests raw events on different Power platforms along with
named events
:avocado: tags=perf,rawevents,events
"""
# Initializing fail command list
fail_cmd = list()

def copy_files(self, filename):
shutil.copyfile(self.get_data(filename),
os.path.join(self.teststmpdir, filename))
src = self.get_data(filename)
if src is None or not os.path.isfile(src):
self.cancel(f'File {filename} not found.')
else:
shutil.copyfile(src, os.path.join(self.teststmpdir, filename))

def setUp(self):
'''
Expand All @@ -45,10 +48,7 @@ def setUp(self):
smm = SoftwareManager()
detected_distro = distro.detect()
self.distro_name = detected_distro.name
processor = genio.read_file("/proc/cpuinfo")
for line in processor.splitlines():
if 'revision' in line:
self.rev = (line.split(' ')[3].strip())
self.rev = cpu.get_revision()
if detected_distro.arch != 'ppc64le':
self.cancel('This test is not supported on %s architecture'
% detected_distro.arch)
Expand All @@ -67,9 +67,13 @@ def setUp(self):
if not smm.check_installed(package) and not smm.install(package):
self.cancel('%s is needed for the test to be run' % package)

for filename in ['name_events_004b', 'raw_codes_004b', 'name_events_004e',
'raw_codes_004e', 'name_events_0080', 'raw_codes_0080']:
self.copy_files(filename)
revisions_to_test = ['004b', '004e', '0080', '0082']
for rev in revisions_to_test:
for filename in [f'name_events_{rev}', f'raw_codes_{rev}']:
if rev == '0082':
# Use Power10 files for Power11
filename = filename.replace('0082', '0080')
self.copy_files(filename)

os.chdir(self.teststmpdir)
# Clear the dmesg to capture the delta at the end of the test.
Expand All @@ -91,13 +95,13 @@ def error_check(self):
self.fail("perf_raw_events: refer log file for failed events")

def test_raw_code(self):
file_name = 'raw_codes_' + self.rev
file_name = 'raw_codes_' + (self.rev if self.rev != '0082' else '0080')
perf_flags = "perf stat -e r"
self.run_event(file_name, perf_flags)
self.error_check()

def test_name_event(self):
file_name = 'name_events_' + self.rev
file_name = 'name_events_' + (self.rev if self.rev != '0082' else '0080')
perf_flags = "perf stat -e "
self.run_event(file_name, perf_flags)
self.error_check()
Expand Down

0 comments on commit d9ef3ce

Please sign in to comment.