Skip to content

Commit

Permalink
Merge pull request avocado-framework-tests#2788 from sacsant/ppc64_cpu
Browse files Browse the repository at this point in the history
cpu/ppc64_cpu: single core plus smt and upstream as a target
  • Loading branch information
abdhaleegit authored May 6, 2024
2 parents ad6b5a2 + 19e4c14 commit c1a189e
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 4 deletions.
92 changes: 88 additions & 4 deletions cpu/ppc64_cpu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from avocado import Test
from avocado.utils import process
from avocado.utils import cpu
from avocado.utils import distro
from avocado.utils import distro, build, archive
from avocado.utils import genio
from avocado.utils.software_manager.manager import SoftwareManager
from math import ceil
Expand All @@ -41,11 +41,13 @@ def setUp(self):
"""
if 'ppc' not in distro.detect().arch:
self.cancel("Processor is not ppc64")
if SoftwareManager().check_installed("powerpc-utils") is False:
if SoftwareManager().install("powerpc-utils") is False:
self.cancel("powerpc-utils is not installing")
self.sm = SoftwareManager()
if not self.sm.check_installed("powerpc-utils"):
if not self.sm.install("powerpc-utils"):
self.cancel("Cannot install powerpc-utils, check the log!")

self.loop = int(self.params.get('test_loop', default=100))
self.run_type = self.params.get('type', default='distro')
self.smt_str = "ppc64_cpu --smt"
# Dynamically set max SMT specified at boot time
process.system("%s=on" % self.smt_str, shell=True)
Expand All @@ -67,6 +69,49 @@ def setUp(self):
self.value = ""
self.max_smt_value = int(self.curr_smt)

def test_build_upstream(self):
"""
For upstream target download and compile source code
Caution : This function will overwrite system installed
lsvpd Tool binaries with upstream code.
"""
if self.run_type == 'upstream':
self.detected_distro = distro.detect()
deps = ['gcc', 'make', 'automake', 'autoconf', 'bison', 'flex',
'libtool', 'zlib-devel', 'ncurses-devel', 'librtas-devel']
if 'SuSE' in self.detected_distro.name:
deps.extend(['libnuma-devel'])
elif self.detected_distro.name in ['centos', 'fedora', 'rhel']:
deps.extend(['numactl-devel'])
else:
self.cancel("Unsupported Linux distribution")
for package in deps:
if not self.sm.check_installed(package) and not \
self.sm.install(package):
self.cancel("Fail to install %s required for this test." %
package)
url = self.params.get(
'ppcutils_url', default='https://github.com/'
'ibm-power-utilities/powerpc-utils/archive/refs/heads/'
'master.zip')
tarball = self.fetch_asset('ppcutils.zip', locations=[url],
expire='7d')
archive.extract(tarball, self.workdir)
self.sourcedir = os.path.join(self.workdir, 'powerpc-utils-master')
os.chdir(self.sourcedir)
cmd_result = process.run('./autogen.sh', ignore_status=True,
sudo=True, shell=True)
if cmd_result.exit_status:
self.fail('Upstream build: Pre configure step failed')
cmd_result = process.run('./configure --prefix=/usr',
ignore_status=True, sudo=True, shell=True)
if cmd_result.exit_status:
self.fail('Upstream build: Configure step failed')
build.make(self.sourcedir)
build.make(self.sourcedir, extra_args='install')
else:
self.cancel("This test is supported with upstream as target")

def equality_check(self, test_name, cmd1, cmd2):
"""
Verifies if the output of 2 commands are same, and sets failure
Expand Down Expand Up @@ -165,6 +210,45 @@ def test_smt_loop(self):
shell=True):
self.fail('SMT loop test failed')

def test_single_core_smt(self):
"""
Test smt level change when single core is online. This
scenario was attempted to catch a regression.
ppc64_cpu --cores-on=all
ppc64_cpu —-smt=on
ppc64_cpu --cores-on=1
ppc64_cpu --cores-on
ppc64_cpu --smt=2
ppc64_cpu --smt=4
ppc64_cpu --cores-on
At this stage the number of online cores should be one.
If not fail the test case
"""
# online all cores
process.system("ppc64_cpu --cores-on=all", shell=True)
# Set highest SMT level
process.system("ppc64_cpu --smt=on", shell=True)
# online single core
process.system("ppc64_cpu --cores-on=1", shell=True)
# Record the output
cores_on = process.system_output("ppc64_cpu --cores-on",
shell=True).decode("utf-8")
op1 = cores_on.strip().split("=")[-1]
self.log.debug(op1)
# Set 2 threads online
process.system("ppc64_cpu --smt=2", shell=True)
# Set 4 threads online
process.system("ppc64_cpu --smt=4", shell=True)
# Record the output
cores_on = process.system_output("ppc64_cpu --cores-on",
shell=True).decode("utf-8")
op2 = cores_on.strip().split("=")[-1]
self.log.debug(op2)
if str(op1) != str(op2):
self.fail("SMT with Single core test failed")

def tearDown(self):
"""
Sets back SMT to original value as was before the test.
Expand Down
6 changes: 6 additions & 0 deletions cpu/ppc64_cpu_test.py.data/ppc64_cpu_test.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
test_loop : 10
run_type: !mux
upstream:
ppcutils_url: 'https://github.com/ibm-power-utilities/powerpc-utils/archive/refs/heads/master.zip'
type: 'upstream'
distro:
type: 'distro'

0 comments on commit c1a189e

Please sign in to comment.