[Piglit] [PATCH 09/11] framework/test/shader_test.py: add GLSL (ES) based skipping.

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Thu Nov 5 14:16:47 PST 2015


From: Dylan Baker <baker.dylan.c at gmail.com>

This adds support to ShaderTest to scrape the GLSL requirements, and
provide them to the FasSkipMixin.

This reduces run time by ~15 seconds on my HSW.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/test/shader_test.py        | 21 +++++++++++++++++++--
 framework/tests/shader_test_tests.py | 26 ++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index b74e71b..dcfc16a 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -45,6 +45,8 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
     _is_gl = re.compile(r'GL (<|<=|=|>=|>) \d\.\d')
     _match_gl_version = re.compile(
         r'^GL\s+(?P<es>ES)?\s*(?P<op>(<|<=|=|>=|>))\s*(?P<ver>\d\.\d)')
+    _match_glsl_version = re.compile(
+        r'^GLSL\s+(?P<es>ES)?\s*(?P<op>(<|<=|=|>=|>))\s*(?P<ver>\d\.\d+)')
 
     def __init__(self, filename):
         self.gl_required = set()
@@ -110,7 +112,9 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
         for line in lines:
             if line.startswith('GL_') and not line.startswith('GL_MAX'):
                 self.gl_required.add(line.strip())
-            elif not (self.gl_version or self.gles_version):
+                continue
+
+            if not (self.gl_version or self.gles_version):
                 # Find any gles requirements
                 m = self._match_gl_version.match(line)
                 if m:
@@ -119,7 +123,20 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
                             self.gles_version = float(m.group('ver'))
                         else:
                             self.gl_version = float(m.group('ver'))
-            elif line.startswith('['):
+                        continue
+
+            if not (self.glsl_version or self.glsl_es_version):
+                # Find any GLSL requirements
+                m = self._match_glsl_version.match(line)
+                if m:
+                    if m.group('op') not in ['<', '<=']:
+                        if m.group('es'):
+                            self.glsl_es_version = float(m.group('ver'))
+                        else:
+                            self.glsl_version = float(m.group('ver'))
+                        continue
+
+            if line.startswith('['):
                 break
 
     @PiglitBaseTest.command.getter
diff --git a/framework/tests/shader_test_tests.py b/framework/tests/shader_test_tests.py
index e86e51f..25ae60d 100644
--- a/framework/tests/shader_test_tests.py
+++ b/framework/tests/shader_test_tests.py
@@ -143,6 +143,32 @@ def test_find_requirements_gles_version():
     nt.eq_(test.gles_version, 2.0)
 
 
+def test_find_requirements_glsl_version():
+    """test.shader_test.ShaderTest: finds glsl_version."""
+    data = ('[require]\n'
+            'GL = 2.0\n'
+            'GLSL >= 1.0\n'
+            'GL_ARB_ham_sandwhich\n')
+
+    with mock.patch('framework.test.shader_test.open',
+                    mock.mock_open(read_data=data)):
+        test = testm.ShaderTest('null')
+    nt.eq_(test.glsl_version, 1.0)
+
+
+def test_find_requirements_glsl_es_version():
+    """test.shader_test.ShaderTest: finds glsl_es_version."""
+    data = ('[require]\n'
+            'GL ES = 2.0\n'
+            'GLSL ES > 2.00\n'
+            'GL_ARB_ham_sandwhich\n')
+
+    with mock.patch('framework.test.shader_test.open',
+                    mock.mock_open(read_data=data)):
+        test = testm.ShaderTest('null')
+    nt.eq_(test.glsl_es_version, 2.0)
+
+
 @utils.nose_generator
 def test_ignore_shader_runner_directives():
     """test.shader_test.ShaderTest: Doesn't add shader_runner command to gl_required list"""
-- 
2.6.2



More information about the Piglit mailing list