[Piglit] [PATCH 1/2] framework: Fix standalone execution of glsl_parser_test.py

Fabian Bieler fabianbieler at fastmail.fm
Wed Feb 26 15:19:00 PST 2014


On 2014-02-26 23:43, Dylan Baker wrote:
> On Wednesday, February 26, 2014 22:10:08 Fabian Bieler wrote:
>
>  > This is usefull when writing new tests using the glslparser framework.
>
> Dang, someone actually uses this...thing. I actually have patches on the
> list to remove it.
>
> I know that you're trying to solve the problem of running this from the
> framework folder, a la:
>
> cd framework
>
> ./glsl_parser_test.py foo
or just framework/glsl_parser_test.py bar from piglit root
>
> But it's making this module even more of a nightmare than it already is.
> idiomatically this is scary stuff.
>
> I think it would be better to write a little wrapper script that lives
> in the piglit root that can run tests standalone, perferably both
> shader_tests and glsl_parser_tests.
Fine by me, although I don't think the root folder should be polluted 
with a seldomly used tool like this. Maybe there's some other place the 
wrapper script could live.

I agree with Ilia that a wrapper around shader_runner is unnecessary.

> I'd be willing to code something up
> to do that.
That would be appreciated.

Fabian
>
>  >
>
>  > Signed-off-by: Fabian Bieler <fabianbieler at fastmail.fm>
>
>  > ---
>
>  > framework/glsl_parser_test.py | 11 ++++++++++-
>
>  > 1 file changed, 10 insertions(+), 1 deletion(-)
>
>  >
>
>  > diff --git a/framework/glsl_parser_test.py
> b/framework/glsl_parser_test.py
>
>  > index 82292b5..9b6ff24 100755
>
>  > --- a/framework/glsl_parser_test.py
>
>  > +++ b/framework/glsl_parser_test.py
>
>  > @@ -31,6 +31,14 @@ standalone tests on the command line. To add a
> test to a
>
>  > Piglit group, us
>
>  >
>
>  > usage_message = "usage: glsl_parser_test.py TEST_FILE"
>
>  >
>
>  > +if __name__ == '__main__':
>
>  > + import sys
>
>  > + import os.path as path
>
>  > + sys.path.insert(1, path.join(sys.path[0], '..'))
>
>  > + from framework import glsl_parser_test as self
>
>  > +
>
>  > + self._main()
>
>  > +
>
>  > import ConfigParser
>
>  > import os
>
>  > import os.path as path
>
>  > @@ -355,6 +363,7 @@ class GLSLParserTest(PlainExecTest):
>
>  > env[e] = str(self.env[e])
>
>  > p = subprocess.Popen(self.command, env=env)
>
>  > p.communicate()
>
>  > + sys.exit(p.returncode)
>
>  >
>
>  > @property
>
>  > def config(self):
>
>  > @@ -393,7 +402,7 @@ class GLSLParserTest(PlainExecTest):
>
>  > def env(self):
>
>  > return dict()
>
>  >
>
>  > -if __name__ == '__main__':
>
>  > +def _main():
>
>  > if len(sys.argv) != 2:
>
>  > sys.stderr.write("{0}: usage error\n\n".format(sys.argv[0]))
>
>  > sys.stderr.write(usage_message)
>


More information about the Piglit mailing list