summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-06-20 12:06:55 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-09-20 06:37:10 -0700
commit1f9234b5329cd5adafc725fc18d82d5ed9a440f5 (patch)
treef38f10c0653171b73f90c0cf8b757c7b67ff6d9c /unittests
parent1627ac4e014a233fcef1cfc2da1815525d585606 (diff)
framework/test: Convert tests to new fast-skip interface
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.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/framework/test/test_glsl_parser_test.py47
-rw-r--r--unittests/framework/test/test_opengl.py172
-rw-r--r--unittests/framework/test/test_shader_test.py24
3 files changed, 127 insertions, 116 deletions
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