Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle validation tasks inside CPAchecker #1078

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions benchexec/tools/cpa-witness2test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import benchexec.tools.cpachecker as cpachecker

from benchexec.tools.template import ToolNotFoundException
from benchexec.tools.template import ToolNotFoundException, UnsupportedFeatureException


class Tool(cpachecker.Tool):
Expand Down Expand Up @@ -51,4 +51,10 @@ def program_files(self, executable):
def cmdline(self, executable, options, task, rlimits):
additional_options = self._get_additional_options(options, task, rlimits)
# Add additional options in front of existing ones, since -gcc-args ... must be last argument in front of task
return [executable] + additional_options + options + [task.single_input_file]
input_files = self._get_non_witness_input_files(task)
if len(input_files) != 1:
raise UnsupportedFeatureException(
f"{self.name()} does not support tasks with more than one non-witness input file"
)

return [executable] + additional_options + options + input_files
44 changes: 38 additions & 6 deletions benchexec/tools/cpachecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# SPDX-License-Identifier: Apache-2.0

import logging
from pathlib import Path
import sys
import os
import re
Expand Down Expand Up @@ -180,16 +181,47 @@ def option_present(option):
f"Unsupported data_model '{data_model}' defined for task '{task}'"
)

if isinstance(task.options, dict) and "witness" in task.options.keys():
if not option_present("witness"):
possible_witness_files = self._get_witness_input_files(task)

if len(possible_witness_files) != 1:
raise benchexec.tools.template.UnsupportedFeatureException(
f"Expected exactly one witness file, but found {len(possible_witness_files)}: {possible_witness_files}"
)

options += [f"{prefix}witness", possible_witness_files[0]]
else:
raise benchexec.tools.template.UnsupportedFeatureException(
"You are passing a witness as both an option and through the task definition. "
"Please remove one of them."
)

return options

def __partition_input_files(self, task):
input_files = task.input_files_or_identifier
witness_files = []
other_files = []
for file in input_files:
if Path(file).name == task.options.get("witness"):
witness_files.append(file)
else:
other_files.append(file)
return witness_files, other_files

def _get_witness_input_files(self, task):
witness_files, _ = self.__partition_input_files(task)
return witness_files

def _get_non_witness_input_files(self, task):
_, other_files = self.__partition_input_files(task)
return other_files

def cmdline(self, executable, options, task, rlimits):
additional_options = self._get_additional_options(options, task, rlimits)
return (
[executable]
+ options
+ additional_options
+ list(task.input_files_or_identifier)
)
input_files = self._get_non_witness_input_files(task)
return [executable] + options + additional_options + input_files

def determine_result(self, run):
"""
Expand Down