[Piglit] [PATCH v2 15/16] framework: Plug in fast-skipping to MultiShaderTest

Dylan Baker dylan at pnwbakers.com
Fri Sep 30 21:17:48 UTC 2016


This adds fast-skipping support to the MultiShaderTest class. Both
patches seemed significant enough to warrant splitting them in two.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/test/base.py        |  8 +++++-
 framework/test/shader_test.py | 49 +++++++++++++++++++++++++++---------
 2 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/framework/test/base.py b/framework/test/base.py
index 224ca61..5f0491d 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -467,11 +467,17 @@ class ReducedProcessMixin(object):
     """
 
     def __init__(self, command, subtests=None, **kwargs):
-        assert subtests  # This covers both "not None" and len(subtests) > 1
+        assert subtests is not None
         super(ReducedProcessMixin, self).__init__(command, **kwargs)
         self._expected = subtests
         self._populate_subtests()
 
+    def is_skip(self):
+        """Skip if the length of expected is 0."""
+        if not self._expected:
+            raise TestIsSkip('All subtests skipped')
+        super(ReducedProcessMixin, self).is_skip()
+
     def __find_sub(self):
         """Helper for getting the next index."""
         return len([l for l in self.result.out.split('\n')
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index e72e2ec..447e8c0 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -32,8 +32,8 @@ import re
 
 from framework import exceptions
 from framework import status
-from .base import ReducedProcessMixin
-from .opengl import FastSkipMixin
+from .base import ReducedProcessMixin, TestIsSkip
+from .opengl import FastSkipMixin, FastSkip
 from .piglit_test import PiglitBaseTest
 
 __all__ = [
@@ -185,24 +185,49 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
     """
 
     def __init__(self, filenames):
-        # TODO fast skip.
-        parser = Parser(filenames[0])
-        parser.parse()
-        prog = parser.prog
-        files = [parser.filename]
-
-        for each in filenames[1:]:
+        assert filenames
+        prog = None
+        files = []
+        subtests = []
+        skips = []
+
+        # Walk each subtest, and either add it to the list of tests to run, or
+        # determine it is skip, and set the result of that test in the subtests
+        # dictionary to skip without adding it ot the liest of tests to run
+        for each in filenames:
             parser = Parser(each)
             parser.parse()
-            assert parser.prog == prog
+            subtest = os.path.basename(os.path.splitext(each)[0]).lower()
+
+            if prog is not None:
+                assert parser.prog == prog
+            else:
+                prog = parser.prog
+
+            try:
+                skipper = FastSkip(gl_required=parser.gl_required,
+                                   gl_version=parser.gl_version,
+                                   gles_version=parser.gles_version,
+                                   glsl_version=parser.glsl_version,
+                                   glsl_es_version=parser.glsl_es_version)
+                skipper.test()
+            except TestIsSkip:
+                skips.append(subtest)
+                continue
             files.append(parser.filename)
+            subtests.append(subtest)
+
+        assert len(subtests) + len(skips) == len(filenames), \
+            'not all tests accounted for'
 
         super(MultiShaderTest, self).__init__(
             [prog] + files,
-            subtests=[os.path.basename(os.path.splitext(f)[0]).lower()
-                      for f in filenames],
+            subtests=subtests,
             run_concurrent=True)
 
+        for name in skips:
+            self.result.subtests[name] = status.SKIP
+
     @PiglitBaseTest.command.getter  # pylint: disable=no-member
     def command(self):
         """Add -auto to the test command."""
-- 
git-series 0.8.10


More information about the Piglit mailing list