summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-03-27 11:20:02 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-05-01 14:28:22 -0700
commit8c79770317389fe7a31f689da94523d43e8e6da7 (patch)
tree48630cde4dc4db83a3a57f078d9baaa7a6951531
parenta3ddc62114168ce39a30965298ce95349889f67d (diff)
framework/test: Split multishader too
Tested-by: Rafael Antognolli <rafael.antognolli@intel.com>
-rw-r--r--framework/test/shader_test.py63
-rw-r--r--tests/all.py2
-rw-r--r--unittests/framework/test/test_shader_test.py17
3 files changed, 59 insertions, 23 deletions
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index 64edb58c5..3dc2c3987 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -201,11 +201,22 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
filenames -- a list of absolute paths to shader test files
"""
- def __init__(self, filenames):
+ def __init__(self, prog, files, subtests, skips):
+ super(MultiShaderTest, self).__init__(
+ [prog] + files,
+ subtests=subtests,
+ run_concurrent=True)
+
+ self.prog = prog
+ self.files = files
+ self.subtests = subtests
+ self.skips = [FastSkip(**s) for s in skips]
+
+ @classmethod
+ def new(cls, filenames):
# TODO
assert filenames
prog = None
- files = []
subtests = []
skips = []
@@ -215,7 +226,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
for each in filenames:
parser = Parser(each)
parser.parse()
- subtest = os.path.basename(os.path.splitext(each)[0]).lower()
+ subtests.append(os.path.basename(os.path.splitext(each)[0]).lower())
if prog is not None:
# This allows mixing GLES2 and GLES3 shader test files
@@ -236,30 +247,42 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
else:
prog = parser.prog
+ skips.append({
+ 'gl_required': parser.gl_required,
+ 'gl_version': parser.gl_version,
+ 'glsl_version': parser.glsl_version,
+ 'gles_version': parser.gles_version,
+ 'glsl_es_version': parser.glsl_es_version,
+ })
+
+ return cls(prog, filenames, subtests, skips)
+
+ def _process_skips(self):
+ r_files = []
+ r_subtests = []
+ r_skips = []
+ for f, s, k in zip(self.files, self.subtests, self.skips):
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()
+ k.test()
except TestIsSkip:
- skips.append(subtest)
- continue
- files.append(parser.filename)
- subtests.append(subtest)
+ r_skips.append(s)
+ else:
+ r_files.append(f)
+ r_subtests.append(s)
- assert len(subtests) + len(skips) == len(filenames), \
+ assert len(r_subtests) + len(r_skips) == len(self.files), \
'not all tests accounted for'
- super(MultiShaderTest, self).__init__(
- [prog] + files,
- subtests=subtests,
- run_concurrent=True)
-
- for name in skips:
+ for name in r_skips:
self.result.subtests[name] = status.SKIP
+ self._expected = r_subtests
+ self._command = [self._command[0]] + r_files
+
+ def run(self):
+ self._process_skips()
+ super(MultiShaderTest, self).run()
+
@PiglitBaseTest.command.getter # pylint: disable=no-member
def command(self):
"""Add -auto to the test command."""
diff --git a/tests/all.py b/tests/all.py
index f8a1d8d2c..b9f34b8b7 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -339,7 +339,7 @@ for group, files in six.iteritems(shader_tests):
group, os.path.basename(os.path.splitext(files[0])[0]))
profile.test_list[group] = ShaderTest.new(files[0])
else:
- profile.test_list[group] = MultiShaderTest(files)
+ profile.test_list[group] = MultiShaderTest.new(files)
# Collect and add all asmparsertests
diff --git a/unittests/framework/test/test_shader_test.py b/unittests/framework/test/test_shader_test.py
index c7a8da223..49caecbde 100644
--- a/unittests/framework/test/test_shader_test.py
+++ b/unittests/framework/test/test_shader_test.py
@@ -33,6 +33,7 @@ except ImportError:
import pytest
import six
+from framework import status
from framework.test import shader_test
# pylint: disable=invalid-name,no-self-use,protected-access
@@ -242,7 +243,7 @@ class TestMultiShaderTest(object):
[vertex shader]"""))
- return shader_test.MultiShaderTest(
+ return shader_test.MultiShaderTest.new(
[six.text_type(one), six.text_type(two)])
def test_prog(self, inst):
@@ -268,10 +269,11 @@ class TestMultiShaderTest(object):
two.write(textwrap.dedent("""\
[require]
GLSL >= 4.0
+ GL_ARB_ham_sandwhich
[vertex shader]"""))
- return shader_test.MultiShaderTest(
+ return shader_test.MultiShaderTest.new(
[six.text_type(one), six.text_type(two)])
def test_resume(self, inst):
@@ -279,3 +281,14 @@ class TestMultiShaderTest(object):
assert os.path.basename(actual[0]) == 'shader_runner'
assert os.path.basename(actual[1]) == 'bar.shader_test'
assert os.path.basename(actual[2]) == '-auto'
+
+ def test_skips_set(self, inst):
+ assert inst.skips[0].glsl_version == 3.0
+ assert inst.skips[1].glsl_version == 4.0
+ assert inst.skips[1].gl_required == {'GL_ARB_ham_sandwhich'}
+
+ def test_process_skips(self, inst):
+ expected = {'bar': status.SKIP, 'foo': status.NOTRUN}
+ with mock.patch.object(inst.skips[0].info, 'glsl_version', 3.0):
+ inst._process_skips()
+ assert dict(inst.result.subtests) == expected