[Piglit] [PATCH 26/35] shader_tests: correctly generate xml during out of tree builds

Dylan Baker dylan at pnwbakers.com
Wed Apr 4 22:27:14 UTC 2018


---
 framework/test/shader_test.py | 14 ++++++++++----
 tests/shader.py               | 31 +++++++++++++++++++++++++++----
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index dbad16b..719b92f 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -167,12 +167,18 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
             glsl_es_version=glsl_es_version)
 
     @classmethod
-    def new(cls, filename):
+    def new(cls, filename, installed_name=None):
+        """Parse an XML file and create a new instance.
+
+        :param str filename: The name of the file to parse
+        :param str installed_name: The relative path to the file when installed
+            if not the same as the parsed name
+        """
         parser = Parser(filename)
         parser.parse()
 
         return cls(
-            [parser.prog, parser.filename],
+            [parser.prog, installed_name or filename],
             run_concurrent=True,
             gl_required=parser.gl_required,
             gl_version=parser.gl_version,
@@ -215,7 +221,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
         self.skips = [FastSkip(**s) for s in skips]
 
     @classmethod
-    def new(cls, filenames):
+    def new(cls, filenames, installednames=None):
         # TODO
         assert filenames
         prog = None
@@ -257,7 +263,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
                 'glsl_es_version': parser.glsl_es_version,
             })
 
-        return cls(prog, filenames, subtests, skips)
+        return cls(prog, installednames or filenames, subtests, skips)
 
     def _process_skips(self):
         r_files = []
diff --git a/tests/shader.py b/tests/shader.py
index 0396c4c..3a43bcf 100644
--- a/tests/shader.py
+++ b/tests/shader.py
@@ -6,6 +6,7 @@ from __future__ import (
 import collections
 import os
 
+from six.moves import zip
 import six
 
 from framework.options import OPTIONS
@@ -22,17 +23,26 @@ shader_tests = collections.defaultdict(list)
 
 # Find and add all shader tests.
 basepath = os.path.normpath(os.path.join(TESTS_DIR, '..'))
+gen_basepath = os.path.relpath(os.path.join(GENERATED_TESTS_DIR, '..'), basepath)
+
 for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
+    isgenerated = basedir == GENERATED_TESTS_DIR
     for dirpath, _, filenames in os.walk(basedir):
         groupname = grouptools.from_path(os.path.relpath(dirpath, basedir))
         for filename in filenames:
             testname, ext = os.path.splitext(filename)
             if ext == '.shader_test':
                 dirname = os.path.relpath(dirpath, basepath)
+                filepath = os.path.join(dirname, filename)
+                if isgenerated:
+                    installpath = os.path.relpath(filepath, gen_basepath)
+                else:
+                    installpath = None
+
                 if OPTIONS.process_isolation:
-                    test = ShaderTest.new(os.path.join(dirname, filename))
+                    test = ShaderTest.new(filepath, installpath)
                 else:
-                    shader_tests[groupname].append(os.path.join(dirname, filename))
+                    shader_tests[groupname].append((filepath, installpath))
                     continue
             else:
                 continue
@@ -46,11 +56,24 @@ for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
 # this dictionary is constructed, then added to the actual test dictionary.
 for group, files in six.iteritems(shader_tests):
     assert group not in profile.test_list, 'duplicate group: {}'.format(group)
+
+    # We'll end up with a list of tuples, split that into two lists
+    files, installedfiles = list(zip(*files))
+    files = list(files)
+    installedfiles = list(installedfiles)
+
     # If there is only one file in the directory use a normal shader_test.
     # Otherwise use a MultiShaderTest
     if len(files) == 1:
         group = grouptools.join(
             group, os.path.basename(os.path.splitext(files[0])[0]))
-        profile.test_list[group] = ShaderTest.new(files[0])
+        profile.test_list[group] = ShaderTest.new(files[0], installedfiles[0])
     else:
-        profile.test_list[group] = MultiShaderTest.new(files)
+        if all(i is None for i in installedfiles):
+            installedfiles = None
+        else:
+            for i, n in enumerate(installedfiles):
+                if n is None:
+                    installedfiles[i] = files[i]
+
+        profile.test_list[group] = MultiShaderTest.new(files, installedfiles)
-- 
git-series 0.9.1


More information about the Piglit mailing list