[Piglit] [PATCH 33/34] genclbuiltins.py: hybridize for python3
Dylan Baker
baker.dylan.c at gmail.com
Fri Feb 20 18:18:20 PST 2015
This allows gen_cl_int_builtins, gen_cl_math_builtins, and
gen_cl_relational_tests to generate tests with python3 and
python2, and to produce the same output
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
generated_tests/genclbuiltins.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/generated_tests/genclbuiltins.py b/generated_tests/genclbuiltins.py
index 0a14f0c..5f66d4d 100644
--- a/generated_tests/genclbuiltins.py
+++ b/generated_tests/genclbuiltins.py
@@ -18,9 +18,13 @@
import os
+import six
+
__all__ = ['gen', 'DATA_SIZES', 'MAX_VALUES', 'MAX', 'MIN', 'BMIN', 'BMAX',
'SMIN', 'SMAX', 'UMIN', 'UMAX', 'TYPE', 'T', 'U', 'B']
+_NUMERIC_TYPES = tuple(list(six.integer_types) + [float])
+
DATA_SIZES = {
'char': 8,
@@ -286,7 +290,7 @@ def getValue(type, val, isVector):
return map(lambda x: getValue(type, x, isVector), val);
# At this point, we should have been passed a number
- if (isinstance(val, (int, long, float))):
+ if (isinstance(val, _NUMERIC_TYPES)):
return val
print('Invalid value '+repr(val)+' encountered in getValue\n')
@@ -391,7 +395,7 @@ def gen(types, minVersions, functions, testDefs, dirName):
for dataType in types:
for fnName in functions:
# Merge all of the generic/signed/unsigned/custom test definitions
- if not testDefs.has_key((dataType, fnName)):
+ if (dataType, fnName) not in testDefs:
continue
functionDef = testDefs[(dataType, fnName)]
--
2.3.0
More information about the Piglit
mailing list