Skip to content

Commit ef07236

Browse files
committed
fix: formal flow
Signed-off-by: James McCorrie <james.mccorrie@lowrisc.org>
1 parent 0665930 commit ef07236

File tree

3 files changed

+70
-59
lines changed

3 files changed

+70
-59
lines changed

src/dvsim/flow/formal.py

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4+
from collections.abc import Sequence
5+
from dvsim.job.data import CompletedJobStatus
46

57
from pathlib import Path
68

@@ -176,41 +178,47 @@ def gen_results_summary(self):
176178

177179
return self.results_summary_md
178180

179-
def _gen_results(self, results):
180-
# This function is called after the regression and looks for
181-
# results.hjson file with aggregated results from the formal logfile.
182-
# The hjson file is required to follow this format:
183-
# {
184-
# "messages": {
185-
# "errors" : []
186-
# "warnings" : []
187-
# "cex" : ["property1", "property2"...],
188-
# "undetermined": [],
189-
# "unreachable" : [],
190-
# },
191-
#
192-
# "summary": {
193-
# "errors" : 0
194-
# "warnings" : 2
195-
# "proven" : 20,
196-
# "cex" : 5,
197-
# "covered" : 18,
198-
# "undetermined": 7,
199-
# "unreachable" : 2,
200-
# "pass_rate" : "90 %",
201-
# "cover_rate" : "90 %"
202-
# },
203-
# }
204-
# The categories for property results are: proven, cex, undetermined,
205-
# covered, and unreachable.
206-
#
207-
# If coverage was enabled then results.hjson will also have an item that
208-
# shows formal coverage. It will have the following format:
209-
# "coverage": {
210-
# formal: "90 %",
211-
# stimuli: "90 %",
212-
# checker: "80 %"
213-
# }
181+
def _gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
182+
"""Generate results.
183+
184+
This function is called after the regression and looks for
185+
results.hjson file with aggregated results from the formal logfile.
186+
The hjson file is required to follow this format:
187+
{
188+
"messages": {
189+
"errors" : []
190+
"warnings" : []
191+
"cex" : ["property1", "property2"...],
192+
"undetermined": [],
193+
"unreachable" : [],
194+
},
195+
196+
"summary": {
197+
"errors" : 0
198+
"warnings" : 2
199+
"proven" : 20,
200+
"cex" : 5,
201+
"covered" : 18,
202+
"undetermined": 7,
203+
"unreachable" : 2,
204+
"pass_rate" : "90 %",
205+
"cover_rate" : "90 %"
206+
},
207+
}
208+
The categories for property results are: proven, cex, undetermined,
209+
covered, and unreachable.
210+
211+
If coverage was enabled then results.hjson will also have an item that
212+
shows formal coverage. It will have the following format:
213+
"coverage": {
214+
formal: "90 %",
215+
stimuli: "90 %",
216+
checker: "80 %"
217+
}
218+
"""
219+
# There should be just one job that has run for this config.
220+
complete_job = results[0]
221+
214222
results_str = "## " + self.results_title + "\n\n"
215223
results_str += "### " + self.timestamp_long + "\n"
216224
if self.revision:
@@ -222,7 +230,7 @@ def _gen_results(self, results):
222230
assert len(self.deploy) == 1
223231
mode = self.deploy[0]
224232

225-
if results[mode] == "P":
233+
if complete_job.status == "P":
226234
result_data = Path(
227235
subst_wildcards(self.build_dir, {"build_mode": mode.name}),
228236
"results.hjson",
@@ -254,8 +262,8 @@ def _gen_results(self, results):
254262
else:
255263
summary += ["N/A", "N/A", "N/A"]
256264

257-
if results[mode] != "P":
258-
results_str += "\n## List of Failures\n" + "".join(mode.launcher.fail_msg.message)
265+
if complete_job.status != "P":
266+
results_str += "\n## List of Failures\n" + "".join(complete_job.fail_msg.message)
259267

260268
messages = self.result.get("messages")
261269
if messages is not None:

src/dvsim/flow/lint.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
"""Class describing lint configuration object."""
66

7+
from dvsim.job.data import CompletedJobStatus
8+
9+
from collections.abc import Sequence
710
from pathlib import Path
811

912
from tabulate import tabulate
@@ -99,26 +102,26 @@ def gen_results_summary(self):
99102

100103
# TODO(#9079): This way of parsing out messages into an intermediate
101104
# results.hjson file will be replaced by a native parser mechanism.
102-
def _gen_results(self, results):
103-
# '''
104-
# The function is called after the regression has completed. It looks
105-
# for a results.hjson file with aggregated results from the lint run.
106-
# The hjson needs to have the following format:
107-
#
108-
# {
109-
# bucket_key: [str],
110-
# // other buckets according to message_buckets configuration
111-
# }
112-
#
113-
# Each bucket key points to a list of signatures (strings).
114-
# The bucket categories and severities are defined in the
115-
# message_buckets class variable, and can be set via Hjson Dvsim
116-
# config files.
117-
#
118-
# Note that if this is a primary config, the results will
119-
# be generated using the _gen_results_summary function
120-
# '''
121-
105+
def _gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
106+
"""Generate results.
107+
108+
The function is called after the regression has completed. It looks
109+
for a results.hjson file with aggregated results from the lint run.
110+
The hjson needs to have the following format:
111+
112+
{
113+
bucket_key: [str],
114+
// other buckets according to message_buckets configuration
115+
}
116+
117+
Each bucket key points to a list of signatures (strings).
118+
The bucket categories and severities are defined in the
119+
message_buckets class variable, and can be set via Hjson Dvsim
120+
config files.
121+
122+
Note that if this is a primary config, the results will
123+
be generated using the _gen_results_summary function
124+
"""
122125
# Generate results table for runs.
123126
results_str = f"## {self.results_title}\n\n"
124127
results_str += f"### {self.timestamp_long}\n"

src/dvsim/flow/one_shot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _create_deploy_objects(self) -> None:
154154
self._create_dirs()
155155

156156
@abstractmethod
157-
def _gen_results(self):
157+
def _gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
158158
"""Generate results for this config."""
159159

160160
@abstractmethod

0 commit comments

Comments
 (0)