[LNT] r279179 - Import of simple text based data
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 18 16:54:30 PDT 2016
Author: cmatthews
Date: Thu Aug 18 18:54:30 2016
New Revision: 279179
URL: http://llvm.org/viewvc/llvm-project?rev=279179&view=rev
Log:
Import of simple text based data
Sometimes you have data you want to put into LNT that does not come from
a full test suite. This importer lets you import simple key value pairs
from a text file into a LNT json report, so you can subit them. I am
currently using this to collect code size metrics, but this could be
used for any metric or test-suite collection.
Added:
lnt/trunk/lnt/lnttool/import_report.py
lnt/trunk/tests/lnttool/test_importreport.py
Modified:
lnt/trunk/lnt/lnttool/main.py
Added: lnt/trunk/lnt/lnttool/import_report.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/import_report.py?rev=279179&view=auto
==============================================================================
--- lnt/trunk/lnt/lnttool/import_report.py (added)
+++ lnt/trunk/lnt/lnttool/import_report.py Thu Aug 18 18:54:30 2016
@@ -0,0 +1,65 @@
+import os
+from optparse import OptionParser
+
+import lnt.testing
+
+
+def action_importreport(name, args):
+ """Import simple space separated data into a report to submit."""
+ description = """Import simple data into LNT. This takes a space separated
+ key value file and creates an LNT report file, which can be submitted to
+ an LNT server. Example input file:
+
+ foo.exec 123
+ bar.size 456
+ foo/bar/baz.size 789
+
+ The format is "test-name.metric", so exec and size are valid metrics for the
+ test suite you are submitting to.
+ to.
+ """
+ parser = OptionParser(
+ "%s [<input>, [<output>]] \n\n%s" % (name, description))
+ parser.add_option("", "--testsuite", dest="suite", default="nts",
+ help="Short name of the test suite to submit to."
+ " [%default]")
+ parser.add_option("", "--order", dest="order",
+ help="Order to submit as number. Ex: a svn revision,"
+ " or timestamp.")
+ parser.add_option("", "--machine", dest="machine",
+ help="The name of the machine to submit under.")
+ (opts, args) = parser.parse_args(args)
+
+ input_file_name = None
+ output = None
+
+ if len(args) == 1:
+ input_file_name, = args
+ output = "report.json"
+ elif len(args) == 2:
+ input_file_name, output = args
+ else:
+ parser.error("Invalid number of arguments.")
+ if not opts.suite or not opts.order or not opts.machine:
+ parser.error("Testsuite, order and machine are required.")
+
+ intput_fd = open(input_file_name, 'r')
+ output_fd = open(output, 'wb')
+
+ machine_info = {}
+ run_info = {'tag': opts.suite}
+ run_info['run_order'] = opts.order
+ machine = lnt.testing.Machine(opts.machine,
+ machine_info)
+ ctime = os.path.getctime(input_file_name)
+ mtime = os.path.getmtime(input_file_name)
+
+ run = lnt.testing.Run(ctime, mtime, run_info)
+ report = lnt.testing.Report(machine=machine, run=run, tests=[])
+
+ for line in intput_fd.readlines():
+ key, val = line.split()
+ test = lnt.testing.TestSamples(opts.suite + "." + key, [val])
+ report.tests.extend([test])
+
+ output_fd.write(report.render())
Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=279179&r1=279178&r2=279179&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Thu Aug 18 18:54:30 2016
@@ -123,6 +123,7 @@ from convert import action_convert
from import_data import action_import
from updatedb import action_updatedb
from viewcomparison import action_view_comparison
+from import_report import action_importreport
def action_checkformat(name, args):
"""check the format of an LNT test report file"""
Added: lnt/trunk/tests/lnttool/test_importreport.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/test_importreport.py?rev=279179&view=auto
==============================================================================
--- lnt/trunk/tests/lnttool/test_importreport.py (added)
+++ lnt/trunk/tests/lnttool/test_importreport.py Thu Aug 18 18:54:30 2016
@@ -0,0 +1,6 @@
+# Testing text importing.
+#
+# RUN: echo "foo.exec 10" > input
+# RUN: echo "bar.exec 20" >> input
+# RUN: lnt importreport --testsuite nts --order 123 --machine foo input output.json
+# RUN: cat output.json
More information about the llvm-commits
mailing list