AProVE: extract version number
@@ -21,6 +21,12 @@ import benchexec.util as util
import benchexec.tools.template
import benchexec.result as result
+import tempfile
+import re
+import functools
+import subprocess
+import logging
+
class Tool(benchexec.tools.template.BaseTool):
REQUIRED_PATHS = [
@@ -30,15 +36,38 @@ class Tool(benchexec.tools.template.BaseTool):
"newstrategy.strategy"
]
+ @functools.lru_cache()
def executable(self):
return util.find_executable('AProVE.sh')
-
def name(self):
return 'AProVE'
+ @functools.lru_cache()
+ def _aprove_version(self, executable):
+ with tempfile.NamedTemporaryFile(suffix=".c") as trivial_example:
+ trivial_example.write(b'int main() { return 0; }\n')
+ trivial_example.flush()
+
+ cmd = [executable, trivial_example.name]
+ try:
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = process.communicate()
+ except OSError as e:
+ logging.warning('Unable to determine AProVE version: {0}'.format(e.strerror))
+ return ''
+
+ version_aprove_match = re.compile('^# AProVE Commit ID: (.*)', re.MULTILINE).search(util.decode_to_string(stdout))
+ if not version_aprove_match:
+ logging.warning('Unable to determine AProVE version: {0}'.format(util.decode_to_string(stdout)))
+ return ''
+ return version_aprove_match.group(1)[:10]
+
+ @functools.lru_cache()
+ def version(self, executable):
+ return self._aprove_version(executable)
- def determine_result(self, returncode, returnsignal, output, isTimeout):
+ def determine_result(self, returncode, returnsignal, output, is_timeout):
if not output:
return result.RESULT_ERROR
elif "YES" in output[0]:
