From 892f6e44723eda8d4f98ca8850f0fefee3e0f638 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 9 Aug 2016 11:42:56 -0700 Subject: framework: fix binary assignment for shader_runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the python layer tries to dispatch shader_tests to the right binary (gles2, gles3 or gl). But the implementation is pretty dumb. It basically assumes either >= or == are the only operators used, and makes wrong assignments for < or <=, which are allowed. Is also only understands 2.0 and 3.0 as GLES versions, which is problematic. This version uses the closes equivalent of a match statement that python has, to try to pick the right GLES version, otherwise it uses the GL version. It also shares this picking mechanism with the Fast Skip mechanism, so they always have the same result. Signed-off-by: Dylan Baker cc: mark.a.janes@intel.com cc: currojerez@riseup.net Tested-by: Michel Dänzer --- unittests/framework/test/test_shader_test.py | 44 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'unittests/framework/test') diff --git a/unittests/framework/test/test_shader_test.py b/unittests/framework/test/test_shader_test.py index bd54624dc..9cf8b6042 100644 --- a/unittests/framework/test/test_shader_test.py +++ b/unittests/framework/test/test_shader_test.py @@ -63,28 +63,40 @@ teardown_module = _setup.teardown class TestConfigParsing(object): """Tests for ShaderRunner config parsing.""" - def test_no_decimal(self, tmpdir): - """test.shader_test.ShaderTest: raises if version lacks decminal.""" + @pytest.mark.parametrize('gles,operator,expected', [ + # pylint: disable=bad-whitespace + ('2.0', '>=', 'shader_runner_gles2'), + ('2.0', '<=', 'shader_runner_gles2'), + ('2.0', '=', 'shader_runner_gles2'), + ('2.0', '>', 'shader_runner_gles3'), + ('3.0', '>=', 'shader_runner_gles3'), + ('3.0', '<=', 'shader_runner_gles2'), + ('3.0', '=', 'shader_runner_gles3'), + ('3.0', '>', 'shader_runner_gles3'), + ('3.0', '<', 'shader_runner_gles2'), + ('3.1', '>=', 'shader_runner_gles3'), + ('3.1', '<=', 'shader_runner_gles2'), + ('3.1', '=', 'shader_runner_gles3'), + ('3.1', '>', 'shader_runner_gles3'), + ('3.1', '<', 'shader_runner_gles2'), + ('3.2', '>=', 'shader_runner_gles3'), + ('3.2', '<=', 'shader_runner_gles2'), + ('3.2', '=', 'shader_runner_gles3'), + ('3.2', '<', 'shader_runner_gles2'), + ]) + def test_bin(self, gles, operator, expected, tmpdir): + """Test that the shader_runner parse picks the correct binary.""" p = tmpdir.join('test.shader_test') p.write(textwrap.dedent("""\ [require] - GL = 2 - """)) - - with pytest.raises(exceptions.PiglitFatalError): - shader_test.ShaderTest(six.text_type(p)) - - def test_gles2_bin(self, tmpdir): - """test.shader_test.ShaderTest: Identifies GLES2 tests successfully.""" - p = tmpdir.join('test.shader_test') - p.write(textwrap.dedent("""\ - [require] - GL ES >= 2.0 + GL ES {} {} GLSL ES >= 1.00 - """)) + + [next section] + """.format(operator, gles))) test = shader_test.ShaderTest(six.text_type(p)) - assert os.path.basename(test.command[0]) == "shader_runner_gles2" + assert os.path.basename(test.command[0]) == expected def test_gles3_bin(self, tmpdir): """test.shader_test.ShaderTest: Identifies GLES3 tests successfully.""" -- cgit v1.2.3