X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=tests%2Fpdtest;h=d0717a8b8124fe9aea2e47ad0915909cf9602ec4;hp=088ad91cdf2b387ec8d0127da66f83fc9a1ae2a3;hb=1f6f2ad8c33e58cfd40ea0370e6d2dfbd6040026;hpb=d510f7b3d5d03c6fca5b6af4e184dc2f46da9a1a diff --git a/tests/pdtest b/tests/pdtest index 088ad91..d0717a8 100755 --- a/tests/pdtest +++ b/tests/pdtest @@ -309,7 +309,7 @@ def run_tests(tests, fix=False): pd_cvg = [] for tclist in tests[pd]: for tc in tclist: - args = cmd.copy() + args = cmd[:] if DEBUG > 1: args.append('-d') # Set up PD stack for this test. @@ -379,7 +379,7 @@ def run_tests(tests, fix=False): os.unlink(outfile) if op['type'] == 'exception' and 'error' in results[-1]: # filter out the exception we were looking for - reg = "^Error: srd: Protocol decoder instance %s: %s:" % (op['pd'], op['match']) + reg = "^Error: srd: %s:" % op['match'] if re.match(reg, results[-1]['error']): # found it, not an error results[-1].pop('error') @@ -409,14 +409,29 @@ def run_tests(tests, fix=False): for cvg in results[-1]['coverage']: if cvg['scope'] == pd: pd_cvg.append(cvg) - if VERBOSE and opt_coverage and len(pd_cvg) > 1: + if opt_coverage and len(pd_cvg) > 1: # report total coverage of this PD, across all the tests # that were done on it. total_lines, missed_lines = coverage_sum(pd_cvg) pd_coverage = 100 - (float(len(missed_lines)) / total_lines * 100) if VERBOSE: dots = '.' * (54 - len(pd) - 2) - INFO("%s total %s %d%%" % (pd, dots, pd_coverage)) + INFO("%s total %s %d%%" % (pd, dots, pd_coverage)) + if report_dir: + # generate a missing lines list across all the files in + # the PD + files = {} + for entry in missed_lines: + filename, line = entry.split(':') + if filename not in files: + files[filename] = [] + files[filename].append(line) + text = '' + for filename in sorted(files.keys()): + line_list = ','.join(sorted(files[filename], key=int)) + text += "%s: %s\n" % (filename, line_list) + open(os.path.join(report_dir, pd + "_total"), 'w').write(text) + return results, errors