<div dir="ltr">I have some concerns with this patch:<div style>1) It has two imports that are not being used: cgi, os (not os.path)</div><div style>2) getopt: I've been trying to get rid of getopt and replace it with argparse (I have a patch set ready to go to replace the rest of optparse and getopt with argparse)</div>
<div style>3) using the name piglit-summary.py: If the project ever wanted to have a unified summary program that could output different summary formats (which seems like a good idea as the project gets more and more summary output types) the logical name would be piglit-summary.py. This creates friction since that kind of feature would be changing the functionality of an existing tool in the project.</div>
<div style><br></div><div style>-Dylan</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 6:21 PM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If only one result file is specified, just print all the tests<br>
followed by the outcome.  For example:<br>
<br>
fbo/FBO blit from missing attachment: pass<br>
fbo/FBO blit to missing attachment: fail<br>
fbo/fbo-1d: pass<br>
fbo/fbo-3d: crash<br>
[...]<br>
<br>
If multiple result files are specified, we'll print pass/fail/etc<br>
for each file.  Example:<br>
<br>
fbo/FBO blit from missing attachment: pass pass<br>
fbo/FBO blit to missing attachment: fail pass<br>
[...]<br>
<br>
If -s (--summary) is specified, only print a summary of the number of<br>
passes, fails, crashes, etc.<br>
<br>
if -d (-diff) is specified with multipe result files, only print the<br>
tests which had different outcomes.  Good for spotting regressions.<br>
---<br>
 piglit-summary.py |  158 +++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
 1 files changed, 158 insertions(+), 0 deletions(-)<br>
 create mode 100755 piglit-summary.py<br>
<br>
diff --git a/piglit-summary.py b/piglit-summary.py<br>
new file mode 100755<br>
index 0000000..ae1e5ca<br>
--- /dev/null<br>
+++ b/piglit-summary.py<br>
@@ -0,0 +1,158 @@<br>
+#!/usr/bin/env python<br>
+#<br>
+# Permission is hereby granted, free of charge, to any person<br>
+# obtaining a copy of this software and associated documentation<br>
+# files (the "Software"), to deal in the Software without<br>
+# restriction, including without limitation the rights to use,<br>
+# copy, modify, merge, publish, distribute, sublicense, and/or<br>
+# sell copies of the Software, and to permit persons to whom the<br>
+# Software is furnished to do so, subject to the following<br>
+# conditions:<br>
+#<br>
+# This permission notice shall be included in all copies or<br>
+# substantial portions of the Software.<br>
+#<br>
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY<br>
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE<br>
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR<br>
+# PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHOR(S) BE<br>
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN<br>
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF<br>
+# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
+# DEALINGS IN THE SOFTWARE.<br>
+<br>
+# Print a very simple summary of piglit results file(s).<br>
+# When multiple result files are specified, compare the results<br>
+# of each test run to look for differences/regressions.<br>
+#<br>
+# Brian Paul<br>
+# April 2013<br>
+<br>
+<br>
+from getopt import getopt, GetoptError<br>
+import cgi<br>
+import os, os.path<br>
+import sys<br>
+import string<br>
+<br>
+sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))<br>
+import framework.core as core<br>
+import framework.summary<br>
+<br>
+<br>
+#############################################################################<br>
+##### Main program<br>
+#############################################################################<br>
+def usage():<br>
+       USAGE = """\<br>
+Usage: %(progName)s [options] resultsfile [...]<br>
+<br>
+Print path/name of each test and the result.<br>
+When multiple files are specified, count the number of differences in results.<br>
+Tests are sorted by name.<br>
+<br>
+Options:<br>
+  -h, --help            Show this message<br>
+  -s, --summary         Only display pass/fail summary<br>
+  -d, --diff            Only display the differences between multiple result files<br>
+  -l, --list=listfile   Use test results from a list file<br>
+"""<br>
+       print USAGE % {'progName': sys.argv[0]}<br>
+       sys.exit(1)<br>
+<br>
+<br>
+def parse_listfile(filename):<br>
+       file = open(filename, "r")<br>
+       code = "".join([s for s in file])<br>
+       file.close()<br>
+       return eval(code)<br>
+<br>
+def loadresult(descr):<br>
+       result = core.loadTestResults(descr[0])<br>
+       if len(descr) > 1:<br>
+               result.__dict__.update(descr[1])<br>
+       return result<br>
+<br>
+def main():<br>
+       try:<br>
+               options, args = getopt(sys.argv[1:], "hsdl:", [ "help", "summary", "diff", "list" ])<br>
+       except GetoptError:<br>
+               usage()<br>
+<br>
+       OptionList = []<br>
+       CountsOnly = False<br>
+       DiffOnly = False<br>
+       for name, value in options:<br>
+               if name == "-h" or name == "--help":<br>
+                       usage()<br>
+               elif name == "-s" or name == "--summary":<br>
+                       CountsOnly = True<br>
+               elif name == "-d" or name == "--diff":<br>
+                       DiffOnly = True<br>
+               elif name == "-l" or name == "--list":<br>
+                       OptionList += parse_listfile(value)<br>
+<br>
+       OptionList += [[name] for name in args[0:]]<br>
+<br>
+       if len(args) < 1 or len(OptionList) == 0:<br>
+               usage()<br>
+<br>
+       # make list of results<br>
+       results = []<br>
+       for result_dir in OptionList:<br>
+               results.append(loadresult(result_dir))<br>
+<br>
+       summary = framework.summary.Summary(results)<br>
+<br>
+       # possible test outcomes<br>
+       possible_results = [ "pass", "fail", "crash", "skip", "warn" ]<br>
+       if len(OptionList) > 1:<br>
+                       possible_results.append("changes")<br>
+<br>
+       # init the summary counters<br>
+       counts = {}<br>
+       for result in possible_results:<br>
+                       counts[result] = 0<br>
+<br>
+       # get all results<br>
+       all = summary.allTests()<br>
+<br>
+       # sort the results list by path<br>
+       all = sorted(all, key=lambda test: test.path)<br>
+<br>
+       # loop over the tests<br>
+       for test in all:<br>
+               results = []<br>
+               anyChange = False<br>
+               # loop over the results for multiple runs<br>
+               for j in range(len(summary.testruns)):<br>
+                       outcome = test.results[j]['result'] # 'pass', 'fail', etc.<br>
+                       # check for different results between multiple runs<br>
+                       if len(results) >= 1 and not outcome in results:<br>
+                               # something changed<br>
+                               counts["changes"] += 1<br>
+                               anyChange = True<br>
+                       results.append(outcome)<br>
+<br>
+               # if all test runs had the same outcome:<br>
+               if not anyChange:<br>
+                       counts[outcome] += 1<br>
+<br>
+               # print the individual test result line<br>
+               if DiffOnly:<br>
+                       if anyChange:<br>
+                               print "%s: %s" % (test.path, string.join(results," "))<br>
+               elif not CountsOnly:<br>
+                       print "%s: %s" % (test.path, string.join(results," "))<br>
+<br>
+       # print the summary info<br>
+       print "summary:"<br>
+       total = 0<br>
+       for result in possible_results:<br>
+               print " %7s: %5d" % (result, counts[result])<br>
+               total += counts[result]<br>
+       print "   total: %5d" % total<br>
+<br>
+<br>
+if __name__ == "__main__":<br>
+       main()<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.3.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>