import sys
import traceback
+import snapdiff
+import retracediff
+
def good():
'''Tell git-bisect that this commit is good.'''
'-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='^.*$',
# implementation is usable, and is the right one (i.e., we didn't fallback
# to a different OpenGL implementation due to missing symbols).
if platform.system() != 'Windows' and which('glxinfo'):
- p = subprocess.Popen(['glxinfo'], stdout=subprocess.PIPE)
- stdout, stderr = p.communicate()
- if p.returncode:
+ glxinfo = subprocess.Popen(['glxinfo'], stdout=subprocess.PIPE)
+ stdout, stderr = glxinfo.communicate()
+ if glxinfo.returncode:
skip()
# Search for the GL_RENDERER string
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.
skip()
# Run glretrace
- retrace = [options.retrace] + args
- sys.stdout.write(' '.join(retrace) + '\n')
- sys.stdout.flush()
- returncode = subprocess.call(retrace)
- if returncode:
- # TODO: allow other criterias here, such as, snapshot comparison or performance threshold
- bad()
+
+ retracer = retracediff.Retracer(options.retrace, args)
+
+ if options.compare_prefix:
+ refImages = {}
+ callNos = []
+
+ images = snapdiff.find_images(options.compare_prefix)
+ images.sort()
+ for image in images:
+ imageName, ext = os.path.splitext(image)
+ try:
+ callNo = int(imageName)
+ except ValueError:
+ continue
+ refImages[callNo] = options.compare_prefix + image
+ callNos.append(callNo)
+
+ run = retracer.snapshot(','.join(map(str, callNos)))
+ while True:
+ srcImage, callNo = run.nextSnapshot()
+ if srcImage is None:
+ break
+
+ refImage = refImages[callNo]
+
+ # Compare the two images
+ comparer = snapdiff.Comparer(refImage, srcImage)
+ precision = comparer.precision()
+
+ mismatch = precision < options.precision_threshold
+ if mismatch:
+ bad()
+ run.process.wait()
+ if run.process.returncode:
+ skip()
+ else:
+ returncode = retracer.retrace('-b')
+ if returncode:
+ bad()
+
+ # TODO: allow more criterias here, such as, performance threshold
# Success
good()