summaryrefslogtreecommitdiff
path: root/framework/tests
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2015-11-02 16:14:55 -0800
committerDylan Baker <baker.dylan.c@gmail.com>2015-11-16 14:53:06 -0800
commit5cca94897d0e3642593d6c5908d88db33fd93ded (patch)
treea8c4db6f7eccab844cd5ae43fbfaec46d885c859 /framework/tests
parent8a32a0deb1226a4141a6598eca8e14cc7f0f46bd (diff)
framework/test/opengl.py: Add GLSL and GLSL ES fast skipping
This adds support to the FastSKipMixin for checking GLSL and GLSL ES versions. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework/tests')
-rw-r--r--framework/tests/opengl_tests.py122
1 files changed, 119 insertions, 3 deletions
diff --git a/framework/tests/opengl_tests.py b/framework/tests/opengl_tests.py
index 2a57a4d6e..97daf2b38 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()