summaryrefslogtreecommitdiffstats
path: root/progs/tests/getprocaddress.py
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-11-08 15:35:46 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-11-08 15:35:46 +0000
commitd1efbf04562be8b9fb4417ebde005532736003ea (patch)
tree57e840c3ce55182d678370be1dcec41bc9377b86 /progs/tests/getprocaddress.py
parent6e40539490082d37791bcc2678598718641918af (diff)
downloadexternal_mesa3d-d1efbf04562be8b9fb4417ebde005532736003ea.zip
external_mesa3d-d1efbf04562be8b9fb4417ebde005532736003ea.tar.gz
external_mesa3d-d1efbf04562be8b9fb4417ebde005532736003ea.tar.bz2
implemented automatic code gen and individual function validation
Diffstat (limited to 'progs/tests/getprocaddress.py')
-rw-r--r--progs/tests/getprocaddress.py97
1 files changed, 97 insertions, 0 deletions
diff --git a/progs/tests/getprocaddress.py b/progs/tests/getprocaddress.py
new file mode 100644
index 0000000..e5d2fbb
--- /dev/null
+++ b/progs/tests/getprocaddress.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+
+# $Id: getprocaddress.py,v 1.1 2002/11/08 15:35:47 brianp Exp $
+
+# Helper for the getprocaddress.c test.
+
+
+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
+
+
+def FindTestFunctions():
+ """Scan getprocaddress.c for lines that start with "test_" to find
+ extension function tests. Return a list of names found."""
+ functions = []
+ f = open("getprocaddress.c")
+ if not f:
+ return functions
+ for line in f.readlines():
+ v = re.search("^test_([a-zA-Z0-9]+)", line)
+ if v:
+ func = v.group(1)
+ #print "Found -%s-" % func
+ functions.append(func)
+ f.close
+ return functions
+
+
+def PrintFunctions(specFile, tests):
+
+ # init some vars
+ prevCategory = ''
+ funcName = ''
+
+ f = open(specFile)
+ for line in f.readlines():
+
+ # 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 HaveTest("gl" + funcName):
+ 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("../bin/APIspec", tests)
+PrintTail()
+
+