[Piglit] [PATCH 4/4] cl: Add a python script for generating tests for relational builtins

Tom Stellard tom at stellard.net
Thu Sep 12 10:45:22 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

This includes a test for the isnan builtin.
---
 generated_tests/CMakeLists.txt                     |  4 ++
 generated_tests/generate-cl-relational-builtins.py | 69 ++++++++++++++++++++++
 tests/all_cl.tests                                 |  1 +
 3 files changed, 74 insertions(+)
 create mode 100644 generated_tests/generate-cl-relational-builtins.py

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 2a1c3ff..7c41899 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -63,6 +63,9 @@ piglit_make_generated_tests(
 piglit_make_generated_tests(
 	builtin_cl_math_tests.list
 	generate-cl-math-builtins.py)
+piglit_make_generated_tests(
+	builtin_cl_relational_tests.list
+	generate-cl-relational-builtins.py)
 
 # Add a "gen-tests" target that can be used to generate all the
 # tests without doing any other compilation.
@@ -72,6 +75,7 @@ add_custom_target(gen-tests ALL
 		constant_array_size_tests.list
 		builtin_cl_int_tests.list
 		builtin_cl_math_tests.list
+		builtin_cl_relational_tests.list
 		cl_store_tests.list
 		interpolation_tests.list
 		non-lvalue_tests.list
diff --git a/generated_tests/generate-cl-relational-builtins.py b/generated_tests/generate-cl-relational-builtins.py
new file mode 100644
index 0000000..af6849f
--- /dev/null
+++ b/generated_tests/generate-cl-relational-builtins.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 Advanced Micro Devices, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+# Authors: Tom Stellard <thomas.stellard at amd.com>
+#
+
+import os
+
+from genclbuiltins import gen
+
+CLC_VERSION_MIN = {
+    'isnan' : 10
+}
+
+DATA_TYPES = ['float']
+
+F = {
+    'float' : 'float'
+}
+
+I = {
+    'float' : 'int'
+}
+
+tests = {
+    'isnan' : {
+        'arg_types': [I, F],
+        'function_type': 'ttt',
+        'values': [
+            [0,   1,            0,   0],            # Result
+            [0.0, float("nan"), 1.0, float("inf") ] # Arg0
+        ]
+    }
+}
+
+
+def main():
+    dirName = os.path.join("cl", "builtin", "relational")
+
+    testDefs = {}
+    functions = sorted(tests.keys())
+    for dataType in DATA_TYPES:
+        for fnName in functions:
+            testDefs[(dataType, fnName)] = tests[fnName]
+
+    gen(DATA_TYPES, CLC_VERSION_MIN, functions, testDefs, dirName)
+
+
+main()
diff --git a/tests/all_cl.tests b/tests/all_cl.tests
index b0aa9d7..877119e 100644
--- a/tests/all_cl.tests
+++ b/tests/all_cl.tests
@@ -114,6 +114,7 @@ program_execute_builtin = Group()
 program["Execute"]["Builtin"] = program_execute_builtin
 add_program_test_dir(program_execute_builtin, 'generated_tests/cl/builtin/int')
 add_program_test_dir(program_execute_builtin, 'generated_tests/cl/builtin/math')
+add_program_test_dir(program_execute_builtin, 'generated_tests/cl/builtin/relational')
 program_execute_store = Group()
 program["Execute"]["Store"] = program_execute_store
 add_program_test_dir(program_execute_store, 'generated_tests/cl/store')
-- 
1.7.11.4



More information about the Piglit mailing list