- args = [os.path.join('.', basename)]
- window_name = args[0]
-
- p = popen(args, cwd=dirname)
- for i in range(6):
- time.sleep(0.5)
- if p.poll() is not None:
- break
- if subprocess.call(['xwininfo', '-name', window_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
- break
- if p.returncode is None:
- p.terminate()
- elif p.returncode:
- sys.stdout.write('SKIP (app)\n')
- return
-
- ref_image = os.path.join(options.results, demo.replace('/', '-') + '.ref.png')
- p = popen(args, env=env, cwd=dirname)
- try:
- for i in range(10):
- time.sleep(0.5)
- if p.poll() is not None:
- break
- if subprocess.call(['xwininfo', '-name', window_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
- break
-
- if p.returncode is None:
- subprocess.call("xwd -name '%s' | xwdtopnm | pnmtopng > '%s'" % (args[0], ref_image), shell=True)
- finally:
- if p.returncode is None:
- p.terminate()
- p.wait()
- elif p.returncode:
- print p.returncode
- sys.stdout.write('FAIL (trace)\n')
- return
-
- p = popen([os.path.join(options.build, 'tracedump'), trace], stdout=subprocess.PIPE)
- call_re = re.compile('^([0-9]+) (\w+)\(')
- swapbuffers = 0
- flushes = 0
- for orig_line in p.stdout:
- orig_line = orig_line.rstrip()
- 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':
- swapbuffers += 1
- if function_name in ('glFlush', 'glFinish'):
- flushes += 1
- #print orig_line
- p.wait()
- if p.returncode != 0:
- sys.stdout.write('FAIL (tracedump)\n')
- return
-
- args = [os.path.join(options.build, 'glretrace')]
- if swapbuffers:
- args += ['-db']
- frames = swapbuffers
- else:
- args += ['-sb']
- frames = flushes
- if os.path.exists(ref_image) and frames < 10:
- snapshot_prefix = os.path.join(options.results, demo.replace('/', '-') + '.')
- args += ['-s', snapshot_prefix]
- else:
- snapshot_prefix = None
- args += [trace]
- p = popen(args, stdout=subprocess.PIPE)
- image_re = re.compile('^Wrote (.*\.png)$')
- image = None
- for line in p.stdout:
- line = line.rstrip()
- mo = image_re.match(line)
- if mo:
- image = mo.group(1)
- p.wait()
- if p.returncode != 0:
- sys.stdout.write('FAIL (glretrace)\n')
- return
-
- if image:
- delta_image = os.path.join(options.results, demo.replace('/', '-') + '.diff.png')
- p = popen([
- 'compare',
- '-alpha', 'opaque',
- '-metric', 'AE',
- '-fuzz', '5%',
- '-dissimilarity-threshold', '1',
- ref_image, image, delta_image
- ], stderr = subprocess.PIPE)
- _, stderr = p.communicate()
-
- try:
- ae = int(stderr)
- except ValueError:
- ae = 9999
-
- if ae:
- html.write(' <tr>\n')
- image_tag(html, ref_image)
- image_tag(html, image)
- image_tag(html, delta_image)
- html.write(' </tr>\n')
- html.flush()
-
- sys.stdout.write('FAIL (snapshot)\n')
- return
-
- sys.stdout.write('PASS\n')