Skip to content

Commit

Permalink
Merge pull request #825 from PraveenPenguin/fix_suse_gcov
Browse files Browse the repository at this point in the history
Fix suse gcov
  • Loading branch information
abdhaleegit authored Jun 6, 2024
2 parents 89a5010 + 16e87ec commit 42f6483
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
19 changes: 12 additions & 7 deletions common/OpTestUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2274,15 +2274,16 @@ def get_distro_version(self):
res = self.get_distro_details()
return res.get('VERSION_ID')[0].strip("\"")

def get_distro_src(self, package, dest_path, build_option=None):
def get_distro_src(self, package, dest_path, build_option=None, pack_dir=None):

'''
Downloads the source package and prepares it in the given dest_path
to be ready to build.
:param package: name of the package
:param dest_path: destination_path
:param build_option : rpmbuild option
:param build_option : rpmbuild option
:param pack_dir: final pakage dir in case of sles
:return path: build directory
'''
if dest_path is None:
Expand Down Expand Up @@ -2314,21 +2315,22 @@ def get_distro_src(self, package, dest_path, build_option=None):
return ""

elif self.distro_name() == 'sles':
host.host_run_command("zypper install rpm-build -y")
s_cmd = f"zypper -n source-install {package}"
host.host_run_command("zypper install -y rpm-build")
s_cmd = f"zypper -n source-install {package};cd /usr/src/packages/SOURCES/;./mkspec;cp {package}.spec ../SPECS/"
if host.host_run_command(s_cmd):

spec_path = f"/usr/src/packages/SPECS/{package}.spec"
else:
spec_path = None
if spec_path:
return self.prepare_source(spec_path,host, dest_path, package, build_option)
return self.prepare_source(spec_path,host, dest_path, package, build_option, 'sles', pack_dir)
else:
log.error("Failed to install distro package")
else:
return ""


def prepare_source(self,spec_file, host, dest_path, package, build_option=None):
def prepare_source(self,spec_file, host, dest_path, package, build_option=None, distro=None, pack_dir=None):
"""
Rpmbuild the spec path and return build dir
Expand All @@ -2344,7 +2346,10 @@ def prepare_source(self,spec_file, host, dest_path, package, build_option=None):
build_option += f" --define '_builddir {dest_path}'"
try:
host.host_run_command(f"rpmbuild {build_option} {spec_file}")
return host.host_run_command(f"ls -d -- {dest_path}/* | grep {package}")[0]
dir_name = host.host_run_command(f"ls -d -- {dest_path}/* | grep {package}")[0]
if distro is not None:
dir_name = host.host_run_command(f"ls -d -- {dir_name}/* | grep linux")[0]
return dir_name
except OpTestError:
return ""

Expand Down
12 changes: 9 additions & 3 deletions testcases/GcovSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ def runTest(self):
self.installer = "yum install"
elif self.distro_name == 'sles':
self.installer = "zypper install"
dep_packages = ["rpm-build", "yum-utils", "gcc*", "perl*", "tiny*"]
dep_packages = ["rpm-build", "gcc*", "perl*", "tiny*"]
log.info(f"\nInstalling following dependency packages\n {dep_packages}")
for pkg in dep_packages:
self.cv_HOST.host_run_command(f"{self.installer} {pkg} -y")
if self.distro_name == 'rhel':
dep_packages.append("yum-utils")
self.cv_HOST.host_run_command(f"{self.installer} {pkg} -y")
elif self.distro_name == 'sles':
self.cv_HOST.host_run_command(f"{self.installer} -y {pkg}")
log.info("\nInstalling the ditro src...")
if self.distro_name == 'rhel':
src_path = self.util.get_distro_src('kernel', '/root', "-bp")
elif self.distro_name == 'sles':
src_path = self.util.get_distro_src('kernel-default', '/root', "-bp")
src_path = self.util.get_distro_src('kernel-default', '/root', "-bp", "linux")
src_path_base = src_path
out = self.cv_HOST.host_run_command(f"ls {src_path}")
for line in out:
Expand Down Expand Up @@ -154,6 +158,8 @@ def add_gcov_param(self, conf_file):
log.info("param failed to change {param}")
err_param.append(param)
log.info("\n\n\n")
if self.distro_name == 'sles':
self.cv_HOST.host_run_command(f"sed -i 's/^.*CONFIG_SYSTEM_TRUSTED_KEYS/#&/g' {conf_file}")
if err_param:
self.fail("few param did not got updated: %s" %err_param)

Expand Down

0 comments on commit 42f6483

Please sign in to comment.