PandA-2024.02
|
#include <ToolManager.hpp>
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 > ¶meters, 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 > ¶meters) 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 > ¶meters) 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... | |
Definition at line 53 of file ToolManager.hpp.
|
explicit |
Constructor.
Param | is the set of parameters |
Definition at line 57 of file ToolManager.cpp.
|
virtual |
|
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().
|
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().
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().
|
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().
|
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().
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.
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.
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 | list of parameters to be given to the tool executable |
output_files | list of expected output files to be verified |
log_file | is the log file |
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().
|
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
log_file | is 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().
|
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().
|
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().
|
protected |
debug level of the class
Definition at line 74 of file ToolManager.hpp.
Referenced by configure(), execute(), execute_command(), and prepare_input_files().
|
protected |
this string represent the path of the executable
Definition at line 60 of file ToolManager.hpp.
Referenced by configure(), and execute().
|
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().
|
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().
|
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().
|
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().
|
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().