def get_slaves(self, _subpkg): checked_masters = self._get_checked_masters() self._document("Checking slaves for masters:" " {}".format(" and ".join( tu.replace_archs_with_general_arch( checked_masters, self._get_arch())))) masters = mexe.DefaultMock().get_masters() clean_slaves = [] for m in checked_masters: if m not in masters: continue try: slaves = mexe.DefaultMock().get_slaves(m) except mexc.MockExecutionException: self.binaries_test.log( "No relevant slaves were present for " + _subpkg + ".", vc.Verbosity.TEST) continue self.binaries_test.log( "Found slaves for {}: {}".format(_subpkg, str(slaves)), vc.Verbosity.TEST) if m in [tc.JAVA, tc.JAVAC]: clean_slaves.append(m) # skipping manpage slaves for slave in slaves: if not slave.endswith("1.gz"): clean_slaves.append(slave) return clean_slaves
def _get_all_binaries_and_slaves(self, pkgs): mexe.DefaultMock().provideCleanUsefullRoot() original_binaries = mexe.DefaultMock().execute_ls(tc.USR_BIN)[0].split("\n") installed_binaries, installed_slaves = super()._get_all_binaries_and_slaves(pkgs) installed_binaries = self._remove_links_from_usr_bin(installed_binaries) for subpackage in installed_binaries.keys(): all_binaries = installed_binaries[subpackage] installed_binaries[subpackage] = tu.two_lists_diff(all_binaries, original_binaries) settings = tc.ITWEB_SETTINGS bins = [] for b in installed_binaries[tc.DEFAULT]: bins.append(b.replace(".itweb", "")) installed_binaries[tc.DEFAULT] = bins try: installed_binaries[tc.DEFAULT].append(tc.CONTROL_PANEL) tu.passed_or_failed(self, True, "") except ValueError: tu.passed_or_failed(self, False, settings + " binary not in " + tc.DEFAULT + " subpackage") return installed_binaries, installed_slaves
def _check_ghosts_per_file(self, file): rpm_ghosts = self._get_actual_ghosts(file) default_masters = set(mexe.DefaultMock().get_default_masters()) mexe.DefaultMock().postinstall_exception_checked("rpms/" + file) if rc.RuntimeConfig().getRpmList().is_system_jdk(): actual_ghosts = set( mexe.DefaultMock().get_masters()).difference(default_masters) else: actual_ghosts = set() resolved_rpm_ghosts = set() resolved_actual_ghosts = {} for ghost in rpm_ghosts: newghost = ghost.replace("\n", "") resolved_rpm_ghosts.add(tu.resolve_link(newghost)) for ghost in actual_ghosts: resolved_actual_ghosts[(tu.resolve_link( mexe.DefaultMock().get_target(ghost)))] = ghost for ghost in self._get_hardcoded_ghosts(file): resolved_actual_ghosts[ghost] = "hardcoded" if not tu.passed_or_failed( self, set(resolved_actual_ghosts.keys()) == resolved_rpm_ghosts, "Sets of ghost are not correct for " + file + ". Differences will follow."): missing_ghosts = set( resolved_actual_ghosts.keys()).difference(resolved_rpm_ghosts) extra_ghosts = resolved_rpm_ghosts.difference( set(resolved_actual_ghosts.keys())) missing_ghosts_masters = [] for ghost in missing_ghosts: missing_ghosts_masters.append(ghost) if len(missing_ghosts) > 0: tu.passed_or_failed( self, False, "Masters not ghosted via %ghost declaration in specfile: " + str(missing_ghosts_masters)) if len(extra_ghosts) > 0: tu.passed_or_failed( self, False, "Ghosts that do not ghost any alternatives: " + str(extra_ghosts))
def _get_all_binaries_and_slaves(self, pkgs): for pkg in pkgs: name = os.path.basename(pkg) _subpkg = tu.rename_default_subpkg( pkgsplit.get_subpackage_only(name)) if _subpkg in tc.subpackages_without_alternatives( ) + tc.get_javadoc_dirs(): self.binaries_test.log("Skipping binaries extraction for " + _subpkg) self.skipped.append(_subpkg) continue if not mexe.DefaultMock().postinstall_exception_checked(pkg): self.binaries_test.log( "Failed to execute postinstall. Slaves will not be found for " + _subpkg) binary_directory_path = self._get_binary_directory_path(name) binaries = mexe.DefaultMock().execute_ls(binary_directory_path) if binaries[1] != 0: self.binaries_test.log( "Location {} does not exist, binaries test skipped " "for ".format(binary_directory_path) + name, vc.Verbosity.TEST) continue else: self.binaries_test.log( "Binaries found at {}: {}".format( binary_directory_path, ", ".join(binaries[0].split("\n"))), vc.Verbosity.TEST) slaves = self.get_slaves(_subpkg) self.installed_slaves[_subpkg] = slaves self.installed_binaries[_subpkg] = binaries[0].split("\n") return self.installed_binaries, self.installed_slaves
def _get_extra_bins(self, plugin_bin_content): ls = mexe.DefaultMock().execute_ls(self._itw_plugin_bin_location()) if ls[1] != 0: raise NotADirectoryError("dir not found") plugin_bin = list(set(ls[0].split("\n")) - set(plugin_bin_content)) return plugin_bin
def man_page_test(self, pkgs): self._document("Every binary must have a man page. If binary has a slave, then man page has also its slave." " \n - Man pages are in {} directory.".format(tc.MAN_DIR)) bins = {} manpages_without_postscript = {} manpages_with_postscript = {} mexe.DefaultMock().provideCleanUsefullRoot() default_mans = mexe.DefaultMock().execute_ls(tc.MAN_DIR)[0].split("\n") usr_bin_content = mexe.DefaultMock().execute_ls("/usr/bin")[0].split("\n") plugin_bin_content = mexe.DefaultMock().execute_ls(self._itw_plugin_bin_location())[0].split("\n") for pkg in pkgs: name = os.path.basename(pkg) _subpkg = tu.rename_default_subpkg(pkgsplit.get_subpackage_only(name)) # expects binaries are only in devel/default/headless subpackage, is consistent with binaries test if _subpkg not in self._get_subpackages(): continue # first check links if not mexe.DefaultMock().postinstall_exception_checked(pkg): self.skipped.append(_subpkg) continue masters = mexe.DefaultMock().get_masters() checked_masters = self._get_checked_masters() for m in masters: if m not in checked_masters: continue tg = self._get_target(m) binaries = mexe.DefaultMock().execute_ls(tg)[0].split("\n") binaries = self._clean_up_binaries(binaries, m, usr_bin_content) binaries = self._remove_java_rmi_cgi(binaries) binaries = self._remove_excludes(binaries) try: plugin_binaries = self._get_extra_bins(plugin_bin_content) except NotADirectoryError: tu.passed_or_failed(self, False, "/usr/bin directory not found, this is unexpected " "behaviour and the test will not be executed.") return ManpageTests.instance.log("Binaries found for {}: ".format(tg) + ", ".join(binaries + plugin_binaries)) bins[_subpkg] = copy.deepcopy(binaries + plugin_binaries) # check links manpages = self._clean_default_mpges(default_mans, mexe.DefaultMock().execute_ls(tc.MAN_DIR)[0].split("\n")) if len(manpages) != 0: manpages_with_postscript[_subpkg] = manpages ManpageTests.instance.log("Manpages found: " + ", ".join(manpages)) else: ManpageTests.instance.log("Warning: {} subpackage does not contain any binaries".format(_subpkg)) # then check files mexe.DefaultMock().importRpm(pkg) manpages_without_postscript[_subpkg] = self._clean_default_mpges(default_mans, mexe.DefaultMock().execute_ls(tc.MAN_DIR)[0] .split("\n")) try: bins = self._clean_sdk_from_jre(bins, self._get_subpackages()) bins = self.binaries_without_manpages(bins) except KeyError as e: tu.passed_or_failed(self, False, "This type of failure usually means missing package in tested rpm set." " Text of the error: " + str(e)) # then compare man files with binaries and man links with links for subpackage in bins.keys(): manpage_files = self.manpage_file_check(bins, subpackage, plugin_bin_content, manpages_without_postscript) self.manpage_links_check(bins, subpackage, manpages_with_postscript, manpage_files) self.iced_tea_web_check(manpages_with_postscript, manpages_without_postscript) ManpageTests.instance.log("Failed tests summary: " + ", ".join(self.list_of_failed_tests), vc.Verbosity.ERROR) return self.passed, self.failed
def _get_target(self, master): return mexe.DefaultMock().get_target(master).strip(master)
def check_file_existence(self, file): out, res = me.DefaultMock().execute_ls(file) return res == 0
def resolve_link(link): out = mexe.DefaultMock().executeCommand(["readlink", link]) newlink = out[0].replace("\n", "") if newlink == "": return link return resolve_link(newlink)