Skip to content

Commit

Permalink
cpu/ppc64_cpu_test: Add upstream as a target
Browse files Browse the repository at this point in the history
Add capabilities to download and compile upstream source for
powerpc-utils tools(ppc64_cpu).

Signed-off-by: Sachin Sant <[email protected]>
  • Loading branch information
sacsant committed Apr 15, 2024
1 parent 5497e21 commit 2b27e24
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
51 changes: 48 additions & 3 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.sm = SoftwareManager()
if self.sm.check_installed("powerpc-utils") is False:
if self.sm.install("powerpc-utils") is False:
self.cancel("powerpc-utils is not installing")

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
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 2b27e24

Please sign in to comment.