From 2815190696ed46d13c53e6c6e81e8bf11d1bc4f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 14 May 2011 14:56:08 +0100 Subject: [PATCH] Add snapshot comparison criteria in tracecheck.py --- scripts/tracecheck.py | 47 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/scripts/tracecheck.py b/scripts/tracecheck.py index 28b0720..b5d6b76 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='12', + 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() -- 2.43.0