summaryrefslogtreecommitdiff
path: root/progs/tests
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-10-29 19:12:08 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-10-29 19:12:08 +0000
commit7520e259950f7ed356f9737e68d4514e7eec8f06 (patch)
tree684be98c11462d72c27514875b01f3d731872293 /progs/tests
parentefb8b3e251aa07029a2b001dc637d28f3a52a649 (diff)
Updated getprocaddress test to use gl_API.xml instead of old APIspec file.
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/Makefile2
-rw-r--r--progs/tests/getprocaddress.py135
2 files changed, 68 insertions, 69 deletions
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index a826762e1c..872fa0f621 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -87,7 +87,7 @@ clean:
# auto code generation
getprocaddress: getprocaddress.c getproclist.h
-getproclist.h: $(TOP)/src/mesa/glapi/APIspec getprocaddress.c getprocaddress.py
+getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py
python getprocaddress.py > getproclist.h
diff --git a/progs/tests/getprocaddress.py b/progs/tests/getprocaddress.py
index 743a35ebf6..238e019b13 100644
--- a/progs/tests/getprocaddress.py
+++ b/progs/tests/getprocaddress.py
@@ -1,39 +1,17 @@
#!/usr/bin/env python
-# $Id: getprocaddress.py,v 1.3 2003/06/10 14:54:37 brianp Exp $
+# $Id: getprocaddress.py,v 1.4 2004/10/29 19:12:08 brianp Exp $
# Helper for the getprocaddress.c test.
+from xml.sax import saxutils
+from xml.sax import make_parser
+from xml.sax.handler import feature_namespaces
-import re, string
-
-
-def PrintHead():
- print """
-struct name_test_pair {
- const char *name;
- GLboolean (*test)(void *);
-};
-
-static struct name_test_pair functions[] = {"""
-
-
-def PrintTail():
- print"""
- { NULL, NULL }
-};
-"""
-
-
-def HaveTest(function):
- testFuncs = [
- "glActiveTextureARB",
- "glSampleCoverageARB"
- ]
- if function in testFuncs:
- return 1
- else:
- return 0
+import sys, getopt, re
+sys.path.append("../../src/mesa/glapi/" )
+import gl_XML
+import license
def FindTestFunctions():
@@ -52,45 +30,66 @@ def FindTestFunctions():
return functions
-def PrintFunctions(specFile, tests):
+class PrintExports(gl_XML.FilterGLAPISpecBase):
+ name = "gl_exports.py (from Mesa)"
- # init some vars
- prevCategory = ''
- funcName = ''
-
- f = open(specFile)
- for line in f.readlines():
+ def __init__(self):
+ gl_XML.FilterGLAPISpecBase.__init__(self)
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+ self.tests = FindTestFunctions()
+ self.prevCategory = ""
- # split line into tokens
- tokens = string.split(line)
-
- if len(tokens) > 0 and line[0] != '#':
-
- if tokens[0] == 'name':
- if funcName != '':
- if category != prevCategory:
- print ' { "-%s", NULL},' % category
- prevCategory = category
-
- if funcName in tests:
- test = "test_%s" % funcName
- else:
- test = "NULL"
- print ' { "gl%s", %s },' % (funcName, test)
- funcName = tokens[1]
-
- elif tokens[0] == 'category':
- category = tokens[1]
-
- #endif
- #endif
- #endfor
-#enddef
-
-
-tests = FindTestFunctions()
-PrintHead()
-PrintFunctions("../../src/mesa/glapi/APIspec", tests)
-PrintTail()
+ def printRealHeader(self):
+ print """
+struct name_test_pair {
+ const char *name;
+ GLboolean (*test)(void *);
+};
+
+static struct name_test_pair functions[] = {"""
+ def printRealFooter(self):
+ print"""
+ { NULL, NULL }
+};
+"""
+ def printFunction(self, f):
+ if f.category != self.prevCategory:
+ print ' { "-%s", NULL},' % f.category
+ self.prevCategory = f.category
+
+ if f.name in self.tests:
+ test = "test_%s" % f.name
+ else:
+ test = "NULL"
+ print ' { "gl%s", %s }, /* %s */' % (f.name, test, f.category)
+ return
+
+
+if __name__ == '__main__':
+ file_name = "../../src/mesa/glapi/gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+
+ dh = PrintExports()
+
+ parser = make_parser()
+ parser.setFeature(feature_namespaces, 0)
+ parser.setContentHandler(dh)
+
+ f = open(file_name)
+
+ parser.parse(f)
+ dh.printHeader()
+ dh.printFunctions()
+ dh.printFooter()