]> git.cworth.org Git - apitrace-tests/blobdiff - mesademos.py
Disable some tests.
[apitrace-tests] / mesademos.py
index 970c39375105022bae8cd4303b22f3d88015e6fd..4375ef8a30638c9b1908585712bacc4a28890291 100755 (executable)
@@ -74,29 +74,40 @@ ignored_function_names = set([
 ])
 
 
-def runtest(demo):
+def image_tag(html, image):
+    url = os.path.relpath(image, options.results)
+    html.write('        <td><a href="%s"><img src="%s"/></a></td>\n' % (url, url))
+
+
+def runtest(html, demo):
 
     app = os.path.join(options.mesa_demos, 'src', demo)
 
     dirname, basename = os.path.split(app)
     
-    trace = os.path.abspath(demo.replace('/', '-') + '.trace')
+    trace = os.path.abspath(os.path.join(options.results, demo.replace('/', '-') + '.trace'))
 
     env = os.environ.copy()
-    env['LD_PRELOAD'] = os.path.abspath('glxtrace.so')
+    env['LD_PRELOAD'] = os.path.abspath(os.path.join(options.build, 'glxtrace.so'))
     env['TRACE_FILE'] = trace
     
     args = [os.path.join('.', basename)]
-    p = popen(args, env=env, cwd=dirname, stdout=subprocess.PIPE)
-    time.sleep(1)
+    p = popen(args, env=env, cwd=dirname)
+    try:
+        window_name = args[0]
 
-    # http://stackoverflow.com/questions/151407/how-to-get-an-x11-window-from-a-process-id
-    ref_image = demo.replace('/', '-') + '.ref.png'
-    subprocess.call('xwd -name \'%s\' | xwdtopnm | pnmtopng > %s' % (args[0], ref_image), shell=True, stdout=subprocess.PIPE)
+        for i in range(10):
+            time.sleep(1)
+            if subprocess.call(['xwininfo', '-name', window_name], stdout=subprocess.PIPE) == 0:
+                break
 
-    os.kill(p.pid, signal.SIGTERM)
+        ref_image = os.path.join(options.results, demo.replace('/', '-') + '.ref.png')
+        subprocess.call("xwd -name '%s' | xwdtopnm | pnmtopng > '%s'" % (args[0], ref_image), shell=True)
 
-    p = popen(['./tracedump', trace], stdout=subprocess.PIPE)
+    finally:
+        p.send_signal(signal.SIGTERM)
+
+    p = popen([os.path.join(options.build, 'tracedump'), trace], stdout=subprocess.PIPE)
     stdout, _ = p.communicate()
 
     call_re = re.compile('^([0-9]+) (\w+)\(')
@@ -113,10 +124,13 @@ def runtest(demo):
                 double_buffer = True
         #print orig_line
 
-    args = ['./glretrace']
+    args = [os.path.join(options.build, 'glretrace')]
     if double_buffer:
         args += ['-db']
-    args += ['-s', '/tmp/' + demo.replace('/', '-') + '.']
+    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()
@@ -128,10 +142,34 @@ def runtest(demo):
             image = mo.group(1)
     
     if image:
-        delta_image = demo.replace('/', '-') + '.diff.png'
-        p = popen(["compare", '-metric', 'AE', '-fuzz', '5%', ref_image, image, delta_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\n')
+        else:
+            sys.stdout.write('PASS\n')
+
 
 tests = [
     'trivial/clear-color',
@@ -139,7 +177,7 @@ tests = [
     'trivial/clear-fbo-scissor',
     'trivial/clear-fbo-tex',
     'trivial/clear-random',
-    'trivial/clear-repeat',
+    #'trivial/clear-repeat', # XXX: animated
     'trivial/clear-scissor',
     'trivial/clear-undefined',
     'trivial/createwin',
@@ -213,7 +251,7 @@ tests = [
     'trivial/quads',
     'trivial/quadstrip',
     'trivial/quadstrip-clip',
-    'trivial/quadstrip-cont',
+    #'trivial/quadstrip-cont', # XXX: animated
     'trivial/quadstrip-flat',
     'trivial/readpixels',
     'trivial/sub-tex',
@@ -252,7 +290,7 @@ tests = [
     'trivial/tri-orig',
     'trivial/tri-point-line-clipped',
     'trivial/tri-query',
-    'trivial/tri-repeat',
+    #'trivial/tri-repeat', # XXX: animated
     'trivial/tri-scissor-tri',
     'trivial/tri-square',
     'trivial/tri-stencil',
@@ -520,8 +558,8 @@ tests = [
     #'slang/cltest',
     #'slang/sotest',
     #'slang/vstest',
-    'tests/afsmultiarb',
-    'tests/antialias',
+    #'tests/afsmultiarb', # XXX: animated
+    #'tests/antialias', # XXX: animated
     'tests/arbfpspec',
     'tests/arbfptest1',
     'tests/arbfptexture',
@@ -531,21 +569,21 @@ tests = [
     'tests/arbnpot-mipmap',
     'tests/arbvptest1',
     'tests/arbvptest3',
-    'tests/arbvptorus',
-    'tests/arbvpwarpmesh',
+    #'tests/arbvptorus', # XXX: animated
+    #'tests/arbvpwarpmesh', # XXX: animated
     'tests/arraytexture',
     'tests/auxbuffer',
     'tests/blendxor',
     'tests/blitfb',
-    'tests/bufferobj',
+    #'tests/bufferobj', # XXX: animated
     'tests/bug_3050',
     'tests/bug_3101',
-    'tests/bug_3195',
+    #'tests/bug_3195', # XXX: animated
     'tests/bug_texstore_i8',
     'tests/bumpmap',
-    'tests/calibrate_rast',
+    #'tests/calibrate_rast', # XXX: animated
     'tests/condrender',
-    'tests/copypixrate',
+    #'tests/copypixrate', # XXX: animated
     'tests/cva',
     'tests/cva_huge',
     'tests/cylwrap',
@@ -555,9 +593,9 @@ tests = [
     'tests/exactrast',
     'tests/ext422square',
     'tests/fbotest1',
-    'tests/fbotest2',
+    #'tests/fbotest2', # XXX: animated
     'tests/fbotest3',
-    'tests/fillrate',
+    #'tests/fillrate', # XXX: animated
     'tests/floattex',
     'tests/fogcoord',
     'tests/fptest1',
@@ -568,7 +606,7 @@ tests = [
     'tests/invert',
     'tests/jkrahntest',
     'tests/lineclip',
-    'tests/manytex',
+    #'tests/manytex', # XXX: animated
     'tests/mapbufrange',
     'tests/minmag',
     'tests/mipgen',
@@ -579,7 +617,7 @@ tests = [
     'tests/mipmap_view',
     'tests/multipal',
     'tests/multitexarray',
-    'tests/multiwindow',
+    #'tests/multiwindow', # XXX: animated
     'tests/no_s3tc',
     'tests/occlude',
     'tests/packedpixels',
@@ -587,9 +625,9 @@ tests = [
     'tests/persp_hint',
     'tests/prim',
     'tests/prog_parameter',
-    'tests/quads',
-    'tests/random',
-    'tests/readrate',
+    #'tests/quads', # XXX: animated
+    #'tests/random', # XXX: animated
+    #'tests/readrate', # XXX: animated
     'tests/rubberband',
     'tests/scissor',
     'tests/scissor-viewport',
@@ -597,15 +635,15 @@ tests = [
     'tests/shader-interp',
     'tests/shader_api',
     'tests/shadow-sample',
-    'tests/sharedtex',
+    #'tests/sharedtex', # XXX: animated
     'tests/stencilreaddraw',
-    'tests/stencilwrap',
+    #'tests/stencilwrap', # XXX: animated
     'tests/step',
-    'tests/streaming_rect',
+    #'tests/streaming_rect', # XXX: animated
     'tests/subtex',
-    'tests/subtexrate',
+    #'tests/subtexrate', # XXX: animated
     'tests/tex1d',
-    'tests/texcmp',
+    #'tests/texcmp', # XXX: animated
     'tests/texcompress2',
     'tests/texcompsub',
     'tests/texdown',
@@ -613,7 +651,7 @@ tests = [
     'tests/texgenmix',
     'tests/texleak',
     'tests/texline',
-    'tests/texobj',
+    #'tests/texobj', # XXX: animated
     'tests/texobjshare',
     'tests/texrect',
     'tests/unfilledclip',
@@ -666,7 +704,7 @@ tests = [
 ]
 
 
-tests = [
+_tests = [
     'trivial/tri',
     'trivial/tri-tex',
 ]
@@ -682,19 +720,35 @@ def main():
     optparser.add_option(
         '--build', metavar='PATH',
         type='string', dest='build', default='.',
-        help='path to apitrace build')
-
+        help='path to apitrace build [default=%default]')
+    optparser.add_option(
+        '--results', metavar='PATH',
+        type='string', dest='results', default='.',
+        help='results directory [default=%default]')
     optparser.add_option(
         '--mesa-demos', metavar='PATH',
         type='string', dest='mesa_demos', default=os.environ.get('MESA_DEMOS'),
-        help='path to mesa demos')
+        help='path to Mesa demos [default=%default]')
 
     (options, args) = optparser.parse_args(sys.argv[1:])
-    if args:
-        tests = args
 
-    for test in tests:
-       runtest(test)
+    if not options.mesa_demos:
+        optparser.error('path to Mesa demos not specified')
+    if not os.path.exists(options.results):
+        os.makedirs(options.results)
+
+    html = open(os.path.join(options.results, 'index.html'), 'wt')
+    html.write('<html>\n')
+    html.write('  <body>\n')
+    html.write('    <table border="1">\n')
+    html.write('      <tr><th>Ref</th><th>Src</th><th>&Delta;</th></tr>\n')
+    if not args:
+        args = tests
+    for test in args:
+       runtest(html, test)
+    html.write('    </table>\n')
+    html.write('  </body>\n')
+    html.write('</html>\n')
 
 
 if __name__ == '__main__':