Commit eb6359d4 authored by Nicolai Hähnle's avatar Nicolai Hähnle

Generate abbreviated results

The results files can get rather huge when tests fail, because tests like
glean/blendFunc output a lot of debugging data, which we all record.

Now, we generate an additional .../summary file, in which the info string
is simply truncated. Pretty stupid, but it should give enough info to get
an idea of the rough kind of failure.

Add a new option for piglit-summary-html.py, to choose between full or
abbreviated info when both are present.
parent aa22711b
......@@ -102,6 +102,9 @@ class TestResult(dict):
'dict': dict.__repr__(self)
}
def allTestResults(self,name):
return {name: self}
def write(self,file,path):
print >>file, "@test: " + encode(path)
for k in self:
......@@ -136,12 +139,42 @@ class GroupResult(dict):
'dict': dict.__repr__(self)
}
def allTestResults(self, groupName):
collection = {}
for name,sub in self.items():
subfullname = name
if len(groupName) > 0:
subfullname = groupName + '/' + subfullname
collection.update(sub.allTestResults(subfullname))
return collection
def write(self, file, groupName):
for name,sub in self.items():
subfullname = name
if len(groupName) > 0:
subfullname = groupName + '/' + subfullname
sub.write(file, subfullname)
class TestrunResult:
def __init__(self, *args):
self.name = ''
self.globalkeys = ['name', 'glxinfo', 'lspci']
self.results = GroupResult()
def parse(self, path):
def allTestResults(self):
'''Return a dictionary containing (name: TestResult) mappings.
Note that writing to this dictionary has no effect.'''
return self.results.allTestResults('')
def write(self, file):
for key in self.globalkeys:
if key in self.__dict__:
print >>file, "%s: %s" % (key, encode(self.__dict__[key]))
self.results.write(file,'')
def parse(self, path, PreferSummary):
def arrayparser(a):
def cb(line):
if line == '!':
......@@ -179,7 +212,7 @@ class TestrunResult:
key = line[:colon]
value = decode(line[colon+2:])
if key in ['name', 'glxinfo', 'lspci']:
if key in self.globalkeys:
self.__dict__[key] = value
elif key == '@test':
comp = value.split('/')
......@@ -194,15 +227,27 @@ class TestrunResult:
stack.append(dictparser(result))
else:
raise Exception("Line %(linenr)d: Unknown key" % locals())
raise Exception("Line %d: Unknown key %s" % (linenr, key))
main = open(path + '/main', 'r')
main = None
filelist = [path + '/main', path + '/summary']
if PreferSummary:
filelist[:0] = [path + '/summary']
for filename in filelist:
try:
main = open(filename, 'r')
break
except:
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
main.close()
......@@ -319,12 +364,12 @@ def loadTestProfile(filename):
traceback.print_exc()
raise Exception('Could not read tests profile')
def loadTestResults(path):
def loadTestResults(path,PreferSummary=False):
try:
mode = os.stat(path)[stat.ST_MODE]
if stat.S_ISDIR(mode):
testrun = TestrunResult()
testrun.parse(path)
testrun.parse(path,PreferSummary)
else:
# BACKWARDS COMPATIBILITY
ns = {
......
......@@ -95,5 +95,20 @@ def main():
profile.run(env)
env.file.close()
print "Writing summary file..."
results = core.loadTestResults(resultsDir)
for testname,result in results.allTestResults().items():
if 'info' in result:
if len(result['info']) > 4096:
result['info'] = result['info'][0:4096]
file = open(resultsDir + '/summary', "w")
results.write(file)
file.close()
print
print 'Thank you for running Piglit!'
print 'Summary for submission has been written to ' + resultsDir + '/summary'
if __name__ == "__main__":
main()
......@@ -226,6 +226,7 @@ def usage():
Usage: %(progName)s [options] [summary-dir] [test.results]...
Options:
-f, --full Prefer the full results over the
-h, --help Show this message
-o, --overwrite Overwrite existing directories
......@@ -238,16 +239,19 @@ Example:
def main():
try:
options, args = getopt(sys.argv[1:], "ho", [ "help", "overwrite" ])
options, args = getopt(sys.argv[1:], "hof", [ "help", "overwrite", "full" ])
except GetoptError:
usage()
OptionOverwrite = False
OptionPreferSummary = True
for name,value in options:
if name == "-h" or name == "--help":
usage()
elif name == "-o" or name == "--overwrite":
OptionOverwrite = True
elif name == "-f" or name == "--full":
OptionPreferSummary = False
if len(args) < 2:
usage()
......@@ -257,7 +261,7 @@ def main():
core.checkDir(summaryDir, not OptionOverwrite)
results = [core.loadTestResults(name) for name in resultFilenames]
results = [core.loadTestResults(name, OptionPreferSummary) for name in resultFilenames]
summary = framework.summary.Summary(results)
for j in range(len(summary.testruns)):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment