On Tue, Jun 24, 2014 at 7:54 PM, Dylan Baker <[email protected]> wrote:
> This is not a valid input, require_extensions is a space delimited list
> of extensions, raise a exception if these are requested.
>
> Signed-off-by: Dylan Baker <[email protected]>
> ---
> framework/glsl_parser_test.py | 7 +++++-
> framework/tests/glsl_parser_test_tests.py | 36
> +++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
> index 27fd2ca..52b87f1 100644
> --- a/framework/glsl_parser_test.py
> +++ b/framework/glsl_parser_test.py
> @@ -152,7 +152,12 @@ class GLSLParserTest(PiglitTest):
> config.get('config', 'glsl_version')]
> if config.get('config', 'check_link').lower() == 'true':
> command.append('--check-link')
> - command.extend(config.get('config',
> 'require_extensions').split())
> + required = config.get('config', 'require_extensions').split()
> + for x in required:
> + if x[-1] in [';', ',']:
It might be safe to just say if there's anything that's not
[A-Za-z0-9_\s]
in there, then that's no good. (And if you're pre-splitting, without
the \s.) Otherwise someone will invariably write
require_extensions: a ,b
or something else equally silly. You can use a pre-compiled regex to
speed things up a bit.
> + raise GLSLParserException('require_extensions cannot be '
> + 'seperated with "," or ";"')
> + command.extend(required)
>
> super(GLSLParserTest, self).__init__(command,
> run_concurrent=True)
>
> diff --git a/framework/tests/glsl_parser_test_tests.py
> b/framework/tests/glsl_parser_test_tests.py
> index 5e083b8..9794331 100644
> --- a/framework/tests/glsl_parser_test_tests.py
> +++ b/framework/tests/glsl_parser_test_tests.py
> @@ -144,3 +144,39 @@ def test_blank_in_config():
> def test_glslparser_initializer():
> """ GLSLParserTest initializes """
>
> glsl.GLSLParserTest('tests/spec/glsl-es-1.00/compiler/version-macro.frag')
> +
> +
> +def test_glslparser_require_trailing_comma():
> + """ GLSLParserTest() asserts if ',' are used on extensions """
> + content = ('// [config]\n'
> + '// expect_result: pass\n'
> + '// glsl_version: 1.00\n'
> + '// require_extensions: ARB_ham_sandwhich, ARB_pb&j\n'
> + '// [end config]\n')
> +
> + with utils.with_tempfile(content) as tfile:
> + with nt.assert_raises(glsl.GLSLParserException) as exc:
> + glsl.GLSLParserTest(tfile)
> + nt.assert_equal(
> + exc.exception,
> + 'require_extensions cannot be seperated with "," or ";"',
> + msg=("Exception not raised if ',' used to seperate"
> + "require_extensions"))
> +
> +
> +def test_glslparser_require_trailing_semicolon():
> + """ GLSLParserTest() asserts if ';' are used on extensions """
> + content = ('// [config]\n'
> + '// expect_result: pass\n'
> + '// glsl_version: 1.00\n'
> + '// require_extensions: ARB_ham_sandwhich; ARB_pb&j\n'
> + '// [end config]\n')
> +
> + with utils.with_tempfile(content) as tfile:
> + with nt.assert_raises(glsl.GLSLParserException) as exc:
> + glsl.GLSLParserTest(tfile)
> + nt.assert_equal(
> + exc.exception,
> + 'require_extensions cannot be seperated with "," or ";"',
> + msg=("Exception not raised if ';' used to seperate"
> + "require_extensions"))
> --
> 2.0.0
>
> _______________________________________________
> Piglit mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/piglit
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit