From 3b57707e753087c0475396c3f7e483a324c83655 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sun, 25 Nov 2012 22:44:22 -0800 Subject: tiny shred of reporting :( --- framework/database.py | 28 ++++++++++++++++++++++ programs/report.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ robyn | 3 +++ 3 files changed, 96 insertions(+) create mode 100755 programs/report.py diff --git a/framework/database.py b/framework/database.py index b5cf4d0..f73a4a6 100644 --- a/framework/database.py +++ b/framework/database.py @@ -80,3 +80,31 @@ class ResultDatabase: def writeResult(self, run, name, command, result): c = self.connection.cursor() c.execute('UPDATE results SET command = ?, result = ?, return_code = ?, errors = ?, output = ? WHERE run_id = ? AND test_name = ? AND result IS NULL', (' '.join(command), result['status'], result['exitcode'], result['err'], result['out'], run, name)) + + def getResults(self, runs): + c = self.connection.cursor() + + # Build self-join query to get results. This awful code generates: + # + # SELECT R1.test_name, R1.result, R2.result, R3.result FROM + # (SELECT test_name, result FROM results WHERE run_id = 1) R1 + # INNER JOIN + # (SELECT test_name, result FROM results WHERE run_id = 2) R2 + # USING (test_name) + # INNER JOIN + # (SELECT test_name, result FROM results WHERE run_id = 3) R3 + # USING (test_name) + + subselects = ['(SELECT test_name, result FROM results WHERE run_id = %d) R%d' % (r, r) for r in runs] + query = ' '.join(['SELECT R%d.test_name,' % runs[0], + ', '.join('R%d.result' % r for r in runs), + 'FROM', subselects[0], + ' '.join([' INNER JOIN ' + s + ' USING (test_name) ' for s in subselects[1:]])]) + + # Convert (name, s1, s2, s3) to {name: (s1, s2, s3)} + results = {} + xs = c.execute(query) + for x in xs: + results[x[0]] = x[1:] + + return results diff --git a/programs/report.py b/programs/report.py new file mode 100755 index 0000000..a542a5c --- /dev/null +++ b/programs/report.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# +# Copyright © 2012 Intel Corporation +# +# 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: +# +# The above copyright notice and this permission notice (including the next +# paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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 argparse import ArgumentParser +import os +import os.path as path +import re +import sys + +from framework.database import ResultDatabase + +############################################################################# +##### Main program +############################################################################# + +def parseArguments(argv, config): + p = ArgumentParser(prog='robyn report', description='A GPU test runner') + p.add_argument('report', metavar='') + p.add_argument('runs', nargs='+', metavar='') + + # XXX: alternate database (pending refactoring) + return p.parse_args(argv) + +def main(argv, config): + args = parseArguments(argv, config) + + db = ResultDatabase(config) + + reportDir = args.report + if not path.exists(reportDir): + os.makedirs(reportDir) + + # XXX: translate run names into run IDs. + # XXX: for now, we expect runs to be 1353885503 1353885923 1353885927 + results = db.getResults([int(r) for r in args.runs]) + + print(results) + #os.link(path.join(templateDir, 'index.css'), + #path.join(reportDir, 'index.css')) + #writeSummaryHtml(summary, summaryDir, 'all') + + +if __name__ == "__main__": + main() diff --git a/robyn b/robyn index c925da1..adfe3ab 100755 --- a/robyn +++ b/robyn @@ -23,6 +23,7 @@ # import sys import programs.run +import programs.report import programs.listRuns import framework.config @@ -57,6 +58,8 @@ args = sys.argv[2:] if cmd == 'run': programs.run.main(args, config) +elif cmd == 'report': + programs.report.main(args, config) elif cmd == 'list-runs': programs.listRuns.main(args, config) else: -- cgit v1.2.3