Commit 72f92968 authored by Rich Prohaska's avatar Rich Prohaska

#211 simplify sql bench test runner

parent da5e2a19
......@@ -108,7 +108,24 @@ runtests --create-options=engine=$engine --socket=$socket --verbose
popd
# summarize the results
python ~/bin/sql.bench.summary.py <$testresultsdir/$tracefile >$testresultsdir/$summaryfile
while read l ; do
if [[ $l =~ ^([0-9]{8}\ [0-9]{2}:[0-9]{2}:[0-9]{2})(.*)$ ]] ; then
t=${BASH_REMATCH[1]}
cmd=${BASH_REMATCH[2]}
if [ -z "$cmd" ] ; then
let duration=$(date -d "$t" +%s)-$(date -d "$tlast" +%s)
printf "%4s %s %8d %s\n" "$status" "$tlast" "$duration" "$cmdlast"
else
cmdlast=$cmd
tlast=$t
status=PASS
fi
else
if [[ $l =~ "Got error|Died" ]] ; then
status=FAIL
fi
fi
done <$testresultsdir/$tracefile >$testresultsdir/$summaryfile
testresult=""
pf=`mktemp`
......
#!/usr/bin/env python
# summarize the sql-bench trace file
import sys
import re
import os.path
class testreports:
def __init__(self):
self.reports = []
def append(self, report):
self.reports.append(report)
def duration(self, start, stop):
t0 = os.popen('date -d"' + start + '" +%s').readline()
t1 = os.popen('date -d"' + stop + '" +%s').readline()
return int(t1) - int(t0)
def printit(self, i):
report = self.reports[i]
d = self.duration(report["start"], report["stop"])
print "%s %s %6u %s" % (report["result"].upper(), report["start"], d, report["name"])
# print self.reports[i]
def printall(self):
for i in range(len(self.reports)):
self.printit(i)
def stoptime(self, stoptime):
if len(self.reports) > 0:
lastreport = self.reports[-1]
lastreport["stop"] = stoptime
def main():
reports = testreports()
testreport = {}
while 1:
b = sys.stdin.readline()
if b == "": break
b = b.rstrip('\n')
match = re.match("^(\d{8} \d{2}:\d{2}:\d{2})$", b)
if match:
if totaltime == "" and testreport["result"] == "pass":
testreport["result"] = "fail"
testreport["stop"] = match.group(1)
reports.append(testreport)
testreport = {}
continue
match = re.match("^(\d{8} \d{2}:\d{2}:\d{2}) (test-.*)$", b)
if match:
testreport["start"] = match.group(1)
testreport["name"] = match.group(2)
testreport["result"] = "pass"
totaltime = ""
continue
match = re.match(".*Got error|.*Died at", b)
if match: testreport["result"] = "fail"
match = re.match("^Total time|^Estimated total time", b)
if match: totaltime = b
match = re.match("skip", b)
if match: testreport["result"] = "skip"
reports.printall()
return 0
sys.exit(main())
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