def localize_distrib(distrib_dir, executables): """Localize a Mac OS distribution by making adjusting library paths. Paths to libraries are made relative so that the distribution can be moved easily from one place to another. The change is done in place Note that we depends on an external tool called :file:`install_name_tool` :param distrib_dir: root directory of the distribution :type distrib_dir: str :param executables: list of relative path to the executables present in the distribution :type executables: list[str] """ # First we need to find the shared libraries present in our distribution dylib_list = find(distrib_dir, pattern="*.dylib") + \ find(distrib_dir, pattern="*.so") dylib_dict = {os.path.basename(k): k for k in dylib_list} # List of files to adjust (executables + shared libraries) for bin_file in dylib_list + \ [os.path.join(distrib_dir, e) for e in executables]: # Retrieve the list of dependencies for that file file_dylibs = get_dylib_deps(bin_file) for d in file_dylibs: base_d = os.path.basename(d) if base_d in dylib_dict: if base_d == 'libgcc_s.1.dylib': # On darwin, we absolutely want to pick the libgcc_s from # the system. shared libgcc_s from our compilers are # broken. Run([ 'install_name_tool', '-change', d, '/usr/lib/libgcc_s.1.dylib', bin_file ]) else: Run([ 'install_name_tool', '-change', d, '@loader_path/' + os.path.relpath( dylib_dict[base_d], os.path.dirname(bin_file)), bin_file ])
def load_all(self, root): """Load all data generate by a testsuite run. :param root: testsuite root directory :type root: str """ print "== Registering test execution dumps from %s ..." % root # all directories containing a tc.dump file are containing # test results/dumps for p in find(root, QUALDATA_FILE, follow_symlinks=True): self.load_test(os.path.dirname(p))
def load_all(self, root): """Load all data generated by a testsuite run. :param root: testsuite root directory :type root: str """ print "== Registering test execution dumps from %s ..." % root # Search for all directories containing a testcase status # dump file and load the data available there for p in find(root, STATUSDATA_FILE, follow_symlinks=True): self.load_test(os.path.dirname(p))
def dump_testsuite_result(self): """Dump testsuite result files. Dump the content of all <test>.yaml files and create report, result and comment files. """ testsuite_results = os.path.join(self.output_dir, 'results') testsuite_report = os.path.join(self.output_dir, 'report') testsuite_comment = os.path.join(self.output_dir, 'comment') with open(testsuite_comment, 'w') as f: self.write_comment_file(f) touch(testsuite_results) # Mapping: test status -> hits. Computed to display the testsuite run # summary. summary = collections.defaultdict(lambda: 0) for test_result in find(self.output_dir, '*.yaml'): if os.path.basename(test_result) != 'global_env.yaml': with open(test_result, "rb") as fd: tr_yaml = yaml.load(fd) if tr_yaml: # result in results file echo_to_file(testsuite_results, '%s:%s: %s\n' % (tr_yaml.test_env['test_name'], tr_yaml.status, tr_yaml.msg), append=True) tr_yaml.dump_result(self.output_dir) summary[tr_yaml.status] += 1 try: report = ReportDiff(self.output_dir, self.old_output_dir, use_diff=True) except: report = ReportDiff(self.output_dir, self.old_output_dir) report.txt_image(testsuite_report) summary_msg = ['Summary:'] for status in sorted(summary): hits = summary[status] summary_msg.append(' {}: {} test{}'.format( status, summary[status], 's' if hits > 1 else '')) logging.info('\n'.join(summary_msg))
def get_test_list(self, sublist): """Retrieve the list of tests. The default method looks for all test.yaml files in the test directory. If a test.yaml has a variants field, the test is expanded in several test, each test being associated with a given variant. This function may be overriden. At this stage the self.global_env (after update by the tear_up procedure) is available. :param sublist: a list of tests scenarios or patterns :type sublist: list[str] :return: the list of selected test :rtype: list[str] """ # First retrive the list of test.yaml files result = [ os.path.relpath(p, self.test_dir).replace('\\', '/') for p in find(self.test_dir, 'test.yaml') ] if sublist: filtered_result = [] path_selectors = [ os.path.relpath(os.path.abspath(s), self.test_dir).replace('\\', '/') for s in sublist ] for p in result: for s in path_selectors: if re.match(s, p): filtered_result.append(p) continue result = filtered_result # For each of them look for a variants field expanded_result = [] for test in result: test_env = load_with_config(os.path.join(self.test_dir, test), Env().to_dict()) if test_env and 'variants' in test_env: for variant in test_env['variants']: expanded_result.append("%s|%s" % (test, yaml.dump(variant))) else: expanded_result.append(test) return expanded_result
def build_tor (self): # If we have a local testsuite dir at hand and we haven't done so # already, fetch the testsresults that the QM needs to check TOR/TC # consistency: if self.local_testsuite_dir and self.passno == 1: os.chdir (self.local_testsuite_dir) def sync(relative): target_dir = os.path.join ( self.repodir, "testsuite", os.path.dirname (tr) ) if os.path.exists(target_dir): cp (relative, target_dir) else: print ("ERRRR !! inexistant target dir for %s" % relative) [sync(tr) for tr in find (root=".", pattern="tc.dump")] self.__qm_build (part="tor")
def workspace_file(): return ' '.join(fu.find(root="altrun", pattern="justrun.xjrf"))
def find_testcases(directory): """Find all testcases in the given directory.""" return set(sorted(find(directory, pattern='test.py') + find(directory, pattern='test.sh')))