Skip to content

Commit 4abb4d9

Browse files
authored
Add a way to pass additional machine information in lnt importreport (#172)
1 parent 68917fb commit 4abb4d9

File tree

2 files changed

+91
-12
lines changed

2 files changed

+91
-12
lines changed

lnt/lnttool/import_report.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
"Ex: a svn revision, or timestamp.")
1313
@click.option("--machine", required=True,
1414
help="the name of the machine to submit under")
15-
@click.option("--run-info", multiple=True, type=str,
15+
@click.option("--run-info", "run_info", multiple=True, type=str,
1616
help="Optional additional run information to include in the submission. "
1717
"If provided, this must be a key-value pair separated by '='. This "
1818
"argument may be repeated multiple times to provide multiple keys "
1919
"and values in the run information.")
20-
def action_importreport(input, output, suite, order, machine, run_info):
20+
@click.option("--machine-info", "machine_info", multiple=True, type=str,
21+
help="Optional additional machine information to include in the submission. "
22+
"If provided, this must be a key-value pair separated by '='. This "
23+
"argument may be repeated multiple times to provide multiple keys "
24+
"and values in the machine information.")
25+
def action_importreport(input, output, suite, order, machine, run_info, machine_info):
2126
"""Import simple data into LNT. This takes a space separated
2227
key value file and creates an LNT report file, which can be submitted to
2328
an LNT server. Example input file:
@@ -33,22 +38,26 @@ def action_importreport(input, output, suite, order, machine, run_info):
3338
import lnt.testing
3439
import os
3540

36-
machine = lnt.testing.Machine(machine, report_version=2)
37-
38-
parsed_info = {}
41+
# Build the run with any additional info
42+
run_info_dict = {}
3943
for s in run_info:
4044
if '=' not in s:
4145
raise click.BadParameter(f"--run-info must be in 'key=value' format, got: {s}")
4246
k, v = s.split('=', 1) # Split only on the first '=' in case there are several in the string
43-
parsed_info[k] = v
44-
run_info = parsed_info
45-
run_info.update({'llvm_project_revision': order})
46-
47+
run_info_dict[k] = v
48+
run_info_dict.update({'llvm_project_revision': order})
4749
ctime = os.path.getctime(input.name)
4850
mtime = os.path.getmtime(input.name)
49-
run = lnt.testing.Run(start_time=ctime, end_time=mtime,
50-
info=run_info,
51-
report_version=2)
51+
run = lnt.testing.Run(start_time=ctime, end_time=mtime, info=run_info_dict, report_version=2)
52+
53+
# Build the machine with any additional info
54+
machine_info_dict = {}
55+
for s in machine_info:
56+
if '=' not in s:
57+
raise click.BadParameter(f"--machine-info must be in 'key=value' format, got: {s}")
58+
k, v = s.split('=', 1) # Split only on the first '=' in case there are several in the string
59+
machine_info_dict[k] = v
60+
machine = lnt.testing.Machine(machine, info=machine_info_dict, report_version=2)
5261

5362
tests = {} # name => lnt.testing.Test
5463
for line in input.readlines():
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Ensure that we can pass additional machine information with `lnt importreport`.
3+
#
4+
5+
# Pass one machine information.
6+
#
7+
# RUN: lnt importreport --testsuite nts --order 123 --machine foo --machine-info os=macos %S/Inputs/example_metrics.lnt %t.1.json
8+
# RUN: filecheck --check-prefix=CHECK-1 --input-file %t.1.json %s
9+
# CHECK-1: {
10+
# CHECK-1-NEXT: "format_version": "2",
11+
# CHECK-1-NEXT: "machine": {
12+
# CHECK-1-NEXT: "name": "foo",
13+
# CHECK-1-NEXT: "os": "macos"
14+
# CHECK-1-NEXT: },
15+
# CHECK-1-NEXT: "run": {
16+
# CHECK-1-NEXT: "end_time": "{{.+}}",
17+
# CHECK-1-NEXT: "llvm_project_revision": "123",
18+
# CHECK-1-NEXT: "start_time": "{{.+}}"
19+
# CHECK-1-NEXT: },
20+
# CHECK-1-NEXT: "tests": [
21+
# CHECK-1-NEXT: {
22+
# CHECK-1-NEXT: "execution_time": [
23+
# CHECK-1-NEXT: 10.0,
24+
# CHECK-1-NEXT: 11.0
25+
# CHECK-1-NEXT: ],
26+
# CHECK-1-NEXT: "hash": "d7",
27+
# CHECK-1-NEXT: "name": "foo"
28+
# CHECK-1-NEXT: },
29+
# CHECK-1-NEXT: {
30+
# CHECK-1-NEXT: "execution_time": 20.0,
31+
# CHECK-1-NEXT: "name": "bar",
32+
# CHECK-1-NEXT: "profile": "Xz6/"
33+
# CHECK-1-NEXT: }
34+
# CHECK-1-NEXT: ]
35+
# CHECK-1-NEXT: }
36+
37+
# Pass multiple machine informations.
38+
#
39+
# RUN: lnt importreport --testsuite nts --order 123 --machine foo \
40+
# RUN: --machine-info cpu=8 --machine-info os=macos \
41+
# RUN: %S/Inputs/example_metrics.lnt %t.2.json
42+
# RUN: filecheck --check-prefix=CHECK-2 --input-file %t.2.json %s
43+
# CHECK-2: {
44+
# CHECK-2-NEXT: "format_version": "2",
45+
# CHECK-2-NEXT: "machine": {
46+
# CHECK-2-NEXT: "cpu": "8",
47+
# CHECK-2-NEXT: "name": "foo",
48+
# CHECK-2-NEXT: "os": "macos"
49+
# CHECK-2-NEXT: },
50+
# CHECK-2-NEXT: "run": {
51+
# CHECK-2-NEXT: "end_time": "{{.+}}",
52+
# CHECK-2-NEXT: "llvm_project_revision": "123",
53+
# CHECK-2-NEXT: "start_time": "{{.+}}"
54+
# CHECK-2-NEXT: },
55+
# CHECK-2-NEXT: "tests": [
56+
# CHECK-2-NEXT: {
57+
# CHECK-2-NEXT: "execution_time": [
58+
# CHECK-2-NEXT: 10.0,
59+
# CHECK-2-NEXT: 11.0
60+
# CHECK-2-NEXT: ],
61+
# CHECK-2-NEXT: "hash": "d7",
62+
# CHECK-2-NEXT: "name": "foo"
63+
# CHECK-2-NEXT: },
64+
# CHECK-2-NEXT: {
65+
# CHECK-2-NEXT: "execution_time": 20.0,
66+
# CHECK-2-NEXT: "name": "bar",
67+
# CHECK-2-NEXT: "profile": "Xz6/"
68+
# CHECK-2-NEXT: }
69+
# CHECK-2-NEXT: ]
70+
# CHECK-2-NEXT: }

0 commit comments

Comments
 (0)