Skip to content

Commit

Permalink
Create a tool-info module for BtorMC
Browse files Browse the repository at this point in the history
When passing only `--version` to BtorMC,
the tool does not terminate,
an EOF (ctrl-D) has to be passed to stdin additionally.
  • Loading branch information
Po-Chun-Chien committed May 27, 2024
1 parent 6467aa5 commit a14bfcd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
47 changes: 47 additions & 0 deletions benchexec/tools/btormc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of BenchExec, a framework for reliable benchmarking:
# https://github.com/sosy-lab/benchexec
#
# SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0

import benchexec.result as result
import benchexec.tools.template


class Tool(benchexec.tools.template.BaseTool2):
"""
Tool info for BtorMC -- A Bounded Model Checker for Btor2
"""

REQUIRED_PATHS = ["build/"]

def executable(self, tool_locator):
return tool_locator.find_executable("btormc", subdir="build/bin")

def name(self):
return "BtorMC"

def project_url(self):
return "https://github.com/Boolector/boolector"

def version(self, executable):
return self._version_from_tool(executable, stdin="")

def cmdline(self, executable, options, task, rlimits):
return [executable] + options + [task.single_input_file]

def determine_result(self, run):
"""
@return: status of BtorMC after executing a run
"""
if run.was_timeout:
return result.RESULT_TIMEOUT
for line in run.output[::-1]:
# BtorMC's option `--trace-gen` must be set to 1
# such that "sat/unsat" is printed to the output
if line.startswith("unsat"):
return result.RESULT_TRUE_PROP
elif line.startswith("sat"):
return result.RESULT_FALSE_PROP
return result.RESULT_UNKNOWN
3 changes: 3 additions & 0 deletions benchexec/tools/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def version(self, executable):
def _version_from_tool(
executable,
arg="--version",
stdin=None,
use_stderr=False,
ignore_stderr=False,
line_prefix=None,
Expand All @@ -146,13 +147,15 @@ def _version_from_tool(
and returning stdout.
@param executable: the path to the executable of the tool (typically the result of executable())
@param arg: an argument to pass to the tool to let it print its version
@param stdin: this argument is passed to the tool's stdin (default: None)
@param use_stderr: True if the tool prints version on stderr, False for stdout
@param line_prefix: if given, search line with this prefix and return only the rest of this line
@return a (possibly empty) string of output of the tool
"""
try:
process = subprocess.run(
[executable, arg],
input=stdin,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
Expand Down

0 comments on commit a14bfcd

Please sign in to comment.