Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions lnt/lnttool/import_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,30 @@ def action_importreport(input, output, suite, order, machine):
import lnt.testing
import os

machine_info = {}
run_info = {'tag': suite}
run_info['run_order'] = order
machine = lnt.testing.Machine(machine,
machine_info)
machine = lnt.testing.Machine(machine, report_version=2)

ctime = os.path.getctime(input.name)
mtime = os.path.getmtime(input.name)
run = lnt.testing.Run(start_time=ctime, end_time=mtime,
info={'llvm_project_revision': order},
report_version=2)

run = lnt.testing.Run(ctime, mtime, run_info)
report = lnt.testing.Report(machine=machine, run=run, tests=[])

tests = {} # name => lnt.testing.Test
for line in input.readlines():
key, val = line.split()
metric = key.split(".")[1]
(testname, metric) = key.split(".")
metric_type = float if metric not in ("hash", "profile") else str
test = lnt.testing.TestSamples(suite + "." + key, [val],
conv_f=metric_type)

report.tests.extend([test])
if testname not in tests:
tests[testname] = lnt.testing.Test(testname, [], info={}, report_version=2)
test = tests[testname]

samples = next((s for s in test.samples if s.metric == metric), None)
if samples is None:
test.samples.append(lnt.testing.MetricSamples(metric, [], report_version=2))
samples = test.samples[-1]

samples.add_samples([val], conv_f=metric_type)

report = lnt.testing.Report(machine=machine, run=run, tests=list(tests.values()), report_version=2)
output.write(report.render())
4 changes: 2 additions & 2 deletions lnt/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def render(self):
"""
if self.report_version == 2:
d = dict(self.info)
d['Name'] = self.name
d['name'] = self.name
return d
else:
return {'Name': self.name,
Expand Down Expand Up @@ -280,7 +280,7 @@ def render(self):
"""
d = dict(self.info)
d.update([s.render().popitem() for s in self.samples])
d['Name'] = self.name
d['name'] = self.name
return d


Expand Down
5 changes: 5 additions & 0 deletions tests/lnttool/Inputs/example_metrics.lnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
foo.execution_time 10
foo.execution_time 11
bar.execution_time 20
foo.hash d7
bar.profile Xz6/
30 changes: 30 additions & 0 deletions tests/lnttool/importreport.shtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Testing text importing.
#
# RUN: lnt importreport --testsuite nts --order 123 --machine foo %S/Inputs/example_metrics.lnt %t.json
# RUN: filecheck --input-file %t.json %s
# CHECK: {
# CHECK-NEXT: "format_version": "2",
# CHECK-NEXT: "machine": {
# CHECK-NEXT: "name": "foo"
# CHECK-NEXT: },
# CHECK-NEXT: "run": {
# CHECK-NEXT: "end_time": "{{.+}}",
# CHECK-NEXT: "llvm_project_revision": "123",
# CHECK-NEXT: "start_time": "{{.+}}"
# CHECK-NEXT: },
# CHECK-NEXT: "tests": [
# CHECK-NEXT: {
# CHECK-NEXT: "execution_time": [
# CHECK-NEXT: 10.0,
# CHECK-NEXT: 11.0
# CHECK-NEXT: ],
# CHECK-NEXT: "hash": "d7",
# CHECK-NEXT: "name": "foo"
# CHECK-NEXT: },
# CHECK-NEXT: {
# CHECK-NEXT: "execution_time": 20.0,
# CHECK-NEXT: "name": "bar",
# CHECK-NEXT: "profile": "Xz6/"
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: }
8 changes: 0 additions & 8 deletions tests/lnttool/test_importreport.py

This file was deleted.

20 changes: 10 additions & 10 deletions tests/testing/TestingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ def test_check(self):

def test_render(self):
# Check rendering with no info.
d1 = {'Name': 'Test1',
d1 = {'name': 'Test1',
'execution_time': [21.4, 3.2]}
self.assertDictEqual(self.test_noinfo.render(), d1)

# Check rendering with info.
d2 = {'Name': 'Test2',
d2 = {'name': 'Test2',
'execution_time': [21.4, 3.2],
'nb_files': '2'}
self.assertDictEqual(self.test_info.render(), d2)
Expand Down Expand Up @@ -479,13 +479,13 @@ def test_render(self):
self.assertDictEqual(self.machine_v1.render(), d2)

# Check v2 rendering with no info.
d3 = {'Name': 'Machine3',
d3 = {'name': 'Machine3',
'CPUs': '2'}
self.assertDictEqual(self.machine_v2.render(), d3)

# Check v2 rendering with info.
self.machine_v2.info = {}
d4 = {'Name': 'Machine3'}
d4 = {'name': 'Machine3'}
self.assertDictEqual(self.machine_v2.render(), d4)


Expand Down Expand Up @@ -662,7 +662,7 @@ def test_render(self):
{
"format_version": "2",
"machine": {
"Name": "Machine",
"name": "Machine",
"nb_cpus": "2"
},
"run": {
Expand All @@ -671,11 +671,11 @@ def test_render(self):
},
"tests": [
{
"Name": "Test",
"execution_time": [
21.4,
3.2
],
"name": "Test",
"nb_files": "2"
}
]
Expand All @@ -687,7 +687,7 @@ def test_render(self):
{
"format_version": "2",
"machine": {
"Name": "Machine",
"name": "Machine",
"nb_cpus": "2"
},
"run": {
Expand All @@ -696,11 +696,11 @@ def test_render(self):
},
"tests": [
{
"Name": "Test",
"execution_time": [
21.4,
3.2
],
"name": "Test",
"nb_files": "2"
}
]
Expand All @@ -714,7 +714,7 @@ def test_render(self):
{
"format_version": "2",
"machine": {
"Name": "Machine",
"name": "Machine",
"nb_cpus": "2"
},
"run": {
Expand All @@ -723,8 +723,8 @@ def test_render(self):
},
"tests": [
{
"Name": "Test",
"execution_time": 21.4,
"name": "Test",
"nb_files": "2"
}
]
Expand Down
Loading