summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-04-03 10:08:32 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-05-01 14:31:04 -0700
commit1be0b641b4dcc5f7c8922efd288aee86fa595856 (patch)
treec1a6b14674dd3adb60d7be5bcc4dd024754978fb
parent400dcd5cf18ac51ab8e9681d8ecab4132986efbd (diff)
shader_tests: correctly generate xml during out of tree builds
Tested-by: Rafael Antognolli <rafael.antognolli@intel.com>
-rw-r--r--framework/test/shader_test.py14
-rw-r--r--tests/shader.py31
2 files changed, 37 insertions, 8 deletions
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index dbad16be6..719b92f9d 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 0396c4c8d..3a43bcf93 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)