X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=mesademos.py;h=2f6ef3db73bbd6efdb0cfb4ae6526344770655cc;hb=1848be9dd66b7a97b94278273586174a4d6fd2d2;hp=beae8b0e9ef2e34ecc0e87c938d863c3eb3cefcb;hpb=30f90f10df5ac7480acb71d1e5b9a3b0b1600aec;p=apitrace-tests diff --git a/mesademos.py b/mesademos.py index beae8b0..2f6ef3d 100755 --- a/mesademos.py +++ b/mesademos.py @@ -47,7 +47,14 @@ 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) @@ -69,24 +76,27 @@ ignored_function_names = set([ def runtest(demo): - app = os.path.join(options.mesa_demos, demo) + app = os.path.join(options.mesa_demos, 'src', demo) dirname, basename = os.path.split(app) + + trace = os.path.abspath(demo.replace('/', '-') + '.trace') env = os.environ.copy() env['LD_PRELOAD'] = os.path.abspath('glxtrace.so') - env['TRACE_FILE'] = '/tmp/trace' + env['TRACE_FILE'] = trace args = [os.path.join('.', basename)] p = popen(args, env=env, cwd=dirname, stdout=subprocess.PIPE) - time.sleep(0.5) + time.sleep(1) # http://stackoverflow.com/questions/151407/how-to-get-an-x11-window-from-a-process-id - subprocess.call('xwd -name \'%s\' | xwdtopnm | pnmtopng > %s' % (args[0], '/tmp/ref.png'), shell=True, stdout=subprocess.PIPE) + ref_image = demo.replace('/', '-') + '.ref.png' + subprocess.call('xwd -name \'%s\' | xwdtopnm | pnmtopng > %s' % (args[0], ref_image), shell=True, stdout=subprocess.PIPE) os.kill(p.pid, signal.SIGTERM) - p = popen(['./tracedump', '/tmp/trace'], stdout=subprocess.PIPE) + p = popen(['./tracedump', trace], stdout=subprocess.PIPE) stdout, _ = p.communicate() call_re = re.compile('^([0-9]+) (\w+)\(') @@ -106,8 +116,8 @@ def runtest(demo): args = ['./glretrace'] if double_buffer: args += ['-db'] - args += ['-s', '/tmp/test_'] - args += ['/tmp/trace'] + args += ['-s', '/tmp/' + demo.replace('/', '-') + '.'] + args += [trace] p = popen(args, stdout=subprocess.PIPE) stdout, _ = p.communicate() image_re = re.compile('^Wrote (.*\.png)$') @@ -118,7 +128,8 @@ def runtest(demo): image = mo.group(1) if image: - p = popen(["compare", '-metric', 'AE', '-fuzz', '5%', '-extract', '250x250', '/tmp/ref.png', image, '/tmp/delta.png']) + delta_image = demo.replace('/', '-') + '.diff.png' + p = popen(["compare", '-alpha', 'opaque', '-metric', 'AE', '-fuzz', '5%', ref_image, image, delta_image]) _, stderr = p.communicate() @@ -511,7 +522,6 @@ tests = [ #'slang/vstest', 'tests/afsmultiarb', 'tests/antialias', - 'tests/api_speed.py', 'tests/arbfpspec', 'tests/arbfptest1', 'tests/arbfptexture', @@ -667,7 +677,7 @@ 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', @@ -681,10 +691,10 @@ def main(): (options, args) = optparser.parse_args(sys.argv[1:]) if args: - optparser.error("incorrect number of arguments") + tests = args for test in tests: - runtest('src/' + test) + runtest(test) if __name__ == '__main__':