Similarly to print-cmd, this option allows one to specify a format string to output each test in the summary. It can be used to easily generate a list of only tests that failed, with something like:
./piglit summary formatted -e pass -e skip -e notrun --format {name} \ results.json.bz2 > ../piglit-summary.txt This file can then be used as input to piglit run --test-list. Signed-off-by: Rafael Antognolli <rafael.antogno...@intel.com> --- framework/programs/summary.py | 56 +++++++++++++++++++++++++++++++++++++++++++ piglit | 4 ++++ 2 files changed, 60 insertions(+) diff --git a/framework/programs/summary.py b/framework/programs/summary.py index e400d9a76..e21fa5fda 100644 --- a/framework/programs/summary.py +++ b/framework/programs/summary.py @@ -40,6 +40,7 @@ __all__ = [ 'csv', 'html', 'feature' + 'formatted' ] @@ -200,6 +201,61 @@ def csv(input_): else: write_results(sys.stdout) +@exceptions.handler +def formatted(input_): + # Make a copy of the status text list and add all. This is used as the + # argument list for -e/--exclude + statuses = set(str(s) for s in status.ALL) + + unparsed = parsers.parse_config(input_)[1] + + # Adding the parent is necissary to get the help options + parser = argparse.ArgumentParser(parents=[parsers.CONFIG]) + parser.add_argument("--format", + dest="format_string", + metavar="<format string>", + default="{name} ::: {time} ::: " + "{returncode} ::: {result}", + action="store", + help="A template string that defines the format. " + "Replacement tokens are {name}, {time}, " + "{returncode} and {result}") + parser.add_argument("-e", "--exclude-details", + default=[], + action="append", + choices=statuses, + help="Optionally exclude the listing of tests with " + "the status(es) given as arguments. " + "May be used multiple times") + parser.add_argument("-o", "--output", + metavar="<Output File>", + action="store", + dest="output", + default="stdout", + help="Output filename") + parser.add_argument("testResults", + metavar="<Input Files>", + help="JSON results file to be converted") + args = parser.parse_args(unparsed) + + testrun = backends.load(args.testResults) + + def write_results(output): + for name, result in six.iteritems(testrun.tests): + if result.result in args.exclude_details: + continue + output.write((args.format_string + "\n").format( + name=name, + time=result.time.total, + returncode=result.returncode, + result=result.result)) + + if args.output != "stdout": + with open(args.output, 'w') as output: + write_results(output) + else: + write_results(sys.stdout) + @exceptions.handler def aggregate(input_): diff --git a/piglit b/piglit index 6c1d30ae8..0bc753402 100755 --- a/piglit +++ b/piglit @@ -149,6 +149,10 @@ def main(): add_help=False, help='generate csv from results') csv.set_defaults(func=summary.csv) + formatted = summary_parser.add_parser('formatted', + add_help=False, + help='generate formatted output from results') + formatted.set_defaults(func=summary.formatted) aggregate = summary_parser.add_parser('aggregate', add_help=False, help="Aggregate incomplete piglit run.") -- 2.13.5 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit