D-Bus testing: more fixes for parsing of Python 2.7 output + HTML output

Some tests were incorrectly marked as "okay" because the there was
a line in the error message matching the "okay" regex. Now the pattern
also expects "okay" or "ok" at the end of the line.

The logic for detecting the start and end of an error report did not handle
multiple errors for a test. Now it does not overwrite an already opened
.log file anymore and keeps writing into it until some line really
indicates the beginning of another error.

As a new feature, the .html version of the .log file is written at the
same time as the .log file. It contains minor color coding. Its main
advantage is separation of D-Bus and stdout output and anchors with quick
links at the top of the page (can be used for skipping the D-Bus output).
This commit is contained in:
Patrick Ohly 2011-12-05 17:20:00 +00:00
parent bb710674da
commit c4beafccd5
1 changed files with 66 additions and 21 deletions

View File

@ -21,6 +21,7 @@
import sys,os,glob,datetime,popen2
import re
import fnmatch
import cgi
"""
resultcheck.py: tranverse the test result directory, generate an XML
@ -318,13 +319,15 @@ def step2(resultdir, result, servers, indents, srcdir, shellprefix, backenddir):
# first build list of all tests, assuming that they pass
dbustests = {}
test_start = re.compile(r'''^Test(?P<cl>.*)\.test(?P<func>[^ ]*)''')
test_start = re.compile(r'''^Test(?P<cl>.*)\.test(?P<func>[^ ]*).*ok(?:ay)?$''')
# FAIL/ERROR + description of test (old Python)
test_fail = re.compile(r'''(?P<type>FAIL|ERROR): Test(?P<cl>.*)\.test(?P<func>[^ ]*)''')
# FAIL/ERROR + function name of test (Python 2.7)
test_fail_27 = re.compile(r'''(?P<type>FAIL|ERROR): test(?P<func>[^ ]*) \(.*\.(?:Test(?P<cl>.*))\)''')
name = None
logfile = None
sepcount = 0
htmlfile = None
linetype = None
for line in open(rserver + "/output.txt"):
m = test_start.search(line)
if m:
@ -333,29 +336,67 @@ def step2(resultdir, result, servers, indents, srcdir, shellprefix, backenddir):
m = test_fail.search(line) or test_fail_27.search(line)
is_okay = False
if m:
# create log file
# create new (?!) log file
cl = m.group("cl")
func = m.group("func")
name = rserver + "/" + cl + "_" + func + ".log"
logfile = open(name, "w")
if not dbustests.get(cl):
dbustests[cl] = {}
if is_okay:
# okay: write a single line with the full test description
dbustests[cl][func] = "okay"
logfile.write(line)
logfile = None
else:
# failed: start writing lines into separate log file
dbustests[cl][func] = m.group("type")
sepcount = 0
newname = rserver + "/" + cl + "_" + func + ".log"
if newname != name:
name = newname
logfile = open(name, "w")
if htmlfile:
htmlfile.write('</pre></body')
htmlfile.close()
htmlfile = None
htmlfile = open(name + ".html", "w")
htmlfile.write('''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=None">
<style type="text/css">
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
body .hll { background-color: #ffffcc }
body { background: #f8f8f8; }
span.INFO { background: #c0c0c0 }
span.ERROR { background: #e0c0c0 }
span.hl { color: #c02020 }
</style>
</head>
<body>
<pre>''')
if not dbustests.get(cl):
dbustests[cl] = {}
if is_okay:
# okay: write a single line with the full test description
dbustests[cl][func] = "okay"
logfile.write(line)
logfile = None
htmlfile.write('<span class="OKAY">%s</span></pre></body>' % cgi.escape(line))
htmlfile.close()
htmlfile = None
else:
# failed: start writing lines into separate log file
dbustests[cl][func] = m.group("type")
linetype = "ERROR"
htmlfile.write('<a href="#dbus-traffic">D-Bus traffic</a> <a href="#stdout">output</a>\n\n')
if logfile:
logfile.write(line)
if line.startswith("-----------------------------------"):
sepcount = sepcount + 1
if sepcount >= 2:
# end of failure output for this test
logfile = None
if line == 'D-Bus traffic:\n':
linetype = "DBUS"
htmlfile.write('<h3 id="dbus-traffic">D-Bus traffic:</h3>')
elif line == 'server output:\n':
linetype = "OUT"
htmlfile.write('<h3 id="stdout">server output:</h3>')
else:
htmlfile.write('<span class="%s">%s</span>' % (linetype, cgi.escape(line)))
if htmlfile:
htmlfile.write('</pre></body')
htmlfile.close()
htmlfile = None
# now write XML
indent +=space
indents.append(indent)
@ -386,6 +427,9 @@ def step2(resultdir, result, servers, indents, srcdir, shellprefix, backenddir):
# <path>/SyncEvo_CmdlineTest_testConfigure.log
# <path>/N7SyncEvo11CmdlineTestE_testConfigure.log - C++ name mangling?
m = re.match(r'.*/(Client_Source_|Client_Sync_|N7SyncEvo\d+|[^_]*_)(.*)_([^_]*)\.log', log)
if not m:
print "skipping", log
continue
# Client_Sync_, Client_Source_, SyncEvo_, ...
prefix = m.group(1)
# eds_contact, CmdlineTest, ...
@ -399,6 +443,7 @@ def step2(resultdir, result, servers, indents, srcdir, shellprefix, backenddir):
if m:
format = m.group(1)
casename = m.group(2) + '::' + casename
print "analyzing log %s: prefix %s, subset %s, testcase %s" % (log, prefix, format, casename)
if(format not in logdic):
logdic[format]=[]
logdic[format].append((casename, log))