Skip to content

Commit 46877e8

Browse files
stop buffering output
1 parent 4cfac44 commit 46877e8

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

goblint_runner.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
from os import path
77
import logging
88

9-
10-
@dataclass
11-
class ExecutionResult:
12-
output: str
13-
verdict_true_or_error: bool
14-
15-
16-
class GoblintMultishotRunner:
9+
class GoblintRunner:
1710

1811
def __init__(self, logger):
1912
self.logger = logger
@@ -33,7 +26,7 @@ def __init__(self, logger):
3326
"""
3427
)
3528
parser.add_argument("-p","--portfolio-conf", type=str, metavar="FILE",dest="portfolio",
36-
help="a path to a portfolio configuration file (relative to goblint_multishot.py)")
29+
help="a path to a portfolio configuration file (relative to goblint_runner.py)")
3730
conf_args, self.other_args = parser.parse_known_args()
3831
logger.debug(f"Portfolio-conf file: {conf_args.portfolio}")
3932
logger.debug(f"Arguments passed on to goblint: {" ".join(self.other_args)}")
@@ -52,32 +45,25 @@ def run_with_config(self, config_path):
5245
args = ["--conf", config_path] + self.other_args
5346
self.logger.info(f"Running next shot: ./goblint {" ".join(args)}")
5447
process = subprocess.Popen([self.goblint_executable_path, *args],stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
55-
output = []
48+
continue_portfolio = False
5649
for line in process.stdout:
5750
decoded_line = line.decode("utf-8")
5851
print(decoded_line, end="")
59-
output.append(decoded_line)
52+
continue_portfolio = continue_portfolio or decoded_line.startswith("SV-COMP result: unknown")
6053
process.wait()
61-
output = "".join(output)
62-
return ExecutionResult(output, self.verdict_true_or_error(output))
54+
return continue_portfolio
6355

6456
def run_without_config(self):
6557
subprocess.run([self.goblint_executable_path, *self.other_args])
6658

67-
@staticmethod
68-
def verdict_true_or_error(output):
69-
return not any("SV-COMP result: unknown" in line for line in output.splitlines())
70-
7159
def run(self):
7260
if not self.configs:
7361
self.run_without_config()
7462
return
7563

76-
result = None
7764
for config in self.configs:
78-
result = self.run_with_config(config)
79-
if result.verdict_true_or_error:
80-
break
65+
go_on = self.run_with_config(config)
66+
if not go_on: break
8167

8268
class GoblintLikeFormatter(logging.Formatter):
8369
LEVEL_NAMES = {
@@ -94,12 +80,12 @@ def format(self, record):
9480
return super().format(record)
9581

9682
if __name__ == "__main__":
97-
logger=logging.getLogger("multishot")
83+
logger=logging.getLogger("goblintrunner")
9884
logging.basicConfig(level=logging.INFO)
9985
formatter=GoblintLikeFormatter('[%(levelname)s][%(name)s] %(message)s')
10086
sh=logging.StreamHandler()
10187
sh.setFormatter(formatter)
10288
logger.addHandler(sh)
10389
logger.propagate=False
104-
multishot_runner = GoblintMultishotRunner(logger)
105-
multishot_runner.run()
90+
goblint_runner = GoblintRunner(logger)
91+
goblint_runner.run()

0 commit comments

Comments
 (0)