summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-03-26 15:22:12 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-05-01 14:28:17 -0700
commita3ddc62114168ce39a30965298ce95349889f67d (patch)
treefa3d21fd263ab09a4491ef1c32a41f7975f81e60
parentfd84fca6514d8f42232f91ee063915f3eed44e22 (diff)
framework: do the same for shader test
Tested-by: Rafael Antognolli <rafael.antognolli@intel.com>
-rw-r--r--framework/test/shader_test.py46
-rw-r--r--tests/all.py4
-rw-r--r--unittests/framework/test/test_shader_test.py20
3 files changed, 38 insertions, 32 deletions
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index a3fb8e209..64edb58c5 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -154,26 +154,31 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
"""
- def __init__(self, filename):
- if bool(os.environ.get('PIGLIT_NO_FAST_SKIP', False)):
- # No need to parse the shader test file if we've disabled
- # the FastSkip feature.
- super(ShaderTest, self).__init__(
- ['shader_runner', filename],
- run_concurrent=True,)
- else:
- parser = Parser(filename)
- parser.parse()
-
- super(ShaderTest, self).__init__(
- [parser.prog, parser.filename],
- run_concurrent=True,
- 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)
-
+ def __init__(self, command, gl_required=set(), gl_version=None,
+ gles_version=None, glsl_version=None, glsl_es_version=None,
+ **kwargs):
+ super(ShaderTest, self).__init__(
+ command,
+ run_concurrent=True,
+ gl_required=gl_required,
+ gl_version=gl_version,
+ gles_version=gles_version,
+ glsl_version=glsl_version,
+ glsl_es_version=glsl_es_version)
+
+ @classmethod
+ def new(cls, filename):
+ parser = Parser(filename)
+ parser.parse()
+
+ return cls(
+ [parser.prog, parser.filename],
+ run_concurrent=True,
+ 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)
@PiglitBaseTest.command.getter
def command(self):
@@ -197,6 +202,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
"""
def __init__(self, filenames):
+ # TODO
assert filenames
prog = None
files = []
diff --git a/tests/all.py b/tests/all.py
index 7b3a81ac5..f8a1d8d2c 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -305,7 +305,7 @@ for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
testname, ext = os.path.splitext(filename)
if ext == '.shader_test':
if PROCESS_ISOLATION:
- test = ShaderTest(os.path.join(dirpath, filename))
+ test = ShaderTest.new(os.path.join(dirpath, filename))
else:
shader_tests[groupname].append(os.path.join(dirpath, filename))
continue
@@ -337,7 +337,7 @@ for group, files in six.iteritems(shader_tests):
if len(files) == 1:
group = grouptools.join(
group, os.path.basename(os.path.splitext(files[0])[0]))
- profile.test_list[group] = ShaderTest(files[0])
+ profile.test_list[group] = ShaderTest.new(files[0])
else:
profile.test_list[group] = MultiShaderTest(files)
diff --git a/unittests/framework/test/test_shader_test.py b/unittests/framework/test/test_shader_test.py
index 163723129..c7a8da223 100644
--- a/unittests/framework/test/test_shader_test.py
+++ b/unittests/framework/test/test_shader_test.py
@@ -93,7 +93,7 @@ class TestConfigParsing(object):
[next section]
""".format(operator, gles)))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert os.path.basename(test.command[0]) == expected
@@ -105,7 +105,7 @@ class TestConfigParsing(object):
GL ES >= 3.0
GLSL ES >= 3.00 es
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert os.path.basename(test.command[0]) == "shader_runner_gles3"
@@ -117,7 +117,7 @@ class TestConfigParsing(object):
GL >= 3.0
GL_ARB_ham_sandwhich
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert test.gl_required == {'GL_ARB_ham_sandwhich'}
@@ -129,7 +129,7 @@ class TestConfigParsing(object):
GL >= 2.0
GL_ARB_ham_sandwhich
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert test.gl_version == 2.0
@@ -141,7 +141,7 @@ class TestConfigParsing(object):
GL ES >= 2.0
GL_ARB_ham_sandwhich
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert test.gles_version == 2.0
@@ -153,7 +153,7 @@ class TestConfigParsing(object):
GL >= 2.1
GLSL >= 1.20
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert test.glsl_version == 1.2
@@ -165,7 +165,7 @@ class TestConfigParsing(object):
GL ES >= 2.0
GLSL ES >= 1.00
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert test.glsl_es_version == 1.0
@@ -185,7 +185,7 @@ class TestConfigParsing(object):
GL_MAX_VARYING_COMPONENTS
GL_ARB_foobar
"""))
- test = shader_test.ShaderTest(six.text_type(p))
+ test = shader_test.ShaderTest.new(six.text_type(p))
assert test.gl_version == 3.3
assert test.glsl_version == 1.50
@@ -208,13 +208,13 @@ class TestCommand(object):
def test_getter_adds_auto_and_fbo(self, test_file):
"""test.shader_test.ShaderTest: -auto and -fbo is added to the command.
"""
- test = shader_test.ShaderTest(test_file)
+ test = shader_test.ShaderTest.new(test_file)
assert '-auto' in test.command
assert '-fbo' in test.command
def test_setter_doesnt_add_auto_and_fbo(self, test_file):
"""Don't add -fbo or -auto to self._command when using the setter."""
- test = shader_test.ShaderTest(test_file)
+ test = shader_test.ShaderTest.new(test_file)
test.command += ['-newarg']
assert '-auto' not in test._command
assert '-fbo' not in test._command