[Piglit] [PATCH 08/11] framework/test/shader_test.py: add GL and GLES version fast skipping.

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


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

This implements a similar mechanism to check GL or GLES version support
on the current driver.

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

diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index e531f08..b74e71b 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -43,6 +43,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)')
 
     def __init__(self, filename):
         self.gl_required = set()
@@ -108,6 +110,15 @@ 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):
+                # Find any gles requirements
+                m = self._match_gl_version.match(line)
+                if m:
+                    if m.group('op') not in ['<', '<=']:
+                        if m.group('es'):
+                            self.gles_version = float(m.group('ver'))
+                        else:
+                            self.gl_version = float(m.group('ver'))
             elif line.startswith('['):
                 break
 
diff --git a/framework/tests/shader_test_tests.py b/framework/tests/shader_test_tests.py
index ebc76b3..e86e51f 100644
--- a/framework/tests/shader_test_tests.py
+++ b/framework/tests/shader_test_tests.py
@@ -106,7 +106,7 @@ def test_add_auto():
     nt.assert_in('-auto', test.command)
 
 
-def test_find_requirements():
+def test_find_requirements_gl_requirements():
     """test.shader_test.ShaderTest: populates gl_requirements properly"""
 
     data = ('[require]\n'
@@ -119,6 +119,30 @@ def test_find_requirements():
     nt.eq_(test.gl_required, set(['GL_ARB_ham_sandwhich']))
 
 
+def test_find_requirements_gl_version():
+    """test.shader_test.ShaderTest: finds gl_version."""
+    data = ('[require]\n'
+            'GL = 2.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.gl_version, 2.0)
+
+
+def test_find_requirements_gles_version():
+    """test.shader_test.ShaderTest: finds gles_version."""
+    data = ('[require]\n'
+            'GL ES = 2.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.gles_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