progs/tests: also test stencil INCR_WRAP mode if supported
[mesa.git] / progs / tests / getprocaddress.py
1 #!/usr/bin/env python
2
3
4 # Helper for the getprocaddress.c test.
5
6 import sys, getopt, re
7 sys.path.append("../../src/mesa/glapi/gen" )
8 import gl_XML
9 import license
10
11
12 def FindTestFunctions():
13 """Scan getprocaddress.c for lines that start with "test_" to find
14 extension function tests. Return a list of names found."""
15 functions = []
16 f = open("getprocaddress.c")
17 if not f:
18 return functions
19 for line in f.readlines():
20 v = re.search("^test_([a-zA-Z0-9]+)", line)
21 if v:
22 func = v.group(1)
23 functions.append(func)
24 f.close
25 return functions
26
27
28 class PrintExports(gl_XML.gl_print_base):
29 def __init__(self):
30 gl_XML.gl_print_base.__init__(self)
31
32 self.name = "getprocaddress.py (from Mesa)"
33 self.license = license.bsd_license_template % ( \
34 """Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
35 (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
36
37 self.tests = FindTestFunctions()
38 self.prevCategory = ""
39 return
40
41
42 def printRealHeader(self):
43 print """
44 struct name_test_pair {
45 const char *name;
46 GLboolean (*test)(generic_func);
47 };
48
49 static struct name_test_pair functions[] = {"""
50
51 def printBody(self, api):
52 prev_category = None
53
54
55 for f in api.functionIterateByCategory():
56 [category, num] = api.get_category_for_name( f.name )
57 if category != prev_category:
58 print ' { "-%s", NULL},' % category
59 prev_category = category
60
61 test = "NULL"
62 for name in f.entry_points:
63 if name in self.tests:
64 test = "test_%s" % name
65 break
66
67 print ' { "gl%s", %s },' % (f.name, test)
68
69 print ''
70 print ' { NULL, NULL }'
71 print '};'
72 print ''
73 return
74
75
76 if __name__ == '__main__':
77 file_name = "../../src/mesa/glapi/gen/gl_API.xml"
78
79 try:
80 (args, trail) = getopt.getopt(sys.argv[1:], "f:")
81 except Exception,e:
82 show_usage()
83
84 for (arg,val) in args:
85 if arg == "-f":
86 file_name = val
87
88 printer = PrintExports()
89
90 api = gl_XML.parse_GL_API( file_name, gl_XML.gl_item_factory() )
91
92 printer.Print( api )