Skip to content

Commit

Permalink
Add benchexec module for dgtool
Browse files Browse the repository at this point in the history
Allows to run dgtool from benchexec (for testing and benchmarking).
  • Loading branch information
Marek Chalupa authored and mchalupa committed Nov 4, 2020
1 parent 6d51ddd commit 2e5ad16
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
4 changes: 4 additions & 0 deletions misc/benchexec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Benchexec modules for running tools from DG

Copy to "benchexec/benchexec/tools" and then you can
use the tool in the XML spec of benchexec.
54 changes: 54 additions & 0 deletions misc/benchexec/dgtool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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-FileCopyrightText: 2020 Marek Chalupa <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0

from os.path import basename

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

class Tool(benchexec.tools.template.BaseTool):
"""
A benchexec module for running dgtool with given tool
on benchmarks
"""

def executable(self):
return util.find_executable("dgtool")

def version(self, executable):
return self._version_from_tool(executable)

def name(self):
return "dgtool"

def cmdline(self, executable, options, tasks, propertyfile, rlimits):
self.tool = basename(options[0])
return [executable] + options + ['-Xdg', 'dbg'] + tasks

def get_phase(self, tool, output):
phase='start'
for line in output:
if '> clang' in line:
phase='clang'
elif '> opt' in line:
phase='opt'
elif '> llvm-link' in line:
phase='llvm-link'
elif tool in line:
phase=tool
return phase

def determine_result(self, returncode, returnsignal, output, isTimeout):

if isTimeout:
return f"{self.get_phase(self.tool, output)}"

if returnsignal == 0 and returncode == 0:
return result.RESULT_DONE
return f"{result.RESULT_ERROR}({self.get_phase(self.tool, output)})"
2 changes: 1 addition & 1 deletion tools/dgtool
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ if passes:
bitcode = newname

###
# Run to tool
# Run the tool
if not cc_mode:
cmd.append(bitcode)
printcmd(cmd)
Expand Down

0 comments on commit 2e5ad16

Please sign in to comment.