How to use the benchexec.util.decode_to_string function in BenchExec

To help you get started, we’ve selected a few BenchExec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sosy-lab / cpachecker / BenchExec / benchexec / tools / cpachecker.py View on Github external
def version(self, executable):
        try:
            process = subprocess.Popen([executable, '-help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (stdout, stderr) = process.communicate()
        except OSError as e:
            logging.warning('Cannot run CPAchecker to determine version: {0}'.format(e.strerror))
            return ''
        if stderr:
            logging.warning('Cannot determine CPAchecker version, error output: {0}'.format(util.decode_to_string(stderr)))
            return ''
        if process.returncode:
            logging.warning('Cannot determine CPAchecker version, exit code {0}'.format(process.returncode))
            return ''
        stdout = util.decode_to_string(stdout)
        line = next(l for l in stdout.splitlines() if l.startswith('CPAchecker'))
        line = line.replace('CPAchecker' , '')
        line = line.split('(')[0]
        return line.strip()
github sosy-lab / benchexec / benchexec / tools / ultimate.py View on Github external
def _query_ultimate_version(self, cmd, api):
        try:
            process = subprocess.Popen(
                cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
            )
            (stdout, stderr) = process.communicate()
        except OSError as e:
            logging.warning(
                "Cannot run Java to determine Ultimate version (API %s): %s",
                api,
                e.strerror,
            )
            return ""
        stdout = util.decode_to_string(stdout).strip()
        if stderr or process.returncode:
            logging.warning(
                "Cannot determine Ultimate version (API %s).\n"
                "Command was:     %s\n"
                "Exit code:       %s\n"
                "Error output:    %s\n"
                "Standard output: %s",
                api,
                " ".join(map(util.escape_string_shell, cmd)),
                process.returncode,
                util.decode_to_string(stderr),
                stdout,
            )
            return ""

        version_ultimate_match = _ULTIMATE_VERSION_REGEX.search(stdout)
github staticafi / symbiotic / lib / symbioticpy / symbiotic / benchexec / tools / template.py View on Github external
process = subprocess.Popen([executable, arg],
                                       stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (stdout, stderr) = process.communicate()
        except OSError as e:
            logging.warning('Cannot run {0} to determine version: {1}'.
                            format(executable, e.strerror))
            return ''
        if stderr and not use_stderr:
            logging.warning('Cannot determine {0} version, error output: {1}'.
                            format(executable, util.decode_to_string(stderr)))
            return ''
        if process.returncode:
            logging.warning('Cannot determine {0} version, exit code {1}'.
                            format(executable, process.returncode))
            return ''
        return util.decode_to_string(stderr if use_stderr else stdout).strip()
github sosy-lab / benchexec / benchexec / tools / ultimate.py View on Github external
api,
                e.strerror,
            )
            return ""
        stdout = util.decode_to_string(stdout).strip()
        if stderr or process.returncode:
            logging.warning(
                "Cannot determine Ultimate version (API %s).\n"
                "Command was:     %s\n"
                "Exit code:       %s\n"
                "Error output:    %s\n"
                "Standard output: %s",
                api,
                " ".join(map(util.escape_string_shell, cmd)),
                process.returncode,
                util.decode_to_string(stderr),
                stdout,
            )
            return ""

        version_ultimate_match = _ULTIMATE_VERSION_REGEX.search(stdout)
        if not version_ultimate_match:
            logging.warning(
                "Cannot determine Ultimate version (API %s), output was: %s",
                api,
                stdout,
            )
            return ""
        return version_ultimate_match.group(1)
github sosy-lab / benchexec / benchexec / tools / template.py View on Github external
try:
            process = subprocess.Popen(
                [executable, arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE
            )
            (stdout, stderr) = process.communicate()
        except OSError as e:
            logging.warning(
                "Cannot run {0} to determine version: {1}".format(
                    executable, e.strerror
                )
            )
            return ""
        if stderr and not use_stderr and not ignore_stderr:
            logging.warning(
                "Cannot determine {0} version, error output: {1}".format(
                    executable, util.decode_to_string(stderr)
                )
            )
            return ""
        if process.returncode:
            logging.warning(
                "Cannot determine {0} version, exit code {1}".format(
                    executable, process.returncode
                )
            )
            return ""
        return util.decode_to_string(stderr if use_stderr else stdout).strip()
github sosy-lab / benchexec / benchexec / tools / aprove.py View on Github external
(stdout, stderr) = process.communicate()
            except OSError as e:
                logging.warning(
                    "Unable to determine AProVE version: {0}".format(e.strerror)
                )
                return ""

            version_aprove_match = re.search(
                r"^# AProVE Commit ID: (.*)",
                util.decode_to_string(stdout),
                re.MULTILINE,
            )
            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]
github staticafi / symbiotic / lib / symbioticpy / symbiotic / targets / ultimate.py View on Github external
def _query_ultimate_version(self, cmd, api):
        try:
            process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (stdout, stderr) = process.communicate()
        except OSError as e:
            logging.warning('Cannot run Java to determine Ultimate version (API {0}): {1}'
                            .format(api, e.strerror))
            return ''
        if stderr:
            logging.warning('Cannot determine Ultimate version (API {0}). Error output: {1}'
                            .format(api, util.decode_to_string(stderr)))
            return ''
        if process.returncode:
            logging.warning(
                'Cannot determine Ultimate version (API {0}). Exit code : {1}\nCommand was {2}'
                    .format(api, process.returncode, ' '.join(cmd)))
            return ''

        version_ultimate_match = _ULTIMATE_VERSION_REGEX.search(util.decode_to_string(stdout))
        if not version_ultimate_match:
            logging.warning(
                'Cannot determine Ultimate version, output (API {0}): {1}'.format(api, util.decode_to_string(stdout)))
            return ''
        return version_ultimate_match.group(1)