[Piglit] [PATCH 4/4] piglit: Add a toplevel piglit command

Dylan Baker baker.dylan.c at gmail.com
Mon May 5 01:35:57 PDT 2014


On Saturday, May 03, 2014 05:47:26 PM Jordan Justen wrote:
> On Fri, May 2, 2014 at 6:31 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> > This uses the functions created by the last commit to create a
> > all-in-one piglit command. It uses argparse to parse partial commands
> > and provide help for those functions.
> > 
> > It is also capable of handling all of the black magic for setting the
> > python sys.path and setting the PIGLIT_SOURCE_DIR environment variable.
> > 
> > v2: - Allow the name of the program to not be piglit (example:
> >       piglit-20140101)
> >     
> >     - Remove unused check from cmake
> >     - Install piglit as piglit${PIGLIT_INSTALL_VERSION}; when this
> >     
> >       variable is unset piglit will be installed simply as 'piglit'
> > 
> > Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
> > ---
> > 
> >  CMakeLists.txt | 17 ++++--------
> >  piglit         | 88
> >  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files
> >  changed, 93 insertions(+), 12 deletions(-)
> >  create mode 100755 piglit
> > 
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index e3eddba..ff2038f 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -426,18 +426,6 @@ install (
> > 
> >  )
> >  
> >  install (
> > 
> > -       PROGRAMS
> > -               piglit-merge-results.py
> > -               piglit-print-commands.py
> > -               piglit-run.py
> > -               piglit-resume.py
> > -               piglit-summary.py
> > -               piglit-summary-html.py
> > -               piglit-summary-junit.py
> > -       DESTINATION ${PIGLIT_INSTALL_LIBDIR}
> > -)
> > -
> > -install (
> > 
> >         DIRECTORY framework
> >         DESTINATION ${PIGLIT_INSTALL_LIBDIR}
> >         FILES_MATCHING PATTERN "*.py"
> > 
> > @@ -462,6 +450,11 @@ install (
> > 
> >         REGEX "CMakeFiles|CMakeLists" EXCLUDE
> >  
> >  )
> > 
> > +install (
> > +       PROGRAMS piglit RENAME piglit${PIGLIT_INSTALL_VERSION_SUFFIX}
> > +       DESTINATION ${CMAKE_INSTALL_BINDIR}
> > +)
> > +
> > 
> >  set (CPACK_PACKAGE_VERSION_MAJOR "1")
> >  set (CPACK_PACKAGE_VERSION_MINOR "0")
> > 
> > diff --git a/piglit b/piglit
> > new file mode 100755
> > index 0000000..9f3d349
> > --- /dev/null
> > +++ b/piglit
> > @@ -0,0 +1,88 @@
> > +#!/usr/bin/env python
> > +
> > +# Copyright (c) 2014 Intel Corporation
> > +
> > +# Permission is hereby granted, free of charge, to any person obtaining a
> > copy +# of this software and associated documentation files (the
> > "Software"), to deal +# in the Software without restriction, including
> > without limitation the rights +# to use, copy, modify, merge, publish,
> > distribute, sublicense, and/or sell +# copies of the Software, and to
> > permit persons to whom the Software is +# furnished to do so, subject to
> > the following conditions:
> > +
> > +# The above copyright notice and this permission notice shall be included
> > in +# all copies or substantial portions of the Software.
> > +
> > +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> > OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> > IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> > CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> > TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE
> > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE.
> > +
> > +""" Wrapper for piglit executables
> > +
> > +This imports functions from the framework and calls them with the
> > argument
> > +parts that the parser defined here doesn't konw how to parse.
> > +
> > +It is very important that the final parser not generate a help message
> > +(add_help=False in the constructor arguments), otherwise this parser will
> > +capture -h/--help and the results will not be useful.
> > +
> > +"""
> > +
> > +import os
> > +import os.path as path
> > +import sys
> > +import argparse
> > +
> > +# If running in the source directory there will be a HACKING file, don't
> > +# muck with things, if not we need to screw with the python path
> > +if not path.exists('HACKING'):
> > +    _binpath, _bin = path.split(__file__)
> > +    _libdir = path.abspath(path.join(_binpath, '../lib/', _bin))
> 
> '../lib/' => '..', 'lib'

Doing that just produces unnecessary overhead and produces the same result, on 
the three platforms we care about (windows, *nix, osx), the only platform 
python supports that this wouldn't work on is classic macos (pre OSX macos). I 
can make the change, but what does it buy us?

> 
> For patches 3 & 4:
> Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
> 
> I still would prefer that piglit run without any parameters (or just
> -h) would print the commands, one per line, with a brief summary of
> their purpose. That, and that piglit help command would be equivalent
> to piglit command -h. But, neither of these are that big of a deal.
> 
> Thanks for your time on this,
> 
> -Jordan
> 
> > +    sys.path.append(_libdir)
> > +    os.environ['PIGLIT_SOURCE_DIR'] = _libdir
> > +
> > +import framework.programs.run as run
> > +import framework.programs.summary as summary
> > +
> > +
> > +def main():
> > +    """ Parse argument and call other executables """
> > +    parser = argparse.ArgumentParser()
> > +    subparsers = parser.add_subparsers()
> > +
> > +    parse_run = subparsers.add_parser('run',
> > +                                      add_help=False,
> > +                                      help="Run a piglit test")
> > +    parse_run.set_defaults(func=run.run)
> > +    resume = subparsers.add_parser('resume',
> > +                                   add_help=False,
> > +                                   help="resume an interrupted piglit
> > run") +    resume.set_defaults(func=run.resume)
> > +    parse_summary = subparsers.add_parser('summary', help='summary
> > generators') +    summary_parser = parse_summary.add_subparsers()
> > +    html = summary_parser.add_parser('html',
> > +                                     add_help=False,
> > +                                     help='generate html reports from
> > results') +    html.set_defaults(func=summary.html)
> > +    console = summary_parser.add_parser('console',
> > +                                        add_help=False,
> > +                                        help='print results to terminal')
> > +    console.set_defaults(func=summary.console)
> > +    junit = summary_parser.add_parser('junit',
> > +                                      add_help=False,
> > +                                      help='generate junit xml from
> > results') +    junit.set_defaults(func=summary.junit)
> > +
> > +    # Parse the known arguments (piglit run or piglit summary html for
> > +    # example), and then pass the arguments that this parser doesn't know
> > about +    # to that executable
> > +    parsed, args = parser.parse_known_args()
> > +    returncode = parsed.func(args)
> > +    sys.exit(returncode)
> > +
> > +
> > +if __name__ == '__main__':
> > +    main()
> > --
> > 2.0.0.rc0
> > 
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140505/37980526/attachment.sig>


More information about the Piglit mailing list