-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-xbsa.py
executable file
·128 lines (105 loc) · 4.01 KB
/
generate-xbsa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/python3
from datetime import datetime, timezone
from jinja2 import Environment, FileSystemLoader
import bsa
def check_tag(tag):
cpu = "neoverse-n2"
passed = "?"
try:
for bsa_test_id in tags_to_tests[tag]["bsa"]:
if status_bsa[bsa_test_id]['status'][cpu] not in ["FAIL"]:
passed = "✔"
for sbsa_test_id in tags_to_tests[tag]["sbsa"]:
try:
if status_sbsa[sbsa_test_id]['skip_for_qemu']:
passed = "-"
except KeyError:
pass
match status_sbsa[sbsa_test_id]['status'][cpu]:
case "FAIL":
passed = "-"
case "SKIPPED":
passed = "?"
case "PASS":
passed = "✔"
case _:
pass
except KeyError:
pass
return passed
def handle_checklist():
checklist = []
for category in xbsa_checklist:
for group in xbsa_checklist[category]["groups"]:
for rule in xbsa_checklist[category]["groups"][group]["rules"]:
# not every entry from checklist has ACS tests
try:
tests = tags_to_tests[rule["tag"]]
# this tag is present in BSA/SBSA spec, not only in ACS
tags_to_tests[rule["tag"]]["acs_only"] = False
except KeyError:
tests = {"bsa": [], "pcbsa": [], "sbsa": []}
checklist.append({
'category': xbsa_checklist[category]["name"],
'group': xbsa_checklist[category]["groups"][group]["name"],
'tag': rule["tag"],
'bsa': rule["required"]["bsa"],
'pcbsa': rule["required"]["pcbsa"],
'sbsa': rule["required"]["sbsa"],
'sbsaref': check_tag(rule["tag"]),
'tests': tests,
})
for tag in sorted(tags_to_tests.keys()):
if tags_to_tests[tag]["acs_only"]:
# we want to display it at the end on checklist
entry = {
'category': "ACS only tests",
'group': "ACS",
'tag': tag,
'tests': tags_to_tests[tag],
'bsa': [],
'pcbsa': [],
'sbsa': [],
'sbsaref': check_tag(tag),
}
if tags_to_tests[tag]["bsa"]:
entry["bsa"] = True
if tags_to_tests[tag]["sbsa"]:
entry["sbsa"] = {
3: False,
4: False,
5: False,
6: False,
7: False,
8: False
}
for test in tags_to_tests[tag]["sbsa"]:
try:
sbsa_level = int(status_sbsa[test]["level"])
except ValueError:
if "future" == status_sbsa[test]["level"]:
sbsa_level = 8
for level in range(sbsa_level, 9):
entry["sbsa"][level] = True
checklist.append(entry)
return checklist
def generate_html_file(checklist):
file_loader = FileSystemLoader("templates")
env = Environment(loader=file_loader,
trim_blocks=True,
lstrip_blocks=True)
template = env.get_template("bsa-sbsa.html.j2")
output = template.render(
generate_time=datetime.strftime(datetime.now(timezone.utc),
"%d %B %Y %H:%M"),
checklist=checklist,
status_bsa=status_bsa,
status_sbsa=status_sbsa,
git_repo="sbsa-ref-status",
)
print(output)
if __name__ == "__main__":
status_bsa, status_sbsa, xbsa_checklist = bsa.load_yamls()
tags_to_tests = bsa.create_map_tags_to_tests(status_bsa, status_sbsa)
checklist = handle_checklist()
generate_html_file(checklist)