diff --git a/common/OpTestUtil.py b/common/OpTestUtil.py index 03e2d567..02ae76b2 100644 --- a/common/OpTestUtil.py +++ b/common/OpTestUtil.py @@ -2274,7 +2274,7 @@ 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 @@ -2282,7 +2282,8 @@ def get_distro_src(self, package, dest_path, build_option=None): :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: @@ -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 @@ -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 "" diff --git a/testcases/GcovSetup.py b/testcases/GcovSetup.py index 5f1832a8..5a0886ff 100755 --- a/testcases/GcovSetup.py +++ b/testcases/GcovSetup.py @@ -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: @@ -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}") if err_param: self.fail("few param did not got updated: %s" %err_param)