[Piglit] [PATCH 4/7] framework/test: Convert tests to new fast-skip interface

Dylan Baker dylan at pnwbakers.com
Mon Jun 25 23:29:03 UTC 2018


This converts the two test types that use the fast-skipping mechanism
(glsl parser and shader) to use the new interfaces. This has been
verified by running with PIGLIT_NO_FAST_SKIP=1 and without, and sans 1
test (that is fixed later in the series) the results are the same.
---
 framework/test/glsl_parser_test.py            |  54 +++--
 framework/test/opengl.py                      | 185 +++++++-----------
 framework/test/shader_test.py                 |  70 +++----
 .../framework/test/test_glsl_parser_test.py   |  47 +++--
 unittests/framework/test/test_opengl.py       | 172 ++++++++--------
 unittests/framework/test/test_shader_test.py  |  24 +--
 6 files changed, 263 insertions(+), 289 deletions(-)

diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index 21879739c..1cce65036 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -95,9 +95,9 @@ class Parser(object):
     def __init__(self, filepath, installpath=None):
         # a set that stores a list of keys that have been found already
         self.__found_keys = set()
-        self.gl_required = set()
-        self.glsl_es_version = None
-        self.glsl_version = None
+        self.api = None
+        self.extensions = set()
+        self.shader_version = None
         abs_filepath = os.path.join(ROOT_DIR, filepath)
 
         try:
@@ -115,29 +115,39 @@ class Parser(object):
         """Set OpenGL and OpenGL ES fast skipping conditions."""
         glsl = self.config['glsl_version']
         if _is_gles_version(glsl):
-            self.glsl_es_version = float(glsl[:3])
+            self.shader_version = float(glsl[:3])
+            if self.shader_version >= 3.0:
+                self.api = 'gles3'
+            else:
+                self.api = 'gles2'
         elif glsl.endswith('compatibility'):
-            self.glsl_version = float(glsl[:3])
+            self.shader_version = float(glsl[:3])
+            self.api = 'compat'
         else:
-            self.glsl_version = float(glsl)
+            self.shader_version = float(glsl)
+            self.api = 'core'
 
         req = self.config['require_extensions']
-        self.gl_required = set(r for r in req.split() if not r.startswith('!'))
+        self.extensions = set(r for r in req.split() if not r.startswith('!'))
+
+        if self.api != 'compat' and 'GL_ARB_compatibility' in self.extensions:
+            assert self.api == 'core', 'arb_compat with gles?'
+            self.api = 'compat'
 
         # If GLES is requested, but piglit was not built with a gles version,
         # then ARB_ES3<ver>_compatibility is required. Add it to
-        # self.gl_required
-        if self.glsl_es_version and _FORCE_DESKTOP_VERSION:
-            if self.glsl_es_version == 1.0:
+        # self.extensions
+        if self.api.startswith('gles') and _FORCE_DESKTOP_VERSION:
+            if self.shader_version == 1.0:
                 ver = '2'
-            elif self.glsl_es_version == 3.0:
+            elif self.shader_version == 3.0:
                 ver = '3'
-            elif self.glsl_es_version == 3.1:
+            elif self.shader_version == 3.1:
                 ver = '3_1'
-            elif self.glsl_es_version == 3.2:
+            elif self.shader_version == 3.2:
                 ver = '3_2'
             ext = 'ARB_ES{}_compatibility'.format(ver)
-            self.gl_required.add(ext)
+            self.extensions.add(ext)
             self.command.append(ext)
 
     @staticmethod
@@ -274,11 +284,13 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest):
                 .tesc, .tese, .geom or .frag
     """
 
-    def __init__(self, command, gl_required=set(), glsl_version=None,
-                 glsl_es_version=None, **kwargs):
+    def __init__(self, command, api=None, extensions=set(),
+                 shader_version=None, **kwargs):
         super(GLSLParserTest, self).__init__(
-            command, run_concurrent=True, gl_required=gl_required,
-            glsl_version=glsl_version, glsl_es_version=glsl_es_version)
+            command, run_concurrent=True,
+            api=api,
+            extensions=extensions,
+            shader_version=shader_version)
 
     @PiglitBaseTest.command.getter
     def command(self):
@@ -298,9 +310,9 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest):
         parsed = Parser(filepath, installpath)
         return cls(
             parsed.command,
-            gl_required=parsed.gl_required,
-            glsl_version=parsed.glsl_version,
-            glsl_es_version=parsed.glsl_es_version)
+            api=parsed.api,
+            extensions=parsed.extensions,
+            shader_version=parsed.shader_version)
 
     def is_skip(self):
         if os.path.basename(self.command[0]) == 'glslparsertest' and not _HAS_GL_BIN:
diff --git a/framework/test/opengl.py b/framework/test/opengl.py
index 4941d8ce8..3c8460e28 100644
--- a/framework/test/opengl.py
+++ b/framework/test/opengl.py
@@ -53,29 +53,22 @@ class FastSkip(object):
     all the tests that could have, but also a few that should have run.
 
     Keyword Arguments:
-    gl_required     -- This is a set of extensions that are required for
-                       running the test.
-    gl_version      -- A float that is the required version number for an
-                       OpenGL test.
-    gles_version    -- A float that is the required version number for an
-                       OpenGL ES test
-    glsl_version    -- A float that is the required version number of OpenGL
-                       Shader Language for a test
-    glsl_es_version -- A float that is the required version number of OpenGL ES
-                       Shader Language for a test
+    api            -- The API required.
+                      One of [gles1, gles2, gles3, core, compat]
+    extensions     -- A set of extensions required
+    api_version    -- The version of the API required
+    shader_version -- The versoin of the shader language required
     """
-    __slots__ = ['gl_required', 'gl_version', 'gles_version', 'glsl_version',
-                 'glsl_es_version']
+    __slots__ = ['api', 'extensions', 'api_version', 'shader_version']
 
     info = wflinfo.WflInfo()
 
-    def __init__(self, gl_required=None, gl_version=None, gles_version=None,
-                 glsl_version=None, glsl_es_version=None):
-        self.gl_required = gl_required or set()
-        self.gl_version = gl_version
-        self.gles_version = gles_version
-        self.glsl_version = glsl_version
-        self.glsl_es_version = glsl_es_version
+    def __init__(self, api=None, extensions=None, api_version=None,
+                 shader_version=None):
+        self.extensions = extensions or set()
+        self.api = api
+        self.api_version = api_version
+        self.shader_version = shader_version
 
     def test(self):
         """Skip this test if any of its feature requirements are unmet.
@@ -86,48 +79,39 @@ class FastSkip(object):
         Raises:
         TestIsSkip   -- if any of the conditions passed to self are false
         """
-        if self.info.gl_extensions:
-            for extension in self.gl_required:
-                if extension not in self.info.gl_extensions:
+        if not self.api:
+            check = self.info.compat
+        elif self.api in ['gles2', 'gles3']:
+            check = self.info.es2
+        elif self.api == 'gles1':
+            check = self.info.es1
+        else:
+            check = getattr(self.info, self.api)
+
+        if check.extensions:
+            for extension in self.extensions:
+                if extension not in check.extensions:
                     raise TestIsSkip(
                         'Test requires extension {} '
                         'which is not available'.format(extension))
 
         # TODO: Be able to handle any operator
-        if (self.info.gl_version is not None
-                and self.gl_version is not None
-                and self.gl_version > self.info.gl_version):
+        if (check.api_version is not None
+                and self.api_version is not None
+                and self.api_version > check.api_version):
             raise TestIsSkip(
-                'Test requires OpenGL version {}, '
+                'Test requires OpenGL {} version {}, '
                 'but only {} is available'.format(
-                    self.gl_version, self.info.gl_version))
+                    self.api, self.api_version, check.api_version))
 
         # TODO: Be able to handle any operator
-        if (self.info.gles_version is not None
-                and self.gles_version is not None
-                and self.gles_version > self.info.gles_version):
+        if (check.shader_version is not None
+                and self.shader_version is not None
+                and self.shader_version > check.shader_version):
             raise TestIsSkip(
-                'Test requires OpenGL ES version {}, '
+                'Test requires OpenGL {} Shader Language version {}, '
                 'but only {} is available'.format(
-                    self.gles_version, self.info.gles_version))
-
-        # TODO: Be able to handle any operator
-        if (self.info.glsl_version is not None
-                and self.glsl_version is not None
-                and self.glsl_version > self.info.glsl_version):
-            raise TestIsSkip(
-                'Test requires OpenGL Shader Language version {}, '
-                'but only {} is available'.format(
-                    self.glsl_version, self.info.glsl_version))
-
-        # TODO: Be able to handle any operator
-        if (self.info.glsl_es_version is not None
-                and self.glsl_es_version is not None
-                and self.glsl_es_version > self.info.glsl_es_version):
-            raise TestIsSkip(
-                'Test requires OpenGL ES Shader Language version {}, '
-                'but only {} is available'.format(
-                    self.glsl_es_version, self.info.glsl_es_version))
+                    self.api, self.shader_version, check.shader_version))
 
 
 class FastSkipMixin(object):
@@ -141,67 +125,36 @@ class FastSkipMixin(object):
     has all of the same requirements as that class.
 
     It also provides new attributes:
-    gl_required     -- This is a set of extensions that are required for
-                       running the test.
-    gl_version      -- A float that is the required version number for an
-                       OpenGL test.
-    gles_version    -- A float that is the required version number for an
-                       OpenGL ES test
-    glsl_version    -- A float that is the required version number of OpenGL
-                       Shader Language for a test
-    glsl_es_version -- A float that is the required version number of OpenGL ES
-                       Shader Language for a test
+    require_extensions -- A set of extensions that are requuired for running
+                          this test.
+    require_shader    -- The shader language version required.
+    reqiure_version   -- The API version required.
+    require_api       -- The API required.
     """
 
-    def __init__(self, command, gl_required=None, gl_version=None,
-                 gles_version=None, glsl_version=None, glsl_es_version=None,
-                 **kwargs):  # pylint: disable=too-many-arguments
+    def __init__(self, command, api=None, extensions=None, api_version=None,
+                 shader_version=None, **kwargs):
         super(FastSkipMixin, self).__init__(command, **kwargs)
-        self.__skiper = FastSkip(gl_required=gl_required,
-                                 gl_version=gl_version,
-                                 gles_version=gles_version,
-                                 glsl_version=glsl_version,
-                                 glsl_es_version=glsl_es_version)
+        self.__skiper = FastSkip(api=api,
+                                 extensions=extensions,
+                                 api_version=api_version,
+                                 shader_version=shader_version)
 
     @property
-    def gl_required(self):
-        return self.__skiper.gl_required
-
-    @gl_required.setter
-    def gl_required(self, new):
-        self.__skiper.gl_required = new
+    def require_extensions(self):
+        return self.__skiper.extensions
 
     @property
-    def gl_version(self):
-        return self.__skiper.gl_version
-
-    @gl_version.setter
-    def gl_version(self, new):
-        self.__skiper.gl_version = new
-
-    @property
-    def gles_version(self):
-        return self.__skiper.gles_version
-
-    @gles_version.setter
-    def gles_version(self, new):
-        self.__skiper.gles_version = new
+    def require_api(self):
+        return self.__skiper.api
 
     @property
-    def glsl_version(self):
-        return self.__skiper.glsl_version
-
-    @glsl_version.setter
-    def glsl_version(self, new):
-        self.__skiper.glsl_version = new
+    def require_shader(self):
+        return self.__skiper.shader_version
 
     @property
-    def glsl_es_version(self):
-        return self.__skiper.glsl_es_version
-
-    @glsl_es_version.setter
-    def glsl_es_version(self, new):
-        self.__skiper.glsl_es_version = new
+    def require_version(self):
+        return self.__skiper.api_version
 
     def is_skip(self):
         """Skip this test if any of its feature requirements are unmet.
@@ -217,32 +170,30 @@ class FastSkipMixin(object):
 class FastSkipDisabled(object):
     """A no-op version of FastSkip."""
 
-    __slots__ = ['gl_required', 'gl_version', 'gles_version', 'glsl_version',
-                 'glsl_es_version']
+    __slots__ = ['api', 'extensions', 'api_version', 'shader_version']
+
+    info = wflinfo.WflInfo()
 
-    def __init__(self, gl_required=None, gl_version=None, gles_version=None,
-                 glsl_version=None, glsl_es_version=None):
-        self.gl_required = gl_required or set()
-        self.gl_version = gl_version
-        self.gles_version = gles_version
-        self.glsl_version = glsl_version
-        self.glsl_es_version = glsl_es_version
+    def __init__(self, api=None, extensions=None, api_version=None,
+                 shader_version=None):
+        self.extensions = set()
+        self.api = api
+        self.api_version = api_version
+        self.shader_version = shader_version
 
     def test(self):
         pass
 
 
 class FastSkipMixinDisabled(object):
-    def __init__(self, command, gl_required=None, gl_version=None,
-                 gles_version=None, glsl_version=None, glsl_es_version=None,
-                 **kwargs):  # pylint: disable=too-many-arguments
+    def __init__(self, command, api=None, extensions=None, api_version=None,
+                 shader_version=None, **kwargs):
         # Tests that implement the FastSkipMixin expect to have these values
         # set, so just fill them in with the default values.
-        self.gl_required = set()
-        self.gl_version = None
-        self.gles_version = None
-        self.glsl_version = None
-        self.glsl_es_version = None
+        self.require_extensions = set()
+        self.require_shader = None
+        self.reqiure_version = None
+        self.require_api = None
 
         super(FastSkipMixinDisabled, self).__init__(command, **kwargs)
 
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index 719b92f9d..3d3cf2e06 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -46,17 +46,16 @@ class Parser(object):
 
     _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)')
+        r'^GL\s+(?P<profile>(ES|CORE|COMPAT))?\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.filename = filename
-        self.gl_required = set()
-        self._gl_version = None
-        self._gles_version = None
-        self._glsl_version = None
-        self._glsl_es_version = None
+        self.extensions = set()
+        self.api_version = None
+        self.shader_version = None
+        self.api = None
         self.prog = None
         self.__op = None
         self.__sl_op = None
@@ -86,29 +85,33 @@ class Parser(object):
 
         for line in lines:
             if line.startswith('GL_') and not line.startswith('GL_MAX'):
-                self.gl_required.add(line.strip())
+                self.extensions.add(line.strip())
                 continue
 
             # Find any GLES requirements.
-            if not (self._gl_version or self._gles_version):
+            if not self.api_version:
                 m = self._match_gl_version.match(line)
                 if m:
                     self.__op = m.group('op')
-                    if m.group('es'):
-                        self._gles_version = float(m.group('ver'))
+                    self.api_version = float(m.group('ver'))
+                    if m.group('profile') == 'ES':
+                        self.api = 'gles2'
+                    elif m.group('profile') == 'COMPAT':
+                        self.api = 'compat'
                     else:
-                        self._gl_version = float(m.group('ver'))
+                        self.api = 'core'
                     continue
 
-            if not (self._glsl_version or self._glsl_es_version):
+            if not self.shader_version:
                 # Find any GLSL requirements
                 m = self._match_glsl_version.match(line)
                 if m:
                     self.__sl_op = m.group('op')
+                    self.shader_version = float(m.group('ver'))
                     if m.group('es'):
-                        self._glsl_es_version = float(m.group('ver'))
-                    else:
-                        self._glsl_version = float(m.group('ver'))
+                        self.api = 'gles2'
+                    elif not self.api:
+                        self.api = 'core'
                     continue
 
             if line.startswith('['):
@@ -117,9 +120,10 @@ class Parser(object):
         # Select the correct binary to run the test, but be as conservative as
         # possible by always selecting the lowest version that meets the
         # criteria.
-        if self._gles_version:
+        if self.api == 'gles2':
             if self.__op in ['<', '<='] or (
-                    self.__op in ['=', '>='] and self._gles_version < 3):
+                    self.__op in ['=', '>='] and self.api_version is not None
+                    and self.api_version < 3):
                 self.prog = 'shader_runner_gles2'
             else:
                 self.prog = 'shader_runner_gles3'
@@ -154,17 +158,15 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
 
     """
 
-    def __init__(self, command, gl_required=set(), gl_version=None,
-                 gles_version=None, glsl_version=None, glsl_es_version=None,
-                 **kwargs):
+    def __init__(self, command, api=None, extensions=set(),
+                  shader_version=None, api_version=None, **kwargs):
         super(ShaderTest, self).__init__(
             command,
             run_concurrent=True,
-            gl_required=gl_required,
-            gl_version=gl_version,
-            gles_version=gles_version,
-            glsl_version=glsl_version,
-            glsl_es_version=glsl_es_version)
+            api=api,
+            extensions=extensions,
+            shader_version=shader_version,
+            api_version=api_version)
 
     @classmethod
     def new(cls, filename, installed_name=None):
@@ -180,11 +182,10 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
         return cls(
             [parser.prog, installed_name or filename],
             run_concurrent=True,
-            gl_required=parser.gl_required,
-            gl_version=parser.gl_version,
-            gles_version=parser.gles_version,
-            glsl_version=parser.glsl_version,
-            glsl_es_version=parser.glsl_es_version)
+            api=parser.api,
+            extensions=parser.extensions,
+            shader_version=parser.shader_version,
+            api_version=parser.api_version)
 
     @PiglitBaseTest.command.getter
     def command(self):
@@ -256,11 +257,10 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
                 prog = parser.prog
 
             skips.append({
-                'gl_required': parser.gl_required,
-                'gl_version': parser.gl_version,
-                'glsl_version': parser.glsl_version,
-                'gles_version': parser.gles_version,
-                'glsl_es_version': parser.glsl_es_version,
+                'extensions': parser.extensions,
+                'api_version': parser.api_version,
+                'shader_version': parser.shader_version,
+                'api': parser.api,
             })
 
         return cls(prog, installednames or filenames, subtests, skips)
diff --git a/unittests/framework/test/test_glsl_parser_test.py b/unittests/framework/test/test_glsl_parser_test.py
index bf217b186..a81a1fdb7 100644
--- a/unittests/framework/test/test_glsl_parser_test.py
+++ b/unittests/framework/test/test_glsl_parser_test.py
@@ -380,26 +380,47 @@ class TestGLSLParserTestSkipRequirements(object):
             // {}
             // [end config]""".format(version, extra)))
 
-    def test_glsl_version(self, tmpdir):
+    class TestShaderVersions:
+
+        @staticmethod
+        def write_config(filename, version='4.3', extra=''):
+            filename.write(textwrap.dedent("""\
+                // [config]
+                // expect_result: pass
+                // glsl_version: {}
+                // {}
+                // [end config]""".format(version, extra)))
+
+        def test_glsl(self, tmpdir):
+            p = tmpdir.join('test.frag')
+            self.write_config(p)
+            assert glsl.GLSLParserTest.new(six.text_type(p)).require_shader == 4.3
+
+        def test_glsl_es(self, tmpdir):
+            p = tmpdir.join('test.frag')
+            self.write_config(p, version='3.0')
+            assert glsl.GLSLParserTest.new(six.text_type(p)).require_shader == 3.0
+
+
+    @pytest.mark.parametrize(
+        "value,expected",
+        [('3.0', 'gles3'), ('1.0', 'gles2'), ('4.3', 'core'),
+         ('4.3 compatibility', 'compat')])
+    def test_apis(self, tmpdir, value, expected):
         p = tmpdir.join('test.frag')
-        self.write_config(p)
-        assert glsl.GLSLParserTest.new(six.text_type(p)).glsl_version == 4.3
+        self.write_config(p, version=value)
+        assert glsl.GLSLParserTest.new(six.text_type(p)).require_api == expected
 
-    def test_glsl_es_version(self, tmpdir):
-        p = tmpdir.join('test.frag')
-        self.write_config(p, version='3.0')
-        assert glsl.GLSLParserTest.new(six.text_type(p)).glsl_es_version == 3.0
-
-    def test_gl_required(self, tmpdir):
+    def test_require_extensions(self, tmpdir):
         p = tmpdir.join('test.frag')
         self.write_config(p, extra="require_extensions: GL_ARB_foo GL_ARB_bar")
-        assert glsl.GLSLParserTest.new(six.text_type(p)).gl_required == \
+        assert glsl.GLSLParserTest.new(six.text_type(p)).require_extensions == \
             {'GL_ARB_foo', 'GL_ARB_bar'}
 
-    def test_exclude_not_added_to_gl_required(self, tmpdir):
+    def test_exclude_not_added_to_require_extensions(self, tmpdir):
         p = tmpdir.join('test.frag')
         self.write_config(p, extra="require_extensions: GL_ARB_foo !GL_ARB_bar")
-        assert glsl.GLSLParserTest.new(six.text_type(p)).gl_required == \
+        assert glsl.GLSLParserTest.new(six.text_type(p)).require_extensions == \
             {'GL_ARB_foo'}
 
 
@@ -448,7 +469,7 @@ def test_add_compatibility_requirement_fastskip(version, extension, tmpdir,
     test = glsl.GLSLParserTest.new(six.text_type(p))
 
     # The arb_compat extension was added to the fast skipping arguments
-    assert extension in test.gl_required
+    assert extension in test.require_extensions
 
 
 
diff --git a/unittests/framework/test/test_opengl.py b/unittests/framework/test/test_opengl.py
index 59024edf1..c17c4c099 100644
--- a/unittests/framework/test/test_opengl.py
+++ b/unittests/framework/test/test_opengl.py
@@ -46,11 +46,12 @@ class TestFastSkipMixin(object):  # pylint: disable=too-many-public-methods
     def patch(self):
         """Create a Class with FastSkipMixin, but patch various bits."""
         _mock_wflinfo = mock.Mock(spec=wflinfo.WflInfo)
-        _mock_wflinfo.gl_version = 3.3
-        _mock_wflinfo.gles_version = 3.0
-        _mock_wflinfo.glsl_version = 3.3
-        _mock_wflinfo.glsl_es_version = 2.0
-        _mock_wflinfo.gl_extensions = set(['bar'])
+        _mock_wflinfo.core.api_version = 3.3
+        _mock_wflinfo.core.shader_version = 3.3
+        _mock_wflinfo.core.extensions = set(['bar'])
+        _mock_wflinfo.es2.api_version = 3.0
+        _mock_wflinfo.es2.shader_version = 2.0
+        _mock_wflinfo.es2.extensions = set(['bar'])
 
         with mock.patch('framework.test.opengl.FastSkip.info', _mock_wflinfo):
             yield
@@ -64,9 +65,9 @@ class TestFastSkipMixin(object):  # pylint: disable=too-many-public-methods
         Since you're not suppoed to be able to pass gl and gles version, this
         uses two seperate constructor calls.
         """
-        self._Test(['foo'], gl_required={'foo'}, gl_version=3, glsl_version=2)
-        self._Test(['foo'], gl_required={'foo'}, gles_version=3,
-                   glsl_es_version=2)
+        self._Test(['foo'], extensions={'foo'}, api_version=3, shader_version=2)
+        self._Test(['foo'], extensions={'foo'}, api_version=3,
+                   shader_version=2)
 
 
 class TestFastSkip(object):
@@ -76,24 +77,25 @@ class TestFastSkip(object):
     def patch(self):
         """Create a Class with FastSkipMixin, but patch various bits."""
         _mock_wflinfo = mock.Mock(spec=wflinfo.WflInfo)
-        _mock_wflinfo.gl_version = 3.3
-        _mock_wflinfo.gles_version = 3.0
-        _mock_wflinfo.glsl_version = 3.3
-        _mock_wflinfo.glsl_es_version = 2.0
-        _mock_wflinfo.gl_extensions = set(['bar'])
+        _mock_wflinfo.core.api_version = 3.3
+        _mock_wflinfo.core.shader_version = 3.3
+        _mock_wflinfo.core.extensions = set(['bar'])
+        _mock_wflinfo.es2.api_version = 3.0
+        _mock_wflinfo.es2.shader_version = 2.0
+        _mock_wflinfo.es2.extensions = set(['bar'])
 
         with mock.patch('framework.test.opengl.FastSkip.info', _mock_wflinfo):
             yield
 
     @pytest.fixture
     def inst(self):
-        return opengl.FastSkip()
+        return opengl.FastSkip(api='core')
 
     def test_should_skip(self, inst):
         """test.opengl.FastSkipMixin.test: Skips when requires is missing
         from extensions.
         """
-        inst.gl_required.add('foobar')
+        inst.extensions.add('foobar')
         with pytest.raises(_TestIsSkip):
             inst.test()
 
@@ -101,79 +103,79 @@ class TestFastSkip(object):
         """test.opengl.FastSkipMixin.test: runs when requires is in
         extensions.
         """
-        inst.gl_required.add('bar')
+        inst.extensions.add('bar')
         inst.test()
 
-    def test_max_gl_version_lt(self, inst):
-        """test.opengl.FastSkipMixin.test: skips if gl_version >
-        __max_gl_version.
+    def test_max_api_version_lt(self, inst):
+        """test.opengl.FastSkipMixin.test: skips if api_version >
+        __max_api_version.
         """
-        inst.gl_version = 4.0
+        inst.api_version = 4.0
         with pytest.raises(_TestIsSkip):
             inst.test()
 
-    def test_max_gl_version_gt(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if gl_version <
-        __max_gl_version.
+    def test_max_api_version_gt(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if api_version <
+        __max_api_version.
         """
-        inst.gl_version = 1.0
+        inst.api_version = 1.0
 
-    def test_max_gl_version_set(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if gl_version is None"""
+    def test_max_api_version_set(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if api_version is None"""
         inst.test()
 
-    def test_max_gles_version_lt(self, inst):
-        """test.opengl.FastSkipMixin.test: skips if gles_version >
-        __max_gles_version.
+    def test_max_api_version_lt(self, inst):
+        """test.opengl.FastSkipMixin.test: skips if api_version >
+        __max_api_version.
         """
-        inst.gles_version = 4.0
+        inst.api_version = 4.0
         with pytest.raises(_TestIsSkip):
             inst.test()
 
-    def test_max_gles_version_gt(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if gles_version <
-        __max_gles_version.
+    def test_max_api_version_gt(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if api_version <
+        __max_api_version.
         """
-        inst.gles_version = 1.0
+        inst.api_version = 1.0
 
-    def test_max_gles_version_set(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if gles_version is None"""
+    def test_max_api_version_set(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if api_version is None"""
         inst.test()
 
-    def test_max_glsl_version_lt(self, inst):
-        """test.opengl.FastSkipMixin.test: skips if glsl_version >
-        __max_glsl_version.
+    def test_max_shader_version_lt(self, inst):
+        """test.opengl.FastSkipMixin.test: skips if shader_version >
+        __max_shader_version.
         """
-        inst.glsl_version = 4.0
+        inst.shader_version = 4.0
         with pytest.raises(_TestIsSkip):
             inst.test()
 
-    def test_max_glsl_version_gt(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if glsl_version <
-        __max_glsl_version.
+    def test_max_shader_version_gt(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if shader_version <
+        __max_shader_version.
         """
-        inst.glsl_version = 1.0
+        inst.shader_version = 1.0
 
-    def test_max_glsl_version_set(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if glsl_version is None"""
+    def test_max_shader_version_set(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if shader_version is None"""
         inst.test()
 
-    def test_max_glsl_es_version_lt(self, inst):
-        """test.opengl.FastSkipMixin.test: skips if glsl_es_version >
-        __max_glsl_es_version.
+    def test_max_shader_version_lt(self, inst):
+        """test.opengl.FastSkipMixin.test: skips if shader_version >
+        __max_shader_version.
         """
-        inst.glsl_es_version = 4.0
+        inst.shader_version = 4.0
         with pytest.raises(_TestIsSkip):
             inst.test()
 
-    def test_max_glsl_es_version_gt(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if glsl_es_version <
-        __max_glsl_es_version.
+    def test_max_shader_version_gt(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if shader_version <
+        __max_shader_version.
         """
-        inst.glsl_es_version = 1.0
+        inst.shader_version = 1.0
 
-    def test_max_glsl_es_version_set(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if glsl_es_version is None"""
+    def test_max_shader_version_set(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if shader_version is None"""
         inst.test()
 
     class TestEmpty(object):
@@ -183,24 +185,25 @@ class TestFastSkip(object):
         def patch(self):
             """Create a Class with FastSkipMixin, but patch various bits."""
             _mock_wflinfo = mock.Mock(spec=wflinfo.WflInfo)
-            _mock_wflinfo.gl_version = None
-            _mock_wflinfo.gles_version = None
-            _mock_wflinfo.glsl_version = None
-            _mock_wflinfo.glsl_es_version = None
-            _mock_wflinfo.gl_extensions = set()
+            _mock_wflinfo.core.api_version = 0.0
+            _mock_wflinfo.core.shader_version = 0.0
+            _mock_wflinfo.core.extensions = set()
+            _mock_wflinfo.es2.api_version = 0.0
+            _mock_wflinfo.es2.shader_version = 0.0
+            _mock_wflinfo.es2.extensions = set()
 
             with mock.patch('framework.test.opengl.FastSkip.info', _mock_wflinfo):
                 yield
 
         @pytest.fixture
         def inst(self):
-            return opengl.FastSkip()
+            return opengl.FastSkip(api='core')
 
         def test_extension_empty(self, inst):
             """test.opengl.FastSkipMixin.test: if extensions are empty test
             runs.
             """
-            inst.gl_required.add('foobar')
+            inst.info.core.extensions.add('foobar')
             inst.test()
 
         def test_requires_empty(self, inst):
@@ -209,32 +212,18 @@ class TestFastSkip(object):
             """
             inst.test()
 
-        def test_max_gl_version_unset(self, inst):
-            """test.opengl.FastSkipMixin.test: runs if __max_gl_version is
-            None.
-            """
-            inst.gl_version = 1.0
-            inst.test()
-
-        def test_max_glsl_es_version_unset(self, inst):
-            """test.opengl.FastSkipMixin.test: runs if __max_glsl_es_version is
-            None.
-            """
-            inst.glsl_es_version = 1.0
-            inst.test()
-
-    def test_max_glsl_version_unset(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if __max_glsl_version is
+    def test_max_shader_version_unset(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if __max_shader_version is
         None.
         """
-        inst.glsl_version = 1.0
+        inst.shader_version = 1.0
         inst.test()
 
-    def test_max_gles_version_unset(self, inst):
-        """test.opengl.FastSkipMixin.test: runs if __max_gles_version is
+    def test_max_api_version_unset(self, inst):
+        """test.opengl.FastSkipMixin.test: runs if __max_api_version is
         None.
         """
-        inst.gles_version = 1.0
+        inst.api_version = 1.0
         inst.test()
 
 
@@ -245,11 +234,12 @@ class TestFastSkipMixinDisabled(object):
     def patch(self):
         """Create a Class with FastSkipMixin, but patch various bits."""
         _mock_wflinfo = mock.Mock(spec=wflinfo.WflInfo)
-        _mock_wflinfo.gl_version = 3.3
-        _mock_wflinfo.gles_version = 3.0
-        _mock_wflinfo.glsl_version = 3.3
-        _mock_wflinfo.glsl_es_version = 2.0
-        _mock_wflinfo.gl_extensions = set(['bar'])
+        _mock_wflinfo.es2.api_version = 3.3
+        _mock_wflinfo.es2.shader_version = 2.0
+        _mock_wflinfo.es2.extensions = set(['bar'])
+        _mock_wflinfo.core.api_version = 3.0
+        _mock_wflinfo.core.shader_version = 3.3
+        _mock_wflinfo.core.extensions = set(['bar'])
 
         with mock.patch('framework.test.opengl.FastSkip.info', _mock_wflinfo):
             yield
@@ -263,6 +253,6 @@ class TestFastSkipMixinDisabled(object):
         Since you're not suppoed to be able to pass gl and gles version, this
         uses two seperate constructor calls.
         """
-        self._Test(['foo'], gl_required={'foo'}, gl_version=3, glsl_version=2)
-        self._Test(['foo'], gl_required={'foo'}, gles_version=3,
-                   glsl_es_version=2)
+        self._Test(['foo'], extensions={'foo'}, api_version=3, shader_version=2)
+        self._Test(['foo'], extensions={'foo'}, api_version=3,
+                   shader_version=2)
diff --git a/unittests/framework/test/test_shader_test.py b/unittests/framework/test/test_shader_test.py
index 49caecbde..623088734 100644
--- a/unittests/framework/test/test_shader_test.py
+++ b/unittests/framework/test/test_shader_test.py
@@ -120,7 +120,7 @@ class TestConfigParsing(object):
             """))
         test = shader_test.ShaderTest.new(six.text_type(p))
 
-        assert test.gl_required == {'GL_ARB_ham_sandwhich'}
+        assert test.require_extensions == {'GL_ARB_ham_sandwhich'}
 
     def test_skip_gl_version(self, tmpdir):
         """test.shader_test.ShaderTest: finds gl_version."""
@@ -132,7 +132,7 @@ class TestConfigParsing(object):
             """))
         test = shader_test.ShaderTest.new(six.text_type(p))
 
-        assert test.gl_version == 2.0
+        assert test.require_version == 2.0
 
     def test_skip_gles_version(self, tmpdir):
         """test.shader_test.ShaderTest: finds gles_version."""
@@ -144,7 +144,7 @@ class TestConfigParsing(object):
             """))
         test = shader_test.ShaderTest.new(six.text_type(p))
 
-        assert test.gles_version == 2.0
+        assert test.require_version == 2.0
 
     def test_skip_glsl_version(self, tmpdir):
         """test.shader_test.ShaderTest: finds glsl_version."""
@@ -156,7 +156,7 @@ class TestConfigParsing(object):
             """))
         test = shader_test.ShaderTest.new(six.text_type(p))
 
-        assert test.glsl_version == 1.2
+        assert test.require_shader == 1.2
 
     def test_skip_glsl_es_version(self, tmpdir):
         """test.shader_test.ShaderTest: finds glsl_es_version."""
@@ -168,7 +168,7 @@ class TestConfigParsing(object):
             """))
         test = shader_test.ShaderTest.new(six.text_type(p))
 
-        assert test.glsl_es_version == 1.0
+        assert test.require_shader == 1.0
 
     def test_ignore_directives(self, tmpdir):
         """There are some directives for shader_runner that are not interpreted
@@ -188,9 +188,9 @@ class TestConfigParsing(object):
             """))
         test = shader_test.ShaderTest.new(six.text_type(p))
 
-        assert test.gl_version == 3.3
-        assert test.glsl_version == 1.50
-        assert test.gl_required == {'GL_ARB_foobar'}
+        assert test.require_version == 3.3
+        assert test.require_shader == 1.50
+        assert test.require_extensions == {'GL_ARB_foobar'}
 
 
 class TestCommand(object):
@@ -283,12 +283,12 @@ class TestMultiShaderTest(object):
         assert os.path.basename(actual[2]) == '-auto'
 
     def test_skips_set(self, inst):
-        assert inst.skips[0].glsl_version == 3.0
-        assert inst.skips[1].glsl_version == 4.0
-        assert inst.skips[1].gl_required == {'GL_ARB_ham_sandwhich'}
+        assert inst.skips[0].shader_version == 3.0
+        assert inst.skips[1].shader_version == 4.0
+        assert inst.skips[1].extensions == {'GL_ARB_ham_sandwhich'}
 
     def test_process_skips(self, inst):
         expected = {'bar': status.SKIP, 'foo': status.NOTRUN}
-        with mock.patch.object(inst.skips[0].info, 'glsl_version', 3.0):
+        with mock.patch.object(inst.skips[0].info.core, 'shader_version', 3.0):
             inst._process_skips()
         assert dict(inst.result.subtests) == expected
-- 
2.17.1



More information about the Piglit mailing list