[Piglit] [PATCH] summary: Add an aggregate function

Brian Paul brianp at vmware.com
Mon Mar 23 15:23:28 PDT 2015


LGTM.  Thanks.

Reviewed-by: Brian Paul <brianp at vmware.com>


On 03/23/2015 04:14 PM, Dylan Baker wrote:
> This summarizer can be used to aggregate a set of individual tests
> together into a single results file.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>   framework/programs/summary.py | 41 ++++++++++++++++++++++++++++++++++++++---
>   piglit                        |  4 ++++
>   2 files changed, 42 insertions(+), 3 deletions(-)
>
> diff --git a/framework/programs/summary.py b/framework/programs/summary.py
> index a273918..8aaf709 100644
> --- a/framework/programs/summary.py
> +++ b/framework/programs/summary.py
> @@ -19,19 +19,25 @@
>   # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
>   # DEALINGS IN THE SOFTWARE.
>
> +from __future__ import print_function, absolute_import
>   import argparse
>   import shutil
> +import os
>   import os.path as path
>   import sys
> +import errno
>
>   import framework.summary as summary
>   import framework.status as status
>   import framework.core as core
>   import framework.results
>
> -__all__ = ['html',
> -           'console',
> -           'csv']
> +__all__ = [
> +    'aggregate',
> +    'console',
> +    'csv',
> +    'html',
> +]
>
>
>   def html(input_):
> @@ -163,3 +169,32 @@ def csv(input_):
>               write_results(output)
>       else:
>           write_results(sys.stdout)
> +
> +
> +def aggregate(input_):
> +    """Combine files in a tests/ directory into a single results file."""
> +    parser = argparse.ArgumentParser()
> +    parser.add_argument('results_folder',
> +                        type=path.realpath,
> +                        metavar="<results path>",
> +                        help="Path to a results folder")
> +    parser.add_argument('-o', '--output',
> +                        default="results.json",
> +                        help="name of output file. Default: results.json")
> +    args = parser.parse_args(input_)
> +
> +    assert os.path.isdir(args.results_folder)
> +
> +    outfile = os.path.join(args.results_folder, args.output)
> +    results = framework.results.load_results(args.results_folder)
> +
> +    try:
> +        results.write(outfile)
> +    except IOError as e:
> +        if e.errno == errno.EPERM:
> +            print("Error: Unable to write aggregated file, permission denied.",
> +                  file=sys.stderr)
> +            sys.exit(1)
> +        raise
> +
> +    print("Aggregated file written to: {}".format(outfile))
> diff --git a/piglit b/piglit
> index 53a4bb4..5ae43e9 100755
> --- a/piglit
> +++ b/piglit
> @@ -135,6 +135,10 @@ def main():
>                                       add_help=False,
>                                       help='generate csv from results')
>       csv.set_defaults(func=summary.csv)
> +    aggregate = summary_parser.add_parser('aggregate',
> +                                          add_help=False,
> +                                          help="Aggregate incomplete piglit run.")
> +    aggregate.set_defaults(func=summary.aggregate)
>
>       # Parse the known arguments (piglit run or piglit summary html for
>       # example), and then pass the arguments that this parser doesn't know about
>



More information about the Piglit mailing list