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
37 changes: 17 additions & 20 deletions perf/perf_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import re
import tempfile
from avocado import Test
from avocado.utils import process, distro, dmesg
from avocado.utils.software_manager.manager import SoftwareManager
from avocado.utils import process, dmesg
from avocado.utils.software_manager.distro_packages import ensure_tool


class PerfBasic(Test):
Expand Down Expand Up @@ -59,28 +59,25 @@ def run_cmd(self, cmd, verbose=True):
'Segmentation fault'])

def setUp(self):
smg = SoftwareManager()
dist = distro.detect()
if dist.name in ['Ubuntu']:
linux_tools = "linux-tools-" + os.uname()[2]
pkgs = [linux_tools]
if dist.name in ['Ubuntu']:
pkgs.extend(['linux-tools-common'])
elif dist.name in ['debian']:
pkgs = ['linux-perf']
elif dist.name in ['centos', 'fedora', 'rhel', 'SuSE']:
pkgs = ['perf']
else:
self.cancel("perf is not supported on %s" % dist.name)
perf_path = self.params.get('perf_bin', default='')
distro_pkg_map = {
"Ubuntu": [f"linux-tools-{os.uname()[2]}", "linux-tools-common", "gcc", "make"],
"debian": ["linux-perf"],
"centos": ["perf"],
"fedora": ["perf"],
"rhel": ["perf"],
"SuSE": ["perf"],
}
try:
perf_version = ensure_tool("perf", custom_path=perf_path, distro_pkg_map=distro_pkg_map)
self.log.info(f"Perf version: {perf_version}")
self.perf_bin = perf_path if perf_path else "perf"
except RuntimeError as e:
self.cancel(str(e))

self.temp_file = tempfile.NamedTemporaryFile().name
dmesg.clear_dmesg()

for pkg in pkgs:
if not smg.check_installed(pkg) and not smg.install(pkg):
self.cancel(
"Package %s is missing/could not be installed" % pkg)

def test_perf_help(self):
self.run_cmd("perf --help", False)

Expand Down
1 change: 1 addition & 0 deletions perf/perf_basic.py.data/perf_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perf_bin: '/tmp/perf'
36 changes: 18 additions & 18 deletions perf/perf_duplicate_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# Copyright: 2019 IBM
# Author: Shirisha G <shiganta@in.ibm.com>

import platform
import os
from avocado import Test
from avocado.utils import distro, genio, process
from avocado.utils.software_manager.manager import SoftwareManager
from avocado.utils import process, genio
from avocado.utils.software_manager.distro_packages import ensure_tool


class PerfDuplicateProbe(Test):
Expand All @@ -27,21 +27,21 @@ def setUp(self):
Install the basic packages to support perf and systemtap-sdt-devel
'''
# Check for basic utilities
smm = SoftwareManager()
distro_name = distro.detect().name
deps = []
run_type = self.params.get('type', default='distro')
if 'Ubuntu' in distro_name:
deps.extend(['linux-tools-common', 'linux-tools-%s' %
platform.uname()[2]])
elif distro_name in ['rhel', 'SuSE', 'fedora', 'centos']:
deps.extend(['perf'])
else:
self.cancel("Install the package for perf supported\
by %s" % distro_name)
for package in deps:
if not smm.check_installed(package) and not smm.install(package):
self.cancel('%s is needed for the test to be run' % package)
perf_path = self.params.get('perf_bin', default='')
distro_pkg_map = {
"Ubuntu": [f"linux-tools-{os.uname()[2]}", "linux-tools-common", "gcc", "make"],
"debian": ["linux-perf"],
"centos": ["perf"],
"fedora": ["perf"],
"rhel": ["perf"],
"SuSE": ["perf"],
}
try:
perf_version = ensure_tool("perf", custom_path=perf_path, distro_pkg_map=distro_pkg_map)
self.log.info(f"Perf version: {perf_version}")
self.perf_bin = perf_path if perf_path else "perf"
except RuntimeError as e:
self.cancel(str(e))
self.fail_flag = False

def _check_duplicate_probe(self, outpt):
Expand Down
1 change: 1 addition & 0 deletions perf/perf_duplicate_probe.py.data/perf_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perf_bin: '/tmp/perf'
35 changes: 17 additions & 18 deletions perf/perf_events_crash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# Author:Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
#

import platform
import os
from avocado import Test
from avocado.utils import archive, build, process, distro
from avocado.utils.software_manager.manager import SoftwareManager
from avocado.utils import archive, build, process
from avocado.utils.software_manager.distro_packages import ensure_tool


class Perf_crashevent(Test):
Expand All @@ -40,21 +39,21 @@ def setUp(self):
Install the packages
'''
# Check for basic utilities
smm = SoftwareManager()
detected_distro = distro.detect()
deps = ['gcc', 'make']
if 'Ubuntu' in detected_distro.name:
kernel_ver = platform.uname()[2]
deps.extend(['linux-tools-common', 'linux-tools-%s'
% kernel_ver])
elif detected_distro.name in ['rhel', 'SuSE', 'fedora']:
deps.extend(['perf'])
else:
self.cancel("Install the package for perf supported by %s"
% detected_distro.name)
for package in deps:
if not smm.check_installed(package) and not smm.install(package):
self.cancel('%s is needed for the test to be run' % package)
perf_path = self.params.get('perf_bin', default='')
distro_pkg_map = {
"Ubuntu": [f"linux-tools-{os.uname()[2]}", "linux-tools-common", "gcc", "make"],
"debian": ["linux-perf", "gcc", "make"],
"centos": ["perf", "gcc", "make", "gcc-c++"],
"fedora": ["perf", "gcc", "make", "gcc-c++"],
"rhel": ["perf", "gcc", "make", "gcc-c++"],
"SuSE": ["perf", "gcc", "make", "gcc-c++"],
}
try:
perf_version = ensure_tool("perf", custom_path=perf_path, distro_pkg_map=distro_pkg_map)
self.log.info(f"Perf version: {perf_version}")
self.perf_bin = perf_path if perf_path else "perf"
except RuntimeError as e:
self.cancel(str(e))

def build_perf_test(self):
"""
Expand Down
1 change: 1 addition & 0 deletions perf/perf_events_crash_test.py.data/perf_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perf_bin: '/tmp/perf'
39 changes: 17 additions & 22 deletions perf/perf_events_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# Author:Shriya Kulkarni <shriyak@linux.vnet.ibm.com>
#

import platform
import os
from avocado import Test
from avocado.utils import archive, build, process, distro, genio
from avocado.utils.software_manager.manager import SoftwareManager
from avocado.utils import archive, build, process, genio
from avocado.utils.software_manager.distro_packages import ensure_tool


class Perf_subsystem(Test):

"""
This series of test is meant to validate
that the perf_event subsystem is working
Expand All @@ -39,24 +37,21 @@ def setUp(self):
Install the packages
'''
# Check for basic utilities
smm = SoftwareManager()
detected_distro = distro.detect()
deps = ['gcc', 'make']
if 'Ubuntu' in detected_distro.name:
kernel_ver = platform.uname()[2]
deps.extend(['linux-tools-common', 'linux-tools-%s'
% kernel_ver])
elif 'debian' in detected_distro.name:
kernel_ver = platform.uname()[2][3]
deps.extend(['linux-tools-%s' % kernel_ver])
elif detected_distro.name in ['rhel', 'SuSE', 'fedora']:
deps.extend(['perf'])
else:
self.cancel("Install the package for perf supported by %s"
% detected_distro.name)
for package in deps:
if not smm.check_installed(package) and not smm.install(package):
self.cancel('%s is needed for the test to be run' % package)
perf_path = self.params.get('perf_bin', default='')
distro_pkg_map = {
"Ubuntu": [f"linux-tools-{os.uname()[2]}", "linux-tools-common", "gcc", "make"],
"debian": ["linux-perf", "gcc", "make"],
"centos": ["perf", "gcc", "make", "gcc-c++"],
"fedora": ["perf", "gcc", "make", "gcc-c++"],
"rhel": ["perf", "gcc", "make", "gcc-c++"],
"SuSE": ["perf", "gcc", "make", "gcc-c++"],
}
try:
perf_version = ensure_tool("perf", custom_path=perf_path, distro_pkg_map=distro_pkg_map)
self.log.info(f"Perf version: {perf_version}")
self.perf_bin = perf_path if perf_path else "perf"
except RuntimeError as e:
self.cancel(str(e))

def build_perf_test(self):
"""
Expand Down
1 change: 1 addition & 0 deletions perf/perf_events_test.py.data/perf_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perf_bin: '/tmp/perf'
40 changes: 22 additions & 18 deletions perf/perf_script_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
# Author: Shirisha <shiganta@in.ibm.com>

import os
import platform
import tempfile
import shutil
import configparser
from avocado import Test
from avocado.utils import build, distro, process
from avocado.utils.software_manager.manager import SoftwareManager
from avocado.utils import build, process, distro
from avocado.utils.software_manager.distro_packages import ensure_tool


class PerfScript(Test):
Expand All @@ -31,24 +30,29 @@ def setUp(self):
Install the basic packages to support PerfProbe test
'''
# Check for basic utilities
smm = SoftwareManager()
detected_distro = distro.detect()
perf_path = self.params.get('perf_bin', default='')
parser = configparser.ConfigParser()
parser.read(self.get_data('probe.cfg'))
self.perf_probe = parser.get(detected_distro.name, 'probepoint')
deps = ['gcc', 'make']
if detected_distro.name in ['rhel', 'SuSE', 'fedora', 'centos']:
deps.extend(['perf'])
elif detected_distro.name in ['Ubuntu']:
deps.extend(['linux-tools-common', 'linux-tools-%s' %
platform.uname()[2]])
# self.perf_probe = parser.get(detected_distro.name, 'probepoint')
distro_pkg_map = {
"Ubuntu": [f"linux-tools-{os.uname()[2]}", "linux-tools-common", "gcc", "make"],
"debian": ["linux-perf", "gcc", "make"],
"centos": ["perf", "gcc", "make", "gcc-c++"],
"fedora": ["perf", "gcc", "make", "gcc-c++"],
"rhel": ["perf", "gcc", "make", "gcc-c++"],
"SuSE": ["perf", "gcc", "make", "gcc-c++"],
}
try:
perf_version = ensure_tool("perf", custom_path=perf_path, distro_pkg_map=distro_pkg_map)
self.log.info(f"Perf version: {perf_version}")
self.perf_bin = perf_path if perf_path else "perf"
except RuntimeError as e:
self.cancel(str(e))
dist_name = distro.detect().name
if parser.has_section(dist_name):
self.perf_probe = parser.get(dist_name, 'probepoint')
else:
self.cancel("Install the package perf\
for %s" % detected_distro.name)
for package in deps:
if not smm.check_installed(package) and not smm.install(package):
self.cancel('%s is needed for the test to be run' % package)

self.perf_probe = parser.get('Ubuntu', 'probepoint')
shutil.copyfile(self.get_data('perf_test.c'),
os.path.join(self.teststmpdir, 'perf_test.c'))
shutil.copyfile(self.get_data('Makefile'),
Expand Down
1 change: 1 addition & 0 deletions perf/perf_script_bug.py.data/perf_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perf_bin: '/tmp/perf'
34 changes: 20 additions & 14 deletions perf/perfmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import os

from avocado import Test
from avocado.utils import process, build, git, distro
from avocado.utils.software_manager.manager import SoftwareManager
from avocado.utils import process, build, git
from avocado.utils.software_manager.distro_packages import ensure_tool


class Perfmon(Test):
Expand All @@ -32,18 +32,24 @@ class Perfmon(Test):
def setUp(self):

# Check for basic utilities
smm = SoftwareManager()
dist = distro.detect()

deps = ["gcc", "make"]
if dist.name in ['Ubuntu', 'debian']:
deps.extend(['libncurses-dev'])
elif dist.name in ['rhel', 'SuSE']:
deps.extend(['ncurses-devel'])
for package in deps:
if not smm.check_installed(package) and not smm.install(package):
self.cancel(
"Fail to install %s required for this test." % package)
perf_path = self.params.get('perf_bin', default='')

# Define distro-aware package map for build deps
distro_pkg_map = {
"Ubuntu": ["libncurses-dev", "gcc", "make"],
"debian": ["libncurses-dev", "gcc", "make"],
"centos": ["ncurses-devel", "gcc", "make"],
"fedora": ["ncurses-devel", "gcc", "make"],
"rhel": ["ncurses-devel", "gcc", "make"],
"SuSE": ["ncurses-devel", "gcc", "make"],
}

try:
# Ensure toolchain and ncurses dev packages are present
ensure_tool("gcc", distro_pkg_map=distro_pkg_map)
ensure_tool("make", distro_pkg_map=distro_pkg_map)
except RuntimeError as e:
self.cancel(str(e))

git.get_repo('https://git.code.sf.net/p/perfmon2/libpfm4',
destination_dir=self.workdir)
Expand Down
1 change: 1 addition & 0 deletions perf/perfmon.py.data/perf_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perf_bin: '/tmp/perf'
Loading
Loading