Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

Commit

Permalink
Add parameter to show output of tools, in case they provide statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
lembergerth committed Feb 3, 2019
1 parent 3a5b937 commit 34c285f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions tbf/input_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def get_run_env(self):
def failed(result):
return result.returncode != 0

def __init__(self, machine_model, log_verbose, additional_options, preprocessor):
def __init__(self, machine_model, log_verbose, additional_options, preprocessor, show_tool_output=False):
self.machine_model = machine_model
self.log_verbose = log_verbose
self.show_tool_output = show_tool_output
self.cli_options = additional_options
self.program_preprocessor = preprocessor

Expand Down Expand Up @@ -78,7 +79,8 @@ def generate_input(self, filename, error_method, nondet_methods, stop_flag):
env=self.get_run_env(),
quiet=False,
err_to_output=True,
stop_flag=stop_flag)
stop_flag=stop_flag,
show_output=self.show_tool_output)
self.timer_generator.stop()
if BaseInputGenerator.failed(result) \
and (not stop_flag or not stop_flag.is_set()):
Expand Down
2 changes: 1 addition & 1 deletion tbf/tools/random_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _get_nondet_method_definition(method_name, method_type, param_types):
class InputGenerator(BaseInputGenerator):

def __init__(self, machine_model, log_verbose, additional_options):
super().__init__(machine_model, log_verbose, additional_options, Preprocessor())
super().__init__(machine_model, log_verbose, additional_options, Preprocessor(), show_tool_output=True)

def get_run_env(self):
return utils.get_env()
Expand Down
8 changes: 5 additions & 3 deletions tbf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def execute(command,
err_to_output=True,
stop_flag=None,
input_str=None,
timelimit=None):
timelimit=None,
show_output=False):

def wait_and_terminate(timelimit, stop_flag, process):
def shut_down(process):
Expand Down Expand Up @@ -308,10 +309,11 @@ def shut_down(process):

# Decode output, but we can't decode error output, since it may contain undecodable bytes.
output = output.decode() if output else ''
log_output = logging.info if show_output else logging.debug
if output:
log_cmd(output)
log_output(output)
if err_output:
log_cmd(err_output)
log_output(err_output)

return ExecutionResult(returncode, output, err_output)

Expand Down

0 comments on commit 34c285f

Please sign in to comment.