Skip to content

Commit 9d80923

Browse files
committed
better handling of (known) errors
1 parent addafe2 commit 9d80923

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

tests/test_toolchains.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def load_and_read(tester, benchmark):
6161
if results["loader"].not_supported:
6262
pytest.skip("Checker does not support these files.")
6363
assert results["loader"].exit_code == 0, "Loader should not crash."
64+
if results["transformer"].anticipated_error:
65+
pytest.xfail("Transformer failed with an anticipated error")
66+
if results["transformer"].not_supported:
67+
pytest.skip("Transformer does not support these files.")
6468
if results["transformer"] is not None:
6569
assert results["transformer"].exit_code == 0, "Transformer should not crash"
6670
if results["checker"].anticipated_error:

umbtest/tools.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ def parse_logfile_storm(log, inv):
4242
known_error_messages = [
4343
"ERROR (SparseModelFromUmb.cpp:242): Only state observations are currently supported for POMDP models.",
4444
"ERROR (ValueEncoding.h:56): Some values are given as double intervals but a model with a non-interval type is requested.",
45-
] # add messages that indicate a "known" error, i.e., something that indicates that no warning should be printed
45+
] # add messages that indicate a "known" error, i.e., something that indicates that this is a reported issue.
4646
inv.anticipated_error = contains_any_of(log, known_error_messages)
4747
if inv.not_supported or inv.anticipated_error:
4848
return
4949
if inv.exit_code not in [0, 1]:
5050
if not inv.timeout and not inv.memout:
51-
print("WARN: Unexpected return code(s): {}".format(inv["return-codes"]))
51+
print(f"WARN: Unexpected return code(s): {inv.exit_code}")
52+
return
5253

5354
errors = {}
5455
pos = 0
@@ -295,10 +296,6 @@ def get_modest_path(self):
295296

296297
def _call_mcsta(self, log_file, args):
297298
invocation = [self.get_modest_path().as_posix(), "mcsta", "-Y"] + args + self._extra_args
298-
# if log_file is not None:
299-
# invocation = invocation +["-O", log_file.as_posix()]
300-
# else:
301-
# print("WTF")
302299
print(" ".join(invocation))
303300
result = subprocess.run(
304301
invocation,
@@ -311,14 +308,14 @@ def _call_mcsta(self, log_file, args):
311308
reported_result.memout = False
312309
reported_result.logfile = log_file
313310
if log_file is not None:
314-
with open(log_file, "r") as log:
315-
print(log.read())
316-
for line in result.stdout.split("\n"):
317-
print(line)
318-
if "error:" in line:
319-
reported_result.exit_code = 1
320-
if "UMB: error: Only deadlock-free MA, MDP, CTMC, DTMC, and LTS models are supported." in line:
321-
reported_result.not_supported = True
311+
with open(log_file, "w+") as log:
312+
log.write(result.stdout)
313+
if "error:" in result.stdout:
314+
reported_result.exit_code = 1
315+
if "UMB: error: Only deadlock-free MA, MDP, CTMC, DTMC, and LTS models are supported." in result.stdout:
316+
reported_result.not_supported = True
317+
if "UMB: error: Models where state 0 is not the initial state are not supported" in result.stdout:
318+
reported_result.anticipated_error = True
322319
return reported_result
323320

324321
def check_umb(self, umb_file: pathlib.Path, log_file: pathlib.Path, properties=[]):

0 commit comments

Comments
 (0)