PandA-2024.02
Public Member Functions | Protected Member Functions | Protected Attributes
ToolManager Class Reference

#include <ToolManager.hpp>

Collaboration diagram for ToolManager:
Collaboration graph
[legend]

Public Member Functions

 ToolManager (const ParameterConstRef &Param)
 Constructor. More...
 
virtual ~ToolManager ()
 Destructor. More...
 
void configure (const std::string &_tool_, const std::string &setupscr, const std::string &_host_="", const std::string &_remote_path_="", bool force_remote=false)
 Configuration of the tool. More...
 
int execute (const std::vector< std::string > &parameters, const std::vector< std::string > &input_files, const std::vector< std::string > &output_files=std::vector< std::string >(), const std::string &log_file=std::string(), bool permissive=false)
 Execute the tool. More...
 
std::vector< std::string > determine_paths (std::vector< std::string > &files, bool overwrite=true)
 Determine the relative paths of the inputs files. More...
 
std::string determine_paths (std::string &file_name, bool overwrite=true)
 

Protected Member Functions

int execute_command (const std::string &_command_, const std::string &error_message, const std::string &log_file, bool permissive=false, bool throw_message=true)
 Execute the command and check the return code. More...
 
int check_command (const std::string &_tool_, const std::string &setupscr, const std::string &_host_, bool permissive=false)
 Check if a command exist on a given host provided a configuration script. More...
 
std::string create_remote_command_line (const std::vector< std::string > &parameters) const
 Generate the command to the executed on the remote host. More...
 
void prepare_input_files (const std::vector< std::string > &files)
 Check that the input files exist. More...
 
void check_output_files (const std::vector< std::string > &files)
 Check that the output files have been correctly generated. More...
 
std::string create_command_line (const std::vector< std::string > &parameters) const
 Simply creates the command line starting from the list of parameters. More...
 
void remove_files (const std::vector< std::string > &input_files, const std::vector< std::string > &files)
 Removed the specified files. More...
 

Protected Attributes

const ParameterConstRef Param
 The set of parameters passed to the tool. More...
 
std::string executable
 this string represent the path of the executable More...
 
std::string setup_script
 this string has the script used to setup the environment for the executable More...
 
bool local
 flag to specify if the executable is local (true) or remote (false) More...
 
std::string host
 this string represent the host machine if remote More...
 
std::string remote_path
 it represents the paths on the host where the files have to be copied More...
 
int debug_level
 debug level of the class More...
 

Detailed Description

Definition at line 53 of file ToolManager.hpp.

Constructor & Destructor Documentation

◆ ToolManager()

ToolManager::ToolManager ( const ParameterConstRef Param)
explicit

Constructor.

Parameters
Paramis the set of parameters

Definition at line 57 of file ToolManager.cpp.

◆ ~ToolManager()

ToolManager::~ToolManager ( )
virtual

Destructor.

Definition at line 63 of file ToolManager.cpp.

References OUTPUT_FILE.

Member Function Documentation

◆ check_command()

int ToolManager::check_command ( const std::string &  _tool_,
const std::string &  setupscr,
const std::string &  _host_,
bool  permissive = false 
)
protected

Check if a command exist on a given host provided a configuration script.

check if the command is available on host machine

add setup script execution

Definition at line 105 of file ToolManager.cpp.

References test_panda::command, execute_command(), OUTPUT_FILE, Param, and starts_with().

Referenced by configure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_output_files()

void ToolManager::check_output_files ( const std::vector< std::string > &  files)
protected

Check that the output files have been correctly generated.

If the execution is remote, it also copies the files in local

Definition at line 376 of file ToolManager.cpp.

References test_panda::command, create_command_line(), execute_command(), lenet_tvm::file, host, local, OUTPUT_FILE, OUTPUT_LEVEL_VERBOSE, Param, PRINT_OUT_MEX, remote_path, and THROW_ERROR.

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ configure()

void ToolManager::configure ( const std::string &  _tool_,
const std::string &  setupscr,
const std::string &  _host_ = "",
const std::string &  _remote_path_ = "",
bool  force_remote = false 
)

Configuration of the tool.

check if the command is locally available

check if the command is remotely available

check if the host is reachable

Definition at line 153 of file ToolManager.cpp.

References check_command(), test_panda::command, debug_level, DEBUG_LEVEL_VERY_PEDANTIC, executable, execute_command(), host, local, OUTPUT_FILE, Param, PRINT_DBG_MEX, remote_path, setup_script, starts_with(), and THROW_ERROR.

Referenced by BackendFlow::ExecuteSynthesis(), and SimulationTool::Simulate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_command_line()

std::string ToolManager::create_command_line ( const std::vector< std::string > &  parameters) const
protected

Simply creates the command line starting from the list of parameters.

Note that the executable has to be the first parameter

Definition at line 224 of file ToolManager.cpp.

References test_panda::command, and THROW_ASSERT.

Referenced by check_output_files(), create_remote_command_line(), execute(), prepare_input_files(), and remove_files().

Here is the caller graph for this function:

◆ create_remote_command_line()

std::string ToolManager::create_remote_command_line ( const std::vector< std::string > &  parameters) const
protected

Generate the command to the executed on the remote host.

Definition at line 235 of file ToolManager.cpp.

References test_panda::command, create_command_line(), host, and remote_path.

Referenced by execute(), and remove_files().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ determine_paths() [1/2]

std::vector< std::string > ToolManager::determine_paths ( std::vector< std::string > &  files,
bool  overwrite = true 
)

Determine the relative paths of the inputs files.

Definition at line 241 of file ToolManager.cpp.

References lenet_tvm::file.

◆ determine_paths() [2/2]

std::string ToolManager::determine_paths ( std::string &  file_name,
bool  overwrite = true 
)

Definition at line 252 of file ToolManager.cpp.

References test_panda::command, execute_command(), lenet_tvm::file, host, local, Param, remote_path, and THROW_ERROR.

Here is the call graph for this function:

◆ execute()

int ToolManager::execute ( const std::vector< std::string > &  parameters,
const std::vector< std::string > &  input_files,
const std::vector< std::string > &  output_files = std::vector<std::string>(),
const std::string &  log_file = std::string(),
bool  permissive = false 
)

Execute the tool.

Parameters
parameterslist of parameters to be given to the tool executable
output_fileslist of expected output files to be verified
log_fileis the log file
Returns
the return value of the executed process.

check that the input files exist and, if the execution is remote, copy them on the remote path

check if the output files are already present and delete them

execute the command

check that all expected files have been generated

Definition at line 327 of file ToolManager.cpp.

References check_output_files(), test_panda::command, create_command_line(), create_remote_command_line(), debug_level, DEBUG_LEVEL_VERY_PEDANTIC, executable, execute_command(), INDENT_DBG_MEX, local, prepare_input_files(), remove_files(), and THROW_ASSERT.

Referenced by BackendFlow::ExecuteSynthesis(), and SimulationTool::Simulate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute_command()

int ToolManager::execute_command ( const std::string &  _command_,
const std::string &  error_message,
const std::string &  log_file,
bool  permissive = false,
bool  throw_message = true 
)
protected

Execute the command and check the return code.

If an error is occurred, an exception is raised with the given message If the permissive flag is given, it raises simply a warning

Parameters
log_fileis the file where output will be saved

on Ubuntu sh is different from bash so we enforce it

Safe approach for release where assertions are disabled

Definition at line 71 of file ToolManager.cpp.

References CopyStdout(), debug_level, DEBUG_LEVEL_VERY_PEDANTIC, INDENT_DBG_MEX, IsError(), PandaSystem(), Param, THROW_ASSERT, THROW_ERROR, and THROW_WARNING.

Referenced by check_command(), check_output_files(), configure(), determine_paths(), execute(), prepare_input_files(), and remove_files().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_input_files()

void ToolManager::prepare_input_files ( const std::vector< std::string > &  files)
protected

Check that the input files exist.

If the execution is remote, it also copies the files to the remote path

Definition at line 300 of file ToolManager.cpp.

References test_panda::command, create_command_line(), debug_level, DEBUG_LEVEL_VERY_PEDANTIC, execute_command(), lenet_tvm::file, host, INDENT_DBG_MEX, local, OUTPUT_FILE, Param, remote_path, and THROW_ERROR.

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_files()

void ToolManager::remove_files ( const std::vector< std::string > &  input_files,
const std::vector< std::string > &  files 
)
protected

Removed the specified files.

Definition at line 356 of file ToolManager.cpp.

References test_panda::command, create_command_line(), create_remote_command_line(), execute_command(), lenet_tvm::file, local, and Param.

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ debug_level

int ToolManager::debug_level
protected

debug level of the class

Definition at line 74 of file ToolManager.hpp.

Referenced by configure(), execute(), execute_command(), and prepare_input_files().

◆ executable

std::string ToolManager::executable
protected

this string represent the path of the executable

Definition at line 60 of file ToolManager.hpp.

Referenced by configure(), and execute().

◆ host

std::string ToolManager::host
protected

this string represent the host machine if remote

Definition at line 69 of file ToolManager.hpp.

Referenced by check_output_files(), configure(), create_remote_command_line(), determine_paths(), and prepare_input_files().

◆ local

bool ToolManager::local
protected

flag to specify if the executable is local (true) or remote (false)

Definition at line 66 of file ToolManager.hpp.

Referenced by check_output_files(), configure(), determine_paths(), execute(), prepare_input_files(), and remove_files().

◆ Param

const ParameterConstRef ToolManager::Param
protected

The set of parameters passed to the tool.

Definition at line 57 of file ToolManager.hpp.

Referenced by check_command(), check_output_files(), configure(), determine_paths(), execute_command(), prepare_input_files(), and remove_files().

◆ remote_path

std::string ToolManager::remote_path
protected

it represents the paths on the host where the files have to be copied

Definition at line 71 of file ToolManager.hpp.

Referenced by check_output_files(), configure(), create_remote_command_line(), determine_paths(), and prepare_input_files().

◆ setup_script

std::string ToolManager::setup_script
protected

this string has the script used to setup the environment for the executable

Definition at line 63 of file ToolManager.hpp.

Referenced by configure().


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:04:06 for PandA-2024.02 by doxygen 1.8.13