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