[Piglit] [PATCH v2] framework/test/opengl.py: Fix opengl fast-skipping wflinfo errors

Jose Fonseca jfonseca at vmware.com
Wed Dec 9 00:03:50 PST 2015


On 08/12/15 00:56, baker.dylan.c at gmail.com wrote:
> From: Dylan Baker <baker.dylan.c at gmail.com>
>
> This extends the version handling methods of the WflInfo class to handle
> two kinds of errors. First, it handles getting a patch version in OpenGL
> and GLSL version strings.

 > Second, it handles getting back
> WFLINFO_GL_ERROR, such as is returned on the nvidia blob driver because
> of the patch version.

For the record, I saw WFLINFO_GL_ERROR with Mesa X11 libGL.so. But, yes, 
NVIDIA probably has the same too.

>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>
> I'm planning to push this at the end of the day to fix the issues with
> the blob drivers unless anyone objects. (that's in about an hour)
>
>   framework/test/opengl.py        | 46 +++++++++++++++------
>   framework/tests/opengl_tests.py | 88 +++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 123 insertions(+), 11 deletions(-)
>
> diff --git a/framework/test/opengl.py b/framework/test/opengl.py
> index 29da2d1..a3648ee 100644
> --- a/framework/test/opengl.py
> +++ b/framework/test/opengl.py
> @@ -170,8 +170,14 @@ class WflInfo(object):
>                       break
>                   raise
>               else:
> -                ret = float(self.__getline(
> -                    raw.split('\n'), 'OpenGL version string').split()[3])
> +                try:
> +                    # Grab the GL version string, trim any release_number values
> +                    ret = float(self.__getline(
> +                        raw.split('\n'),
> +                        'OpenGL version string').split()[3][:3])
> +                except (IndexError, ValueError):
> +                    # This is caused by wlfinfo returning an error
> +                    pass

In the future, it's probably worth considering using regular expressions.

With that you can ensure that, if the regex matches, float extraction 
and conversion should invariable fail.

It could also simplify and compaact code -- you could even pass the 
regex object as an argument to __call_wflinfo.

Anyway, just a thought for the future.

>                   break
>           return ret
>
> @@ -202,8 +208,15 @@ class WflInfo(object):
>                       break
>                   raise
>               else:
> -                ret = float(self.__getline(
> -                    raw.split('\n'), 'OpenGL version string').split()[5])
> +                try:
> +                    # Yes, search for "OpenGL version string" in GLES
> +                    # GLES doesn't support patch versions.
> +                    ret = float(self.__getline(
> +                        raw.split('\n'),
> +                        'OpenGL version string').split()[5])
> +                except (IndexError, ValueError):
> +                    # This is caused by wlfinfo returning an error
> +                    pass
>                   break
>           return ret
>
> @@ -222,8 +235,14 @@ class WflInfo(object):
>                       break
>                   raise
>               else:
> -                ret = float(self.__getline(
> -                    raw.split('\n'), 'OpenGL shading language').split()[-1])
> +                try:
> +                    # GLSL versions are M.mm formatted
> +                    ret = float(self.__getline(
> +                        raw.split('\n'),
> +                        'OpenGL shading language').split()[-1][:4])
> +                except (IndexError, ValueError):
> +                    # This is caused by wflinfo returning an error
> +                    pass
>                   break
>           return ret
>
> @@ -241,11 +260,16 @@ class WflInfo(object):
>                       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])
> +                try:
> +                    # 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])
> +                except (IndexError, ValueError):
> +                    # Handle wflinfo internal errors
> +                    pass
>                   break
>           return ret
>
> diff --git a/framework/tests/opengl_tests.py b/framework/tests/opengl_tests.py
> index 97daf2b..bec44c0 100644
> --- a/framework/tests/opengl_tests.py
> +++ b/framework/tests/opengl_tests.py
> @@ -137,6 +137,94 @@ class TestWflInfo(object):
>                           mock.Mock(return_value=rv)):
>               nt.eq_(5.0, self._test.glsl_es_version)
>
> +    def test_gl_version_patch(self):
> +        """test.opengl.WflInfo.gl_version: Works with patch versions"""
> +        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: 18.0.1 (Core Profile) Mesa 11.0.4\n'
> +            'OpenGL context flags: 0x0\n'
> +        )
> +        with mock.patch('framework.test.opengl.subprocess.check_output',
> +                        mock.Mock(return_value=rv)):
> +            nt.eq_(18.0, self._test.gl_version)
> +
> +    def test_glsl_version_patch(self):
> +        """test.opengl.WflInfo.glsl_version: Works with patch versions"""
> +        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.7\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_gl_version_err(self):
> +        """test.opengl.WflInfo.gl_version: handles errors correctly"""
> +        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: WFLINFO_GL_ERROR\n'
> +            'OpenGL context flags: 0x0\n'
> +        )
> +        with mock.patch('framework.test.opengl.subprocess.check_output',
> +                        mock.Mock(return_value=rv)):
> +            nt.eq_(None, self._test.gl_version)
> +
> +    def test_gles_version_err(self):
> +        """test.opengl.WflInfo.gles_version: handles errors correctly"""
> +        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: WFLINFO_GL_ERROR\n'
> +        )
> +        with mock.patch('framework.test.opengl.subprocess.check_output',
> +                        mock.Mock(return_value=rv)):
> +            nt.eq_(None, self._test.gles_version)
> +
> +    def test_glsl_version_err(self):
> +        """test.opengl.WflInfo.glsl_version: handles errors correctly"""
> +        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: WFLINFO_GL_ERROR\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_(None, self._test.glsl_version)
> +
> +    def test_glsl_es_version_err(self):
> +        """test.opengl.WflInfo.glsl_es_version: handles errors correctly"""
> +        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: WFLINFO_GL_ERROR\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_(None, self._test.glsl_es_version)
> +

Please add a test case for this one, just in case:

$ wflinfo --platform glx --api gles3
Waffle platform: glx
Waffle api: gles3
OpenGL vendor string: WFLINFO_GL_ERROR
OpenGL renderer string: WFLINFO_GL_ERROR
OpenGL version string: WFLINFO_GL_ERROR


>
>   class TestWflInfoOSError(object):
>       """Tests for the Wflinfo functions to handle OSErrors."""
>

Otherwise looks good.  Thanks.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

Jose


More information about the Piglit mailing list