diff options
author | Andrew McDermott <andrew.mcdermott@linaro.org> | 2014-07-01 14:23:43 +0100 |
---|---|---|
committer | Andrew McDermott <andrew.mcdermott@linaro.org> | 2014-07-01 14:24:30 +0100 |
commit | bc6b07e39a47db21bdc260adcc20baebfe1cc13e (patch) | |
tree | 4f4f8e2272fe103ba17e4261e9e552c50f8d2fcd | |
parent | dd6e012ba447bebb174b8178992713857e79f828 (diff) |
jcstress-generate-html-report: print pass/fail rate
Signed-off-by: Andrew McDermott <andrew.mcdermott@linaro.org>
-rw-r--r-- | common.py | 33 | ||||
-rwxr-xr-x | jcstress-generate-html-report.py | 27 | ||||
-rwxr-xr-x | jcstress-print-results.py | 17 |
3 files changed, 47 insertions, 30 deletions
diff --git a/common.py b/common.py new file mode 100644 index 0000000..804a3a0 --- /dev/null +++ b/common.py @@ -0,0 +1,33 @@ +# Copyright (C) 2014, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Author: Andrew McDermott <andrew.mcdermott@linaro.org> + +import re + +def pass_fail_rate(filename): + with open(filename, 'rb') as fp: + for line in fp: + if 'Overall pass rate:' not in line: + continue + pass_rate_re = re.compile(".*Overall pass rate:....\s(?P<x>\d+)/(?P<y>\d+)") + if not pass_rate_re: + raise + match = pass_rate_re.match(line) + if match: + return [ int(match.group('x')), int(match.group('y')) ] + return [ -1, -1 ] + diff --git a/jcstress-generate-html-report.py b/jcstress-generate-html-report.py index 73c59ec..9a6ab16 100755 --- a/jcstress-generate-html-report.py +++ b/jcstress-generate-html-report.py @@ -20,24 +20,16 @@ from htmltags import * import argparse +import csv import os import platform -import csv -import sys import time from datetime import datetime +from common import * def remove_starting_path(full_path, start): return os.path.relpath(full_path, start) -def cell_style(status): - if 'success' in status: - return status.upper() - elif 'failed' in status: - return status.upper() - else: - return None - parser = argparse.ArgumentParser() parser.add_argument('--results', help='results filename', type=str, required=True) parser.add_argument('--top-dir', help="top directory", type=str, required=True) @@ -46,25 +38,30 @@ args = parser.parse_args() head = HEAD(TITLE("jcstress Result Archive ({})".format(platform.machine()))) head <= LINK(rel="stylesheet", href="style.css") body = BODY() + +body <= P("""This page captures the historic results of +running the {} tests on {}.""".format(A("jcstress", href="http://openjdk.java.net/projects/code-tools/jcstress/"), platform.machine())) + table = TABLE(border=1) -table <= TR(TH('Date') + TH('Results') + TH('Status')) +table <= TR(TH('Date') + TH('JVM') + TH('Run Mode') + TH('Pass Rate')) with open(args.results, 'rb') as csvfile: rdr = csv.reader(csvfile, delimiter=',', quotechar='|') for row in rdr: human_readable_date = time.strftime("%Y-%m-%d", time.localtime(int(row[0]))).lower() - human_readable_index = os.path.join(remove_starting_path(row[1], args.top_dir), 'results') index_html = os.path.join(os.path.sep, remove_starting_path(row[1], args.top_dir), 'results', 'index.html') html_row = TR() + pass_fail = pass_fail_rate("{}/results/index.html".format(row[1])) html_row <= TD(human_readable_date) - html_row <= TD(A(human_readable_index, href=index_html)) - html_row <= TD(row[2], Class=cell_style(row[2])) + html_row <= TD('server-release') # XXX remove hard-coded nature + html_row <= TD('sanity') # XXX remove hard-coded nature + html_row <= TD(A("{}/{}".format(pass_fail[0], pass_fail[1]), href=index_html), align='right') table <= html_row body <= H2("Historic Results") body <= table body <= HR() -body <= P("Page generated on: {}".format(time.strftime("%Y-%m-%d %H:%M:%S %Z"))) +body <= P("Page generated on: {}".format(time.strftime("%a, %d %b %Y %T %z"))) head <= body print HTML(head) diff --git a/jcstress-print-results.py b/jcstress-print-results.py index c3a30f0..c4fcbad 100755 --- a/jcstress-print-results.py +++ b/jcstress-print-results.py @@ -22,7 +22,7 @@ import argparse import os import csv import time -import re +from common import * parser = argparse.ArgumentParser() parser.add_argument('--results', help='results filename', type=str, required=True) @@ -31,23 +31,10 @@ parser.add_argument('--url', help="URL", type=str, required=True) parser.add_argument('rest', nargs=argparse.REMAINDER) args = parser.parse_args() -def pass_fail_rate(filename): - with open(filename, 'rb') as fp: - for line in fp: - if 'Overall pass rate:' not in line: - continue - pass_rate_re = re.compile(".*Overall pass rate:....\s(?P<x>\d+)/(?P<y>\d+)") - if not pass_rate_re: - raise - match = pass_rate_re.match(line) - if match: - return [ int(match.group('x')), int(match.group('y')) ] - return [ -1, -1 ] - with open(args.results, 'rb') as csvfile: rdr = csv.reader(csvfile, delimiter=',', quotechar='|') for row in rdr: human_readable_date = time.strftime("%Y-%m-%d", time.localtime(int(row[0]))).lower() normalized_row = [ human_readable_date, os.path.relpath(row[1], args.top_dir), row[2] ] pass_rate = pass_fail_rate("{}/results/index.html".format(row[1])) - print "{} pass rate: {}/{}, results: {}/{}/results/".format(normalized_row[0], pass_rate[0], pass_rate[1], args.url, normalized_row[1]) + print "{} pass rate: {}/{}, results: {}{}/results/".format(normalized_row[0], pass_rate[0], pass_rate[1], args.url, normalized_row[1]) |