[Piglit] [PATCH 10/15] piglit_test.py: Automatically add -auto and -fbo when appropriate

Dylan Baker baker.dylan.c at gmail.com
Fri Oct 3 17:57:51 PDT 2014


There is a lot of logic in all.py to add -auto and possible -fbo to
tests when it is appropriate. This is rather silly as we can just make
the test class do this for us, which has the added advantage of reducing
the amount of memory each test needs by reducing the number of strings
stored by each instance.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/test/glsl_parser_test.py        |  4 ++--
 framework/test/piglit_test.py             |  8 ++++++++
 framework/test/shader_test.py             | 12 ++++++++----
 framework/tests/glsl_parser_test_tests.py |  6 +++---
 framework/tests/piglit_test_tests.py      | 13 +++++++++++++
 framework/tests/shader_test_tests.py      |  6 ++++++
 6 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index 1c2d175..2c48888 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -27,7 +27,7 @@ import os.path as path
 import re
 import sys
 
-from .piglit_test import PiglitGLTest
+from .piglit_test import PiglitBaseTest
 
 __all__ = [
     'GLSLParserTest',
@@ -73,7 +73,7 @@ def import_glsl_parser_tests(group, basepath, subdirectories):
                     add_glsl_parser_test(group, filepath, testname)
 
 
-class GLSLParserTest(PiglitGLTest):
+class GLSLParserTest(PiglitBaseTest):
     """ Read the options in a glsl parser test and create a Test object
 
     Specifically it is necessary to parse a glsl_parser_test to get information
diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index a232634..c742271 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -88,6 +88,14 @@ class PiglitGLTest(WindowResizeMixin, PiglitBaseTest):
                 return True
         return False
 
+    @PiglitBaseTest.command.getter
+    def command(self):
+        """ Automatically add -auto and -fbo as appropriate """
+        if not self.run_concurrent:
+            return super(PiglitGLTest, self).command + ['-auto']
+        else:
+            return super(PiglitGLTest, self).command + ['-auto', '-fbo']
+
 
 class PiglitCLTest(PiglitBaseTest):
     """ OpenCL specific Test class """
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index b9453bc..fbb0c7f 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -27,7 +27,7 @@ import os
 import os.path as path
 import re
 
-from .piglit_test import PiglitGLTest
+from .piglit_test import PiglitBaseTest
 
 __all__ = [
     'ShaderTest',
@@ -37,7 +37,7 @@ __all__ = [
 ]
 
 
-class ShaderTest(PiglitGLTest):
+class ShaderTest(PiglitBaseTest):
     """ Parse a shader test file and return a PiglitTest instance
 
     This function parses a shader test to determine if it's a GL, GLES2 or
@@ -87,8 +87,12 @@ class ShaderTest(PiglitGLTest):
             else:
                 raise ShaderTestParserException("No GL version set")
 
-        super(ShaderTest, self).__init__([prog, arguments, '-auto'],
-                                         run_concurrent=True)
+        super(ShaderTest, self).__init__([prog, arguments], run_concurrent=True)
+
+    @PiglitBaseTest.command.getter
+    def command(self):
+        """ Add -auto to the test command """
+        return self._command + ['-auto']
 
 
 class ShaderTestParserException(Exception):
diff --git a/framework/tests/glsl_parser_test_tests.py b/framework/tests/glsl_parser_test_tests.py
index ea13928..4eebc23 100644
--- a/framework/tests/glsl_parser_test_tests.py
+++ b/framework/tests/glsl_parser_test_tests.py
@@ -111,9 +111,9 @@ def test_cpp_comments():
                '// [end config]\n')
     test, name = _check_config(content)
 
-    nt.assert_equal(test.command, [os.path.join(TEST_BIN_DIR, 'glslparsertest'),
-                                   name, 'pass', '1.00'],
-                    msg="C++ style comments were not properly parsed")
+    nt.assert_equal(
+        test.command,
+        [os.path.join(TEST_BIN_DIR, 'glslparsertest'), name, 'pass', '1.00'])
 
 
 def test_c_comments():
diff --git a/framework/tests/piglit_test_tests.py b/framework/tests/piglit_test_tests.py
index f4f5bbc..102b5ef 100644
--- a/framework/tests/piglit_test_tests.py
+++ b/framework/tests/piglit_test_tests.py
@@ -70,3 +70,16 @@ def test_piglitest_no_clobber():
 
     nt.assert_dict_equal(test.result['subtest'],
                          {'test1': 'pass', 'test2': 'pass'})
+
+
+def test_piglittest_command_getter_serial():
+    """ PiglitGLTest.command adds -auto to serial tests """
+    test = PiglitGLTest('foo')
+    nt.assert_in('-auto', test.command)
+
+
+def test_piglittest_command_getter_concurrent():
+    """ PiglitGLTest.command adds -fbo and -auto to concurrent tests """
+    test = PiglitGLTest('foo', run_concurrent=True)
+    nt.assert_in('-auto', test.command)
+    nt.assert_in('-fbo', test.command)
diff --git a/framework/tests/shader_test_tests.py b/framework/tests/shader_test_tests.py
index c7c7663..e627b67 100644
--- a/framework/tests/shader_test_tests.py
+++ b/framework/tests/shader_test_tests.py
@@ -81,3 +81,9 @@ def test_add_shader_test():
 def test_add_shader_test_dir():
     """ Test that add_shader_test_dir works """
     testm.add_shader_test_dir({}, 'tests/spec/glsl-es-3.00/execution')
+
+
+def test_add_fbo():
+    """ ShaderTest.command adds -auto """
+    test = testm.ShaderTest('tests/spec/glsl-es-1.00/execution/sanity.shader_test')
+    nt.assert_in('-auto', test.command)
-- 
2.1.2



More information about the Piglit mailing list