Skip to content

Commit 42f6483

Browse files
authored
Merge pull request #825 from PraveenPenguin/fix_suse_gcov
Fix suse gcov
2 parents 89a5010 + 16e87ec commit 42f6483

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

common/OpTestUtil.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -2274,15 +2274,16 @@ def get_distro_version(self):
22742274
res = self.get_distro_details()
22752275
return res.get('VERSION_ID')[0].strip("\"")
22762276

2277-
def get_distro_src(self, package, dest_path, build_option=None):
2277+
def get_distro_src(self, package, dest_path, build_option=None, pack_dir=None):
22782278

22792279
'''
22802280
Downloads the source package and prepares it in the given dest_path
22812281
to be ready to build.
22822282
22832283
:param package: name of the package
22842284
:param dest_path: destination_path
2285-
:param build_option : rpmbuild option
2285+
:param build_option : rpmbuild option
2286+
:param pack_dir: final pakage dir in case of sles
22862287
:return path: build directory
22872288
'''
22882289
if dest_path is None:
@@ -2314,21 +2315,22 @@ def get_distro_src(self, package, dest_path, build_option=None):
23142315
return ""
23152316

23162317
elif self.distro_name() == 'sles':
2317-
host.host_run_command("zypper install rpm-build -y")
2318-
s_cmd = f"zypper -n source-install {package}"
2318+
host.host_run_command("zypper install -y rpm-build")
2319+
s_cmd = f"zypper -n source-install {package};cd /usr/src/packages/SOURCES/;./mkspec;cp {package}.spec ../SPECS/"
23192320
if host.host_run_command(s_cmd):
2321+
23202322
spec_path = f"/usr/src/packages/SPECS/{package}.spec"
23212323
else:
23222324
spec_path = None
23232325
if spec_path:
2324-
return self.prepare_source(spec_path,host, dest_path, package, build_option)
2326+
return self.prepare_source(spec_path,host, dest_path, package, build_option, 'sles', pack_dir)
23252327
else:
23262328
log.error("Failed to install distro package")
23272329
else:
23282330
return ""
23292331

23302332

2331-
def prepare_source(self,spec_file, host, dest_path, package, build_option=None):
2333+
def prepare_source(self,spec_file, host, dest_path, package, build_option=None, distro=None, pack_dir=None):
23322334
"""
23332335
Rpmbuild the spec path and return build dir
23342336
@@ -2344,7 +2346,10 @@ def prepare_source(self,spec_file, host, dest_path, package, build_option=None):
23442346
build_option += f" --define '_builddir {dest_path}'"
23452347
try:
23462348
host.host_run_command(f"rpmbuild {build_option} {spec_file}")
2347-
return host.host_run_command(f"ls -d -- {dest_path}/* | grep {package}")[0]
2349+
dir_name = host.host_run_command(f"ls -d -- {dest_path}/* | grep {package}")[0]
2350+
if distro is not None:
2351+
dir_name = host.host_run_command(f"ls -d -- {dir_name}/* | grep linux")[0]
2352+
return dir_name
23482353
except OpTestError:
23492354
return ""
23502355

testcases/GcovSetup.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ def runTest(self):
6464
self.installer = "yum install"
6565
elif self.distro_name == 'sles':
6666
self.installer = "zypper install"
67-
dep_packages = ["rpm-build", "yum-utils", "gcc*", "perl*", "tiny*"]
67+
dep_packages = ["rpm-build", "gcc*", "perl*", "tiny*"]
6868
log.info(f"\nInstalling following dependency packages\n {dep_packages}")
6969
for pkg in dep_packages:
70-
self.cv_HOST.host_run_command(f"{self.installer} {pkg} -y")
70+
if self.distro_name == 'rhel':
71+
dep_packages.append("yum-utils")
72+
self.cv_HOST.host_run_command(f"{self.installer} {pkg} -y")
73+
elif self.distro_name == 'sles':
74+
self.cv_HOST.host_run_command(f"{self.installer} -y {pkg}")
7175
log.info("\nInstalling the ditro src...")
7276
if self.distro_name == 'rhel':
7377
src_path = self.util.get_distro_src('kernel', '/root', "-bp")
7478
elif self.distro_name == 'sles':
75-
src_path = self.util.get_distro_src('kernel-default', '/root', "-bp")
79+
src_path = self.util.get_distro_src('kernel-default', '/root', "-bp", "linux")
7680
src_path_base = src_path
7781
out = self.cv_HOST.host_run_command(f"ls {src_path}")
7882
for line in out:
@@ -154,6 +158,8 @@ def add_gcov_param(self, conf_file):
154158
log.info("param failed to change {param}")
155159
err_param.append(param)
156160
log.info("\n\n\n")
161+
if self.distro_name == 'sles':
162+
self.cv_HOST.host_run_command(f"sed -i 's/^.*CONFIG_SYSTEM_TRUSTED_KEYS/#&/g' {conf_file}")
157163
if err_param:
158164
self.fail("few param did not got updated: %s" %err_param)
159165

0 commit comments

Comments
 (0)