[Piglit] [PATCH 16/21] framework: Override run_concurrent for CL test classes

Dylan Baker baker.dylan.c at gmail.com
Tue Feb 24 17:34:48 PST 2015


This patch changes where the OpenCL tests get their run_concurrent flag
from. After this patch it is computed automatically, leaving no need to
set the flag manually unless one wants to force a non default behavior
for their platform.

XXX: This assumes Thomas Stellard's
     "opencv: Automatically run tests concurrently..." patch

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/test/opencv.py      |  3 ++-
 framework/test/piglit_test.py | 22 +++++++++++++++++-----
 tests/cl.py                   | 26 ++++----------------------
 3 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/framework/test/opencv.py b/framework/test/opencv.py
index 3490c8a..157102e 100644
--- a/framework/test/opencv.py
+++ b/framework/test/opencv.py
@@ -29,6 +29,7 @@ from os import path
 
 from .gtest import GTest
 from framework.core import PIGLIT_CONFIG
+from framework.test import CL_CONCURRENT
 import framework.grouptools as grouptools
 
 __all__ = [
@@ -42,7 +43,7 @@ class OpenCVTest(GTest):
         options = [test_prog, '--gtest_filter=' + testname, '--gtest_color=no']
         if PIGLIT_CONFIG.has_option('opencv', 'workdir'):
             options.append('-w {}'.format(PIGLIT_CONFIG.get('opencv', 'workdir')))
-        GTest.__init__(self, options)
+        GTest.__init__(self, options, run_concurrent=CL_CONCURRENT)
 
 
 def add_opencv_tests(profile):
diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index 7511df2..2f6282d 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -24,6 +24,8 @@
 
 from __future__ import print_function, absolute_import
 import os
+import sys
+import glob
 try:
     import simplejson as json
 except ImportError:
@@ -34,9 +36,10 @@ import framework.core as core
 
 
 __all__ = [
-    'PiglitGLTest',
     'PiglitCLTest',
-    'TEST_BIN_DIR'
+    'PiglitGLTest',
+    'CL_CONCURRENT',
+    'TEST_BIN_DIR',
 ]
 
 if 'PIGLIT_BUILD_DIR' in os.environ:
@@ -46,6 +49,10 @@ else:
                                                  '../../bin'))
 
 
+CL_CONCURRENT = (not sys.platform.startswith('linux') or
+                 glob.glob('/dev/dri/render*'))
+
+
 class PiglitBaseTest(Test):
     """
     PiglitTest: Run a "native" piglit test executable
@@ -136,6 +143,11 @@ class PiglitGLTest(WindowResizeMixin, PiglitBaseTest):
             return super(PiglitGLTest, self).command + ['-auto', '-fbo']
 
 
-class PiglitCLTest(PiglitBaseTest):
-    """ OpenCL specific Test class """
-    pass
+class PiglitCLTest(PiglitBaseTest):  # pylint: disable=too-few-public-methods
+    """ OpenCL specific Test class.
+
+    Set concurrency based on CL requirements.
+
+    """
+    def __init__(self, command, run_concurrent=CL_CONCURRENT, **kwargs):
+        super(PiglitCLTest, self).__init__(command, run_concurrent, **kwargs)
diff --git a/tests/cl.py b/tests/cl.py
index 68c18a1..14fa2e3 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -10,8 +10,6 @@
 from __future__ import division, absolute_import, print_function
 
 import os
-import sys
-import glob
 
 from framework.profile import TestProfile
 from framework.test import PiglitCLTest
@@ -21,34 +19,18 @@ from .py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
 __all__ = ['profile']
 
 
-can_do_concurrent = (not sys.platform.startswith('linux') or
-                     glob.glob('/dev/dri/render*'))
-
-
-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.
-
-    """
-    if 'run_concurrent' is not False:
-        kwargs['run_concurrent'] = can_do_concurrent
-    return PiglitCLTest(*args, **kwargs)
-
-
 profile = TestProfile()
 
 
 # Custom
-with profile.group_manager(cl_test, 'custom') as g:
+with profile.group_manager(PiglitCLTest, '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:
+with profile.group_manager(PiglitCLTest, 'api') as g:
     # Platform
     g(['cl-api-get-platform-ids'], 'clGetPlatformIDs')
     g(['cl-api-get-platform-info'], 'clGetPlatformInfo')
@@ -105,7 +87,7 @@ with profile.group_manager(cl_test, 'api') as g:
     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:
+with profile.group_manager(PiglitCLTest, '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')
@@ -117,7 +99,7 @@ def add_program_test_dir(group, dirpath):
         if ext not in ['.cl', '.program_test']:
             continue
 
-        profile.test_list[grouptools.join(group, testname)] = cl_test(
+        profile.test_list[grouptools.join(group, testname)] = PiglitCLTest(
             ['cl-program-tester', os.path.join(dirpath, filename)])
 
 
-- 
2.3.0



More information about the Piglit mailing list