- p = popen(args, env=env, cwd=dirname)
- try:
- time.sleep(1)
-
- # http://stackoverflow.com/questions/151407/how-to-get-an-x11-window-from-a-process-id
- ref_image = os.path.join(options.results, demo.replace('/', '-') + '.ref.png')
- #subprocess.call(['xwininfo', '-root', '-tree'])
- subprocess.call("xwd -name '%s' | xwdtopnm | pnmtopng > '%s'" % (args[0], ref_image), shell=True)
-
- finally:
- os.kill(p.pid, signal.SIGTERM)
-
- p = popen([os.path.join(options.build, 'tracedump'), trace], stdout=subprocess.PIPE)
- stdout, _ = p.communicate()
-
- call_re = re.compile('^([0-9]+) (\w+)\(')
- double_buffer = False
- for orig_line in stdout.split('\n'):
- line = ansi_strip(orig_line)
- mo = call_re.match(line)
- if mo:
- call_no = int(mo.group(1))
- function_name = mo.group(2)
- if function_name in ignored_function_names:
- continue
- if function_name == 'glXSwapBuffers':
- double_buffer = True
- #print orig_line
-
- args = [os.path.join(options.build, 'glretrace')]
- if double_buffer:
- args += ['-db']
- else:
- args += ['-sb']
- snapshot_prefix = os.path.join(options.results, demo.replace('/', '-') + '.')
- args += ['-s', snapshot_prefix]
- args += [trace]
- p = popen(args, stdout=subprocess.PIPE)
- stdout, _ = p.communicate()
- image_re = re.compile('^Wrote (.*\.png)$')
- image = None
- for line in stdout.split('\n'):
- mo = image_re.match(line)
- if mo:
- image = mo.group(1)
-
- image_tag(html, ref_image)
- if image:
- delta_image = os.path.join(options.results, demo.replace('/', '-') + '.diff.png')
- p = popen(["compare", '-alpha', 'opaque', '-metric', 'AE', '-fuzz', '5%', ref_image, image, delta_image])
- _, stderr = p.communicate()
- image_tag(html, image)
- image_tag(html, delta_image)
-
- html.write(' </tr>\n')
- html.flush()