X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=mesademos.py;h=4375ef8a30638c9b1908585712bacc4a28890291;hb=2e23013c8357413bd3c4c22febcc3418505606ee;hp=251e1756f7efd6f7de45a62835a6fd8673b855f2;hpb=eafd92102e777af5ee4e285a3c5ec5b546ff231d;p=apitrace-tests diff --git a/mesademos.py b/mesademos.py index 251e175..4375ef8 100755 --- a/mesademos.py +++ b/mesademos.py @@ -47,6 +47,12 @@ def ansi_strip(s): def popen(command, *args, **kwargs): + if 'cwd' in kwargs: + sys.stdout.write('cd %s && ' % kwargs['cwd']) + if 'env' in kwargs: + for name, value in kwargs['env'].iteritems(): + if value != os.environ.get(name, None): + sys.stdout.write('%s=%s ' % (name, value)) sys.stdout.write(' '.join(command) + '\n') sys.stdout.flush() return subprocess.Popen(command, *args, **kwargs) @@ -68,29 +74,40 @@ ignored_function_names = set([ ]) -def runtest(demo): +def image_tag(html, image): + url = os.path.relpath(image, options.results) + html.write(' \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(0.5) + 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+)\(') @@ -107,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() @@ -122,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%', '-extract', '250x250', 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(' \n') + image_tag(html, ref_image) + image_tag(html, image) + image_tag(html, delta_image) + html.write(' \n') + html.flush() + + sys.stdout.write('FAIL\n') + else: + sys.stdout.write('PASS\n') + tests = [ 'trivial/clear-color', @@ -133,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', @@ -207,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', @@ -246,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', @@ -514,9 +558,8 @@ tests = [ #'slang/cltest', #'slang/sotest', #'slang/vstest', - 'tests/afsmultiarb', - 'tests/antialias', - 'tests/api_speed.py', + #'tests/afsmultiarb', # XXX: animated + #'tests/antialias', # XXX: animated 'tests/arbfpspec', 'tests/arbfptest1', 'tests/arbfptexture', @@ -526,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', @@ -550,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', @@ -563,7 +606,7 @@ tests = [ 'tests/invert', 'tests/jkrahntest', 'tests/lineclip', - 'tests/manytex', + #'tests/manytex', # XXX: animated 'tests/mapbufrange', 'tests/minmag', 'tests/mipgen', @@ -574,7 +617,7 @@ tests = [ 'tests/mipmap_view', 'tests/multipal', 'tests/multitexarray', - 'tests/multiwindow', + #'tests/multiwindow', # XXX: animated 'tests/no_s3tc', 'tests/occlude', 'tests/packedpixels', @@ -582,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', @@ -592,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', @@ -608,7 +651,7 @@ tests = [ 'tests/texgenmix', 'tests/texleak', 'tests/texline', - 'tests/texobj', + #'tests/texobj', # XXX: animated 'tests/texobjshare', 'tests/texrect', 'tests/unfilledclip', @@ -661,7 +704,7 @@ tests = [ ] -tests = [ +_tests = [ 'trivial/tri', 'trivial/tri-tex', ] @@ -672,24 +715,40 @@ def main(): # Parse command line options optparser = optparse.OptionParser( - usage='\n\t%prog [options] ', + usage='\n\t%prog [options] [demo] ...', version='%%prog') 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: - optparser.error("incorrect number of arguments") - 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('\n') + html.write(' \n') + html.write(' \n') + html.write(' \n') + if not args: + args = tests + for test in args: + runtest(html, test) + html.write('
RefSrcΔ
\n') + html.write(' \n') + html.write('\n') if __name__ == '__main__':