[Piglit] [PATCH 06/11] framework/test/opengl.py: Add GLSL and GLSL ES fast skipping
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Thu Nov 5 14:16:44 PST 2015
From: Dylan Baker <baker.dylan.c at gmail.com>
This adds support to the FastSKipMixin for checking GLSL and GLSL ES
versions.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/test/opengl.py | 58 +++++++++++++++++++
framework/tests/opengl_tests.py | 122 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 177 insertions(+), 3 deletions(-)
diff --git a/framework/test/opengl.py b/framework/test/opengl.py
index 2fe819b..29da2d1 100644
--- a/framework/test/opengl.py
+++ b/framework/test/opengl.py
@@ -207,6 +207,48 @@ class WflInfo(object):
break
return ret
+ @core.lazy_property
+ def glsl_version(self):
+ """Calculate the maximum OpenGL Shader Language version."""
+ ret = None
+ for profile in ['core', 'compat', 'none']:
+ try:
+ raw = self.__call_wflinfo(
+ ['--verbose', '--api', 'gl', '--profile', profile])
+ except StopWflinfo as e:
+ if e.reason == 'Called':
+ continue
+ elif e.reason == 'OSError':
+ break
+ raise
+ else:
+ ret = float(self.__getline(
+ raw.split('\n'), 'OpenGL shading language').split()[-1])
+ break
+ return ret
+
+ @core.lazy_property
+ def glsl_es_version(self):
+ """Calculate the maximum OpenGL ES Shader Language version."""
+ ret = None
+ for api in ['gles3', 'gles2']:
+ try:
+ raw = self.__call_wflinfo(['--verbose', '--api', api])
+ except StopWflinfo as e:
+ if e.reason == 'Called':
+ continue
+ elif e.reason == 'OSError':
+ break
+ raise
+ else:
+ # GLSL ES version numbering is insane.
+ # For version >= 3 the numbers are 3.00, 3.10, etc.
+ # For version 2, they are 1.0.xx
+ ret = float(self.__getline(
+ raw.split('\n'), 'OpenGL shading language').split()[-1][:3])
+ break
+ return ret
+
class FastSkipMixin(object):
"""Fast test skipping for OpenGL based suites.
@@ -277,4 +319,20 @@ class FastSkipMixin(object):
'but only {} is available'.format(
self.gles_version, self.__info.gles_version))
+ 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))
+
+ 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))
+
super(FastSkipMixin, self).is_skip()
diff --git a/framework/tests/opengl_tests.py b/framework/tests/opengl_tests.py
index 2a57a4d..97daf2b 100644
--- a/framework/tests/opengl_tests.py
+++ b/framework/tests/opengl_tests.py
@@ -30,7 +30,9 @@ import framework.tests.utils as utils
from framework.test import opengl
from framework.test.base import TestIsSkip
-# pylint: disable=invalid-name,protected-access,line-too-long,pointless-statement,attribute-defined-outside-init
+# pylint: disable=invalid-name,protected-access,line-too-long,
+# pylint: disable=pointless-statement,attribute-defined-outside-init
+# pylint: disable=too-many-public-methods
class TestWflInfo(object):
@@ -89,6 +91,52 @@ class TestWflInfo(object):
mock.Mock(return_value=rv)):
nt.eq_(7.1, self._test.gles_version)
+ def test_glsl_version(self):
+ """test.opengl.WflInfo.glsl_version: Provides a version number"""
+ rv = (
+ 'Waffle platform: gbm\n'
+ 'Waffle api: gl\n'
+ 'OpenGL vendor string: Intel Open Source Technology Center\n'
+ 'OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile\n'
+ 'OpenGL version string: 1.1 (Core Profile) Mesa 11.0.4\n'
+ 'OpenGL context flags: 0x0\n'
+ 'OpenGL shading language version string: 9.30\n'
+ 'OpenGL extensions: this is some extension strings.\n'
+ )
+ with mock.patch('framework.test.opengl.subprocess.check_output',
+ mock.Mock(return_value=rv)):
+ nt.eq_(9.3, self._test.glsl_version)
+
+ def test_glsl_es_version_1(self):
+ """test.opengl.WflInfo.glsl_es_version: works with gles2"""
+ rv = (
+ 'Waffle platform: gbm\n'
+ 'Waffle api: gles2\n'
+ 'OpenGL vendor string: Intel Open Source Technology Center\n'
+ 'OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile\n'
+ 'OpenGL version string: OpenGL ES 3.0 Mesa 11.0.4\n'
+ 'OpenGL shading language version string: OpenGL ES GLSL ES 1.0.17\n'
+ 'OpenGL extensions: this is some extension strings.\n'
+ )
+ with mock.patch('framework.test.opengl.subprocess.check_output',
+ mock.Mock(return_value=rv)):
+ nt.eq_(1.0, self._test.glsl_es_version)
+
+ def test_glsl_es_version_3plus(self):
+ """test.opengl.WflInfo.glsl_es_version: works with gles3"""
+ rv = (
+ 'Waffle platform: gbm\n'
+ 'Waffle api: gles3\n'
+ 'OpenGL vendor string: Intel Open Source Technology Center\n'
+ 'OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile\n'
+ 'OpenGL version string: OpenGL ES 3.0 Mesa 11.0.4\n'
+ 'OpenGL shading language version string: OpenGL ES GLSL ES 5.00\n'
+ 'OpenGL extensions: this is some extension strings.\n'
+ )
+ with mock.patch('framework.test.opengl.subprocess.check_output',
+ mock.Mock(return_value=rv)):
+ nt.eq_(5.0, self._test.glsl_es_version)
+
class TestWflInfoOSError(object):
"""Tests for the Wflinfo functions to handle OSErrors."""
@@ -123,15 +171,25 @@ class TestWflInfoOSError(object):
self.inst.gl_extensions
@utils.not_raises(OSError)
- def test_get_gl_version(self):
+ def test_gl_version(self):
"""test.opengl.WflInfo.get_gl_version: Handles OSError "no file" gracefully"""
self.inst.gl_version
@utils.not_raises(OSError)
- def test_get_gles_version(self):
+ def test_gles_version(self):
"""test.opengl.WflInfo.get_gles_version: Handles OSError "no file" gracefully"""
self.inst.gles_version
+ @utils.not_raises(OSError)
+ def test_glsl_version(self):
+ """test.opengl.WflInfo.glsl_version: Handles OSError "no file" gracefully"""
+ self.inst.glsl_version
+
+ @utils.not_raises(OSError)
+ def test_glsl_es_version(self):
+ """test.opengl.WflInfo.glsl_es_version: Handles OSError "no file" gracefully"""
+ self.inst.glsl_es_version
+
class TestWflInfoCalledProcessError(object):
"""Tests for the WflInfo functions to handle OSErrors."""
@@ -175,6 +233,16 @@ class TestWflInfoCalledProcessError(object):
"""test.opengl.WflInfo.gles_version: Handles CalledProcessError gracefully"""
self.inst.gles_version
+ @utils.not_raises(subprocess.CalledProcessError)
+ def test_glsl_version(self):
+ """test.opengl.WflInfo.glsl_version: Handles CalledProcessError gracefully"""
+ self.inst.glsl_version
+
+ @utils.not_raises(subprocess.CalledProcessError)
+ def test_glsl_es_version(self):
+ """test.opengl.WflInfo.glsl_es_version: Handles CalledProcessError gracefully"""
+ self.inst.glsl_es_version
+
class TestFastSkipMixin(object):
"""Tests for the FastSkipMixin class."""
@@ -281,3 +349,51 @@ class TestFastSkipMixin(object):
def test_max_gles_version_set(self):
"""test.opengl.FastSkipMixin.is_skip: runs if gles_version is None"""
self.test.is_skip()
+
+ @nt.raises(TestIsSkip)
+ def test_max_glsl_version_lt(self):
+ """test.opengl.FastSkipMixin.is_skip: skips if glsl_version > __max_glsl_version"""
+ self.test.glsl_version = 4.0
+ self.test.is_skip()
+
+ @utils.not_raises(TestIsSkip)
+ def test_max_glsl_version_gt(self):
+ """test.opengl.FastSkipMixin.is_skip: runs if glsl_version < __max_glsl_version"""
+ self.test.glsl_version = 1.0
+
+ @utils.not_raises(TestIsSkip)
+ def test_max_glsl_version_unset(self):
+ """test.opengl.FastSkipMixin.is_skip: runs if __max_glsl_version is None"""
+ self.test.glsl_version = 1.0
+ with mock.patch.object(self.test._FastSkipMixin__info, 'glsl_version', # pylint: disable=no-member
+ None):
+ self.test.is_skip()
+
+ @utils.not_raises(TestIsSkip)
+ def test_max_glsl_version_set(self):
+ """test.opengl.FastSkipMixin.is_skip: runs if glsl_version is None"""
+ self.test.is_skip()
+
+ @nt.raises(TestIsSkip)
+ def test_max_glsl_es_version_lt(self):
+ """test.opengl.FastSkipMixin.is_skip: skips if glsl_es_version > __max_glsl_es_version"""
+ self.test.glsl_es_version = 4.0
+ self.test.is_skip()
+
+ @utils.not_raises(TestIsSkip)
+ def test_max_glsl_es_version_gt(self):
+ """test.opengl.FastSkipMixin.is_skip: runs if glsl_es_version < __max_glsl_es_version"""
+ self.test.glsl_es_version = 1.0
+
+ @utils.not_raises(TestIsSkip)
+ def test_max_glsl_es_version_unset(self):
+ """test.opengl.FastSkipMixin.is_skip: runs if __max_glsl_es_version is None"""
+ self.test.glsl_es_version = 1.0
+ with mock.patch.object(self.test._FastSkipMixin__info, 'glsl_es_version', # pylint: disable=no-member
+ None):
+ self.test.is_skip()
+
+ @utils.not_raises(TestIsSkip)
+ def test_max_glsl_es_version_set(self):
+ """test.opengl.FastSkipMixin.is_skip: runs if glsl_es_version is None"""
+ self.test.is_skip()
--
2.6.2
More information about the Piglit
mailing list