diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2016-08-04 15:35:46 +1200 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2016-08-31 07:09:26 +0200 |
commit | 1d0dd5bf5eef4ceedb4c99bd1de8042f26201bb8 (patch) | |
tree | a000251d6afee363441804a947687f9820262ae7 /selftest/format-subunit-json | |
parent | dfac53cd40d8f44cebcf15d9aceba5b4a8106b2a (diff) | |
download | samba-1d0dd5bf5eef4ceedb4c99bd1de8042f26201bb8.tar.gz |
selftest/wscript: format perftest as json
This makes it easier to use with common web-based graphing systems.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'selftest/format-subunit-json')
-rw-r--r-- | selftest/format-subunit-json | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/selftest/format-subunit-json b/selftest/format-subunit-json new file mode 100644 index 00000000000..d44918c7524 --- /dev/null +++ b/selftest/format-subunit-json @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org> +# Copyright (C) 2016 Douglas Bagnall <douglas.bagnall@catalyst.net.nz> +# Published under the GNU GPL, v3 or later + +import optparse +import os +import signal +import sys +import json + +sys.path.insert(0, "bin/python") + + +def json_formatter(src_f, dest_f): + """We're not even pretending to be a TestResult subclass; just read + from stdin and look for elapsed-time tags.""" + results = {} + + for line in src_f: + line = line.strip() + print >>sys.stderr, line + if line[:14] == 'elapsed-time: ': + name, time = line[14:].rsplit(':', 1) + results[name] = float(time) + + json.dump(results, dest_f, + sort_keys=True, indent=2, separators=(',', ': ')) + + +def main(): + parser = optparse.OptionParser("format-subunit-json [options]") + parser.add_option("--verbose", action="store_true", + help="ignored, for compatibility") + parser.add_option("--immediate", action="store_true", + help="ignored, for compatibility") + parser.add_option("--prefix", type="string", default=".", + help="Prefix to write summary.json to") + opts, args = parser.parse_args() + + fn = os.path.join(opts.prefix, "summary.json") + f = open(fn, 'w') + json_formatter(sys.stdin, f) + f.close() + print + print "A JSON file summarising these tests performance found in:" + print " ", fn + + +def handle_sigint(sig, stack): + sys.exit(0) + +signal.signal(signal.SIGINT, handle_sigint) +main() |