summaryrefslogtreecommitdiff
path: root/run.py
blob: a6679143710ba7b7e5feae9aa0eed6001b6a5376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python

from getopt import getopt, GetoptError
import re
import sys, os
import subprocess

def usage():
    USAGE = """\
Usage: %(progName)s [shader.frag] [shader.vert]

Options:
  -h, --help                Show this message
"""
    print USAGE % {'progName': sys.argv[0]}
    sys.exit(1)

def run_test(filename):
    command = ['/home/anholt/src/piglit/bin/glslparsertest',
               filename,
               'pass']

    env_add = {}
    env_add["shader_precompile"] = "true"
    env_add["INTEL_DEBUG"] = "vs,wm"

    env = os.environ.copy()
    env.update(env_add)

    try:
        p = subprocess.Popen(
            command,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            env=env)
    except:
        print filename + " FAIL"
        return

    try:
        (stdout, stderr) = p.communicate()
        results = stdout + stderr
    except KeyboardInterrupt:
        exit(1)
    except:
        print filename + " FAIL "
        return

    with open(filename + '.out', 'w') as file:
        file.write(results)

    current_type = 'UNKNOWN'
    counts = {}
    lines = list(results.split('\n'))

    re_fs_8 = re.compile("^Native code for fragment.*8-wide")
    re_fs_16 = re.compile("^Native code for fragment.*16-wide")
    re_vs = re.compile("^Native code for vertex")
    re_align = re.compile("{ align")
    counts["vs  "] = 0
    counts["fs8 "] = 0
    counts["fs16"] = 0
    for line in lines:
        if (re.search(re_vs, line)):
            current_type = "vs  "
        elif (re.search(re_fs_8, line)):
            current_type = "fs8 "
        elif (re.search(re_fs_16, line)):
            current_type = "fs16"
        elif (re.search(re_align, line)):
            counts[current_type] = counts[current_type] + 1

    for t in counts:
        if counts[t] != 0:
            print filename + " " + t + ": " + str(counts[t])
            sys.stdout.flush()

def main():
    try:
        option_list = [
            "help",
            ]
        options, args = getopt(sys.argv[1:], "h", option_list)
    except GetoptError:
        usage()

    for name, value in options:
        if name in ('-h', '--help'):
            usage()

    if len(args) < 1:
        usage()

    for filename in args:
        run_test(filename)

if __name__ == "__main__":
	main()