Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix suse gcov #825

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
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 @@ -60,15 +60,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 @@ -150,6 +154,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}")
abdhaleegit marked this conversation as resolved.
Show resolved Hide resolved
if err_param:
self.fail("few param did not got updated: %s" %err_param)

Expand Down