[Piglit] [RFC 26/30] cl.py: Use TestProfile.group_manager

Dylan Baker baker.dylan.c at gmail.com
Tue Jan 27 14:59:00 PST 2015


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 tests/cl.py | 191 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 93 insertions(+), 98 deletions(-)

diff --git a/tests/cl.py b/tests/cl.py
index 96b3344..1640456 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -19,105 +19,104 @@ from .py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
 
 __all__ = ['profile']
 
-######
-# Helper functions
 
 can_do_concurrent = (not sys.platform.startswith('linux') or
                      glob.glob('/dev/dri/render*'))
 
 
-def add_plain_test(group, name, args):
-    group[name] = PiglitCLTest(args, run_concurrent=can_do_concurrent)
+def cl_test(*args, **kwargs):
+    """Wrapper for PiglitCLTest that sets run_concurrent.
 
+    Always set concurrent to can_do_concurrent, but allow it to be turned off
+    explicitely.
 
-def add_plain_program_tester_test(group, name, path):
-    add_plain_test(group, name, ['cl-program-tester', path])
+    """
+    if 'run_concurrent' is not False:
+        kwargs['run_concurrent'] = can_do_concurrent
+    return PiglitCLTest(*args, **kwargs)
 
 
-######
-# Collecting all tests
 profile = TestProfile()
 
-custom = profile.tests['Custom']
-api = profile.tests['API']
-program = profile.tests['Program']
 
-######
-# Tests
 
 # Custom
-add_plain_test(custom, 'Run simple kernel', ['cl-custom-run-simple-kernel'])
-add_plain_test(custom, 'Flush after enqueue kernel',
-               ['cl-custom-flush-after-enqueue-kernel'])
-add_plain_test(custom, 'r600 create release buffer bug',
-               ['cl-custom-r600-create-release-buffer-bug'])
-add_plain_test(custom, 'Buffer flags', ['cl-custom-buffer-flags'])
-
-# API
-#  Platform
-add_plain_test(api, 'clGetPlatformIDs', ['cl-api-get-platform-ids'])
-add_plain_test(api, 'clGetPlatformInfo', ['cl-api-get-platform-info'])
-#  Device
-add_plain_test(api, 'clGetDeviceIDs', ['cl-api-get-device-ids'])
-add_plain_test(api, 'clGetDeviceInfo', ['cl-api-get-device-info'])
-#  Context
-add_plain_test(api, 'clCreateContext', ['cl-api-create-context'])
-add_plain_test(api, 'clCreateContextFromType',
-               ['cl-api-create-context-from-type'])
-add_plain_test(api, 'clGetContextInfo', ['cl-api-get-context-info'])
-add_plain_test(api, 'clRetainContext and clReleaseContext',
-               ['cl-api-retain_release-context'])
-#  Command Queues
-add_plain_test(api, 'clCreateCommandQueue', ['cl-api-create-command-queue'])
-add_plain_test(api, 'clRetainComandQueue and clReleaseCommandQueue',
-               ['cl-api-retain_release-command-queue'])
-add_plain_test(api, 'clGetCommandQueueInfo', ['cl-api-get-command-queue-info'])
-#  Memory objects
-add_plain_test(api, 'clCreateBuffer', ['cl-api-create-buffer'])
-add_plain_test(api, 'clCreateImage', ['cl-api-create-image'])
-add_plain_test(api, 'clCreateSampler', ['cl-api-create-sampler'])
-add_plain_test(api, 'clEnqueueCopyBuffer', ['cl-api-enqueue-copy-buffer'])
-add_plain_test(api, 'clEnqueueCopyBufferRect',
-               ['cl-api-enqueue-copy-buffer-rect'])
-add_plain_test(api, 'clEnqueueReadBuffer and clEnqueueWriteBuffer',
-               ['cl-api-enqueue-read_write-buffer'])
-add_plain_test(api, 'clGetMemObjectInfo', ['cl-api-get-mem-object-info'])
-add_plain_test(api, 'clGetImageInfo', ['cl-api-get-image-info'])
-add_plain_test(api, 'clRetainMemObject and clReleaseMemObject',
-               ['cl-api-retain_release-mem-object'])
-#  Program
-add_plain_test(api, 'clCreateProgramWithBinary',
-               ['cl-api-create-program-with-binary'])
-add_plain_test(api, 'clCreateProgramWithSource',
-               ['cl-api-create-program-with-source'])
-add_plain_test(api, 'clBuildProgram', ['cl-api-build-program'])
-add_plain_test(api, 'clCompileProgram', ['cl-api-compile-program'])
-add_plain_test(api, 'clCreateKernelsInProgram',
-               ['cl-api-create-kernels-in-program'])
-add_plain_test(api, 'clGetProgramInfo', ['cl-api-get-program-info'])
-add_plain_test(api, 'clGetProgramBuildInfo', ['cl-api-get-program-build-info'])
-add_plain_test(api, 'clRetainProgram and clReleaseProgram',
-               ['cl-api-retain_release-program'])
-add_plain_test(api, 'clUnloadCompiler', ['cl-api-unload-compiler'])
-#  Kernel
-add_plain_test(api, 'clCreateKernel', ['cl-api-create-kernel'])
-add_plain_test(api, 'clCreateKernelsInProgram',
-               ['cl-api-create-kernels-in-program'])
-add_plain_test(api, 'clGetKernelInfo', ['cl-api-get-kernel-info'])
-add_plain_test(api, 'clGetKernelWorkGroupInfo',
-               ['cl-api-get-kernel-work-group-info'])
-add_plain_test(api, 'clRetainKernel and clReleaseKernel',
-               ['cl-api-retain_release-kernel'])
-add_plain_test(api, 'clSetKernelArg', ['cl-api-set-kernel-arg'])
-#  Event
-add_plain_test(api, 'clGetEventInfo', ['cl-api-get-event-info'])
-add_plain_test(api, 'clRetainEvent and clReleaseEvent',
-               ['cl-api-retain_release-event'])
-
-# Program
-add_plain_test(program, 'Run kernel with max work item sizes',
-               ['cl-program-max-work-item-sizes'])
-add_plain_test(program, 'Bitcoin: phatk kernel', ['cl-program-bitcoin-phatk'])
+with profile.group_manager(cl_test, 'custom') as g:
+    g(['cl-custom-run-simple-kernel'], 'Run simple kernel')
+    g(['cl-custom-flush-after-enqueue-kernel'], 'Flush after enqueue kernel')
+    g(['cl-custom-r600-create-release-buffer-bug'],
+      'r600 create release buffer bug')
+    g(['cl-custom-buffer-flags'], 'Buffer flags')
+
+with profile.group_manager(cl_test, 'api') as g:
+    # Platform
+    g(['cl-api-get-platform-ids'], 'clGetPlatformIDs')
+    g(['cl-api-get-platform-info'], 'clGetPlatformInfo')
+
+    # Device
+    g(['cl-api-get-device-ids'], 'clGetDeviceIDs')
+    g(['cl-api-get-device-info'], 'clGetDeviceInfo')
+
+    # Context
+    g(['cl-api-create-context'], 'clCreateContext')
+    g(['cl-api-create-context-from-type'], 'clCreateContextFromType')
+    g(['cl-api-get-context-info'], 'clGetContextInfo')
+    g(['cl-api-retain_release-context'],
+      'clRetainContext and clReleaseContext')
+
+    # Command Queues
+    g(['cl-api-create-command-queue'], 'clCreateCommandQueue')
+    g(['cl-api-retain_release-command-queue'],
+      'clRetainComandQueue and clReleaseCommandQueue')
+    g(['cl-api-get-command-queue-info'], 'clGetCommandQueueInfo')
+
+    # Memory objects
+    g(['cl-api-create-buffer'], 'clCreateBuffer')
+    g(['cl-api-create-image'], 'clCreateImage')
+    g(['cl-api-create-sampler'], 'clCreateSampler')
+    g(['cl-api-enqueue-copy-buffer'], 'clEnqueueCopyBuffer')
+    g(['cl-api-enqueue-copy-buffer-rect'], 'clEnqueueCopyBufferRect')
+    g(['cl-api-enqueue-read_write-buffer'],
+      'clEnqueueReadBuffer and clEnqueueWriteBuffer')
+    g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
+    g(['cl-api-get-image-info'], 'clGetImageInfo')
+    g(['cl-api-retain_release-mem-object'],
+      'clRetainMemObject and clReleaseMemObject')
+
+    g(['cl-api-create-program-with-binary'], 'clCreateProgramWithBinary')
+    g(['cl-api-create-program-with-source'], 'clCreateProgramWithSource')
+    g(['cl-api-build-program'], 'clBuildProgram')
+    g(['cl-api-compile-program'], 'clCompileProgram')
+    g(['cl-api-create-kernels-in-program'], 'clCreateKernelsInProgram')
+    g(['cl-api-get-program-info'], 'clGetProgramInfo')
+    g(['cl-api-get-program-build-info'], 'clGetProgramBuildInfo')
+    g(['cl-api-retain_release-program'], 'clRetainProgram and clReleaseProgram')
+    g(['cl-api-unload-compiler'], 'clUnloadCompiler')
+
+    # Kernel
+    g(['cl-api-create-kernel'], 'clCreateKernel')
+    g(['cl-api-create-kernels-in-program'], 'clCreateKernelsInProgram')
+    g(['cl-api-get-kernel-info'], 'clGetKernelInfo')
+    g(['cl-api-get-kernel-work-group-info'], 'clGetKernelWorkGroupInfo')
+    g(['cl-api-retain_release-kernel'], 'clRetainKernel and clReleaseKernel')
+    g(['cl-api-set-kernel-arg'], 'clSetKernelArg')
+
+    # Event
+    g(['cl-api-get-event-info'], 'clGetEventInfo')
+    g(['cl-api-retain_release-event'], 'clRetainEvent and clReleaseEvent')
+
+with profile.group_manager(cl_test, 'program') as g:
+    g(['cl-program-max-work-item-sizes'],
+      'Run kernel with max work item sizes')
+    g(['cl-program-bitcoin-phatk'], 'Bitcoin: phatk kernel')
+
+
+def add_plain_test(group, name, args):
+    group[name] = PiglitCLTest(args, run_concurrent=can_do_concurrent)
+
+
+def add_plain_program_tester_test(group, name, path):
+    add_plain_test(group, name, ['cl-program-tester', path])
 
 
 def add_program_test_dir(group, dirpath):
@@ -130,31 +129,27 @@ def add_program_test_dir(group, dirpath):
         add_plain_program_tester_test(group, testname, filepath)
 
 
-program_build = program["Build"]
-program_build_fail = program["Build"]["Fail"]
-program_execute = program["Execute"]
 
-add_program_test_dir(program_build,
+add_program_test_dir(profile.tests['Program']["Build"],
                      os.path.join(TESTS_DIR, 'cl', 'program', 'build'))
-add_program_test_dir(program_build_fail,
+add_program_test_dir(profile.tests['Program']["Build"]['fail'],
                      os.path.join(TESTS_DIR, 'cl', 'program', 'build', 'fail'))
-add_program_test_dir(program_execute,
+add_program_test_dir(profile.tests['Program']["execute"],
                      os.path.join(TESTS_DIR, 'cl', 'program', 'execute'))
-add_program_test_dir(program_execute,
+add_program_test_dir(profile.tests['Program']["execute"],
                      os.path.join(TESTS_DIR, 'cl', 'program', 'execute',
                                   'builtin', 'atomic'))
-add_program_test_dir(program_execute,
+add_program_test_dir(profile.tests['Program']["execute"],
                      os.path.join(TESTS_DIR, 'cl', 'program', 'execute',
                                   'builtin', 'convert'))
 
 # Run generated built-in tests
-program_execute_builtin = program["Execute"]["Builtin"]
-add_program_test_dir(program_execute_builtin,
+add_program_test_dir(profile.tests['Program']["execute"]["Builtin"],
                      os.path.join(GENERATED_TESTS_DIR, 'cl', 'builtin', 'int'))
-add_program_test_dir(program_execute_builtin,
+add_program_test_dir(profile.tests['Program']["execute"]["Builtin"],
                      os.path.join(GENERATED_TESTS_DIR, 'cl', 'builtin', 'math'))
-add_program_test_dir(program_execute_builtin,
+add_program_test_dir(profile.tests['Program']["execute"]["Builtin"],
                      os.path.join(GENERATED_TESTS_DIR, 'cl', 'builtin',
                                   'relational'))
-add_program_test_dir(program["Execute"]["Store"],
+add_program_test_dir(profile.tests['program']["Execute"]["Store"],
                      os.path.join(GENERATED_TESTS_DIR, 'cl', 'store'))
-- 
2.2.2



More information about the Piglit mailing list