X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scripts%2Ftracecheck.py;h=d204fa63dbfcbc7a7a6672b888cfea3caac35078;hb=3801952b80cd7a7160f6410518f6e3740d461b60;hp=28b0720fdd7cad6b3a7b0b2c5d7f63da04ebd57c;hpb=79631cd730bb0d01cd48ad713dd75ebbb1f41c9b;p=apitrace diff --git a/scripts/tracecheck.py b/scripts/tracecheck.py index 28b0720..d204fa6 100755 --- a/scripts/tracecheck.py +++ b/scripts/tracecheck.py @@ -110,6 +110,14 @@ def main(): '-r', '--retrace', metavar='PROGRAM', type='string', dest='retrace', default='glretrace', help='retrace command [default: %default]') + optparser.add_option( + '-c', '--compare', metavar='PREFIX', + type='string', dest='compare_prefix', default=None, + help='snapshot comparison prefix') + optparser.add_option( + '--precision-threshold', metavar='BITS', + type='float', dest='precision_threshold', default=8.0, + help='precision threshold in bits [default: %default]') optparser.add_option( '--gl-renderer', metavar='REGEXP', type='string', dest='gl_renderer_re', default='^.*$', @@ -145,6 +153,9 @@ def main(): for line in stdout.split('\n'): if line.startswith(gl_renderer_header): gl_renderer = line[len(gl_renderer_header):] + if line.startswith('direct rendering: No'): + sys.stderr.write('Indirect rendering.\n') + skip() # and match it against the regular expression specified in the command # line. @@ -153,13 +164,37 @@ def main(): skip() # Run glretrace - retrace = [options.retrace] + args - sys.stdout.write(' '.join(retrace) + '\n') + command = [options.retrace] + if options.compare_prefix: + command += ['-c', options.compare_prefix] + else: + command += ['-b'] + command += args + sys.stdout.write(' '.join(command) + '\n') sys.stdout.flush() - returncode = subprocess.call(retrace) - if returncode: - # TODO: allow other criterias here, such as, snapshot comparison or performance threshold - bad() + p = subprocess.Popen(command, stdout=subprocess.PIPE) + stdout, stderr = p.communicate() + if p.returncode: + if not options.compare_prefix: + bad() + else: + skip() + + if options.compare_prefix: + failed = False + precision_re = re.compile('^Snapshot (\S+) average precision of (\S+) bits$') + for line in stdout.split('\n'): + mo = precision_re.match(line) + if mo: + print line + call_no = int(mo.group(1)) + precision = float(mo.group(2)) + if precision < options.precision_threshold: + failed = True + if failed: + bad() + + # TODO: allow more criterias here, such as, performance threshold # Success good()