aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gall <tom.gall@linaro.org>2012-12-13 14:17:22 -0600
committerTom Gall <tom.gall@linaro.org>2013-01-23 14:08:49 -0600
commitae066ce01039ab666a96f0a66201a73308ff111e (patch)
tree5ce0ed0396d47e403bb77a6e806231b86e6bac1f
parent9cafaf5cdbd7eef5bfe6d113383fe0bb5a36aa41 (diff)
downloadpiglit-ae066ce01039ab666a96f0a66201a73308ff111e.tar.gz
gles2, glsl: add gles2 support to glslparser test
Add GLSLESParserTest class which runs the gles2/gles3 version of glslparsertest. Why is this needed? The current GLSLParserTest class doesn't know about the gles2/gles3 varient of glslparsertest. The versioning of glsl_version in the config section of frags and vert shaders is conceptually incompatible for the GLSL ES versions. GLSLESParserTest extends the GLSLParserTest. Through good OO, this keeps the new code to a minimum and shares a lot of the GLSLParserTest implementation. Why? Consider. GLSL ES version 1.00 is approx equal to GLSL 1.20. However there are situations where a testcase that will pass on GLSL 1.20 but will fail under GLSL ES 1.00. Ex: tests/glslparsertest/shaders/CorrectConstruct.vert Embedded structure definitions are not allowed in GLSL ES 1.00 but are perfectly legal in GLSL 1.10. For both GLSL and GLSL ES this is a good testcase. This creates a situation where version comparisons between verions 1.00, 1.10, 1.20, etc just isn't going to work and expected results can be different for the same testcase. To deal with this situation, GLSLESParserTest looks for glsles_version in the config section. If not found, the test is skipped. If found, this version is passed into the glsl es version of glslparsertest. glsles_expect_result is also added as an option entry in the config section. If it is not present the expect_result is the same for GLSL and GLSL ES. If present the glsles_expect_result is passed into the appropriate GLSL ES version of glslparsertest.
-rwxr-xr-xframework/glsl_parser_test.py113
1 files changed, 108 insertions, 5 deletions
diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 66e6dd36..0f2309bd 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -21,12 +21,15 @@
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
-"""This module enables the running of GLSL parser tests.
+"""This module enables the running of GLSL and GLSL ES parser tests.
This module can be used to add parser tests to a Piglit test group or to run
-standalone tests on the command line. To add a test to a Piglit group, us
-``add_glsl_parser_test()``. To run a single standalone test, execute
+standalone tests on the command line. To add a test to a Piglit group, use
+``add_glsl_parser_test()``. To run a single standalone GLSL test, execute
``glsl_parser_test.py TEST_FILE``.
+To radd a test to the Piglit group for GLSL ES use
+``add_glsl_es_parser_test()``. To run a single standalone GLSL ES test,
+execute ``glsl_parser_test.py TEST_FILE es``.
"""
usage_message = "usage: glsl_parser_test.py TEST_FILE"
@@ -47,6 +50,10 @@ def add_glsl_parser_test(group, filepath, test_name):
"""Add an instance of GLSLParserTest to the given group."""
group[test_name] = GLSLParserTest(filepath)
+def add_glsl_es_parser_test(group, filepath, test_name):
+ """Add an instance of GLSLESParserTest to the given group."""
+ group[test_name] = GLSLESParserTest(filepath)
+
def import_glsl_parser_tests(group, basepath, subdirectories):
"""
Recursively register each shader source file in the given
@@ -383,12 +390,108 @@ class GLSLParserTest(PlainExecTest):
def env(self):
return dict()
+class GLSLESParserTest(GLSLParserTest):
+ """Extend GLSLParserTest by adding support for GLSL ES
+
+ This extension takes a GLSL source file and passes it to
+ ``glslparsertest_glesX`` where X is either 2 or 3 for GLES2 or
+ GLES3 respectively.
+
+ Config Section Extensions
+ -------------------------
+ The config section of the ``.vert``, or ``.frag`` is the same as
+ what is required for GLSLParserTest with the following extensions.
+
+ Required Option
+ ---------------
+ glsles_version: A valid GLSL ES version number such as 1.00.
+
+ Nonrequired Option
+ ------------------
+ glsles_expect_result: Either ``pass`` or ``fail``. If this
+ option is not specified expect_result will be used. This
+ option allows for GLSL and GLSL ES tests to have different
+ results and therefore reuse more testcases.
+
+ Examples
+ --------
+ ::
+ // [config]
+ // glsl_version: 1.20
+ // glsl_version: 1.00
+ // expect_result: pass
+ // [end config]
+ ::
+ /* [config]
+ * glsl_version: 1.10
+ * glsl_version: 1.00
+ * expect_result: pass
+ * glsles_expect_result: fail
+ * [end config]
+ */
+ """
+
+ _GLSLParserTest__config_defaults = {
+ 'require_extensions' : '',
+ 'check_link' : 'false',
+ 'glsles_expect_result' : 'ign',
+ 'glsles_version' : '0.00'
+ }
+
+ @property
+ def command(self):
+ """Command line arguments for 'glslparsertest_glesX'.
+
+ The command line arguments are constructed by parsing the
+ config section of the test file. If any errors are present in
+ the config section, then ``self.result`` is set to failure and
+ this returns ``None``.
+
+ :return: [str] or None
+ """
+
+ if self.result is not None:
+ return None
+
+ assert(self.config is not None)
+
+ if self.config.get('config','glsles_version') == '0.00':
+ return None
+
+ if self.config.get('config','glsles_version') == '1.00':
+ commandstr='glslparsertest_gles2'
+ elif self.config.get('config','glsles_version') == '3.00':
+ commandstr='glslparsertest_gles3'
+
+ if self.config.get('config','glsles_expect_result') != 'ign':
+ resultstr=self.config.get('config','glsles_expect_result')
+ else:
+ resultstr=self.config.get('config', 'expect_result')
+
+ command = [
+ path.join(testBinDir, commandstr),
+ self._GLSLParserTest__filepath,
+ resultstr,
+ self.config.get('config', 'glsles_version')
+ ]
+ if self.config.get('config', 'check_link').lower() == 'true':
+ command.append('--check-link')
+ command += self.config.get('config', 'require_extensions').split()
+ return command
+
if __name__ == '__main__':
- if len(sys.argv) != 2:
+ arglength=len(sys.argv)
+ if 3 > arglength < 2:
sys.stderr.write("{0}: usage error\n\n".format(sys.argv[0]))
sys.stderr.write(usage_message)
test_file = sys.argv[1]
- test = GLSLParserTest(test_file)
+ if arglength == 2:
+ test = GLSLParserTest(test_file)
+ elif arglength == 3:
+ if sys.argv[2] == "es":
+ test = GLSLESParserTest(test_file)
+ else:
+ sys.stderr.write("{0}: usage error\n\n".format(sys.argv[0]))
test.run_standalone()
# vim: noet ts=8 sw=8: