diff options
author | Nicolai Haehnle <nhaehnle@gmail.com> | 2008-06-29 11:28:52 +0200 |
---|---|---|
committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2008-06-29 11:28:52 +0200 |
commit | c5cf79d6e81202cdecc73156adece18d948e35fb (patch) | |
tree | db609428d7958ce56e815d3e57c84d49bdfe6de0 | |
parent | ad03bd4dfe2030fc0b0fbfaad240e7d60b0d9b9f (diff) |
Add piglit-create-summary.py to create summary files after the fact.
-rw-r--r-- | framework/core.py | 43 | ||||
-rwxr-xr-x | piglit-create-summary.py | 79 |
2 files changed, 94 insertions, 28 deletions
diff --git a/framework/core.py b/framework/core.py index 760ec1a40..e0f91dc97 100644 --- a/framework/core.py +++ b/framework/core.py @@ -175,7 +175,7 @@ class TestrunResult: self.results.write(file,'') - def parse(self, path, PreferSummary): + def parseFile(self, file): def arrayparser(a): def cb(line): if line == '!': @@ -230,6 +230,14 @@ class TestrunResult: else: raise Exception("Line %d: Unknown key %s" % (linenr, key)) + stack = [toplevel] + linenr = 1 + for line in file: + if line[-1] == '\n': + stack[-1](line[0:-1]) + linenr = linenr + 1 + + def parseDir(self,path,PreferSummary): main = None filelist = [path + '/main', path + '/summary'] if PreferSummary: @@ -242,16 +250,10 @@ class TestrunResult: pass if not main: raise Exception("Failed to open %(path)s" % locals()) - stack = [toplevel] - linenr = 1 - for line in main: - if line[-1] == '\n': - stack[-1](line[0:-1]) - linenr = linenr + 1 + self.parseFile(main) main.close() - ############################################################################# ##### Generic Test classes ############################################################################# @@ -372,28 +374,13 @@ def loadTestProfile(filename): def loadTestResults(path,PreferSummary=False): try: mode = os.stat(path)[stat.ST_MODE] + testrun = TestrunResult() if stat.S_ISDIR(mode): - testrun = TestrunResult() - testrun.parse(path,PreferSummary) + testrun.parseDir(path,PreferSummary) else: - # BACKWARDS COMPATIBILITY - ns = { - '__file__': path, - 'GroupResult': GroupResult, - 'TestResult': TestResult, - 'TestrunResult': TestrunResult - } - execfile(path, ns) - - if 'testrun' not in ns: - testrun = TestrunResult() - testrun.results.update(ns['results']) - if 'name' in ns: - testrun.name = ns['name'] - ns['testrun'] = testrun - - testrun = ns['testrun'] - # END BACKWARDS COMPATIBILITY + file = open(path, 'r') + testrun.parseFile(file) + file.close() if len(testrun.name) == 0: if path[-1] == '/': diff --git a/piglit-create-summary.py b/piglit-create-summary.py new file mode 100755 index 000000000..f709f8119 --- /dev/null +++ b/piglit-create-summary.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# +# 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: +# +# 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 AUTHOR(S) 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. + + +from getopt import getopt, GetoptError +import os +import os.path +import re +import sys + +import framework.core as core + + + +############################################################################# +##### Main program +############################################################################# +def usage(): + USAGE = """\ +Usage: %(progName)s [options] [main results file] + +Options: + -h, --help Show this message + +Example: + %(progName)s results/main > results/summary +""" + print USAGE % {'progName': sys.argv[0]} + sys.exit(1) + +def main(): + env = core.Environment() + + try: + options, args = getopt(sys.argv[1:], "h", [ "help" ]) + except GetoptError: + usage() + + OptionName = '' + + for name,value in options: + if name in ('-h', '--help'): + usage() + + if len(args) != 1: + usage() + + resultsFilename = args[0] + + results = core.loadTestResults(resultsFilename) + for testname,result in results.allTestResults().items(): + if 'info' in result: + if len(result['info']) > 4096: + result['info'] = result['info'][0:4096] + results.write(sys.stdout) + + +if __name__ == "__main__": + main() |