From 9fa68da11c56250017da9735e4a5dd3fd3b2021b Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Sun, 2 Apr 2017 20:29:06 +0200 Subject: [PATCH] Improved wait for regexp operations --- example/diameter/launcher/Launcher.cpp | 192 ++++++++++++------ example/diameter/launcher/Launcher.hpp | 3 +- .../launcher/resources/hex_examples/aaa.hex | 1 + .../launcher/resources/hex_examples/aar.hex | 3 +- .../resources/scripts/operation_signal.sh | 2 +- .../resources/scripts/tinyTestcase.sh | 13 +- .../launcher/resources/xml_examples/aaa.xml | 4 +- .../launcher/resources/xml_examples/aar.xml | 4 +- .../resources/xml_examples/regexp_for_aar.xml | 24 +++ include/anna/testing/TestCase.hpp | 3 +- include/anna/testing/TestCondition.hpp | 43 ++-- include/anna/testing/TestStep.hpp | 3 +- source/testing/TestCase.cpp | 18 +- source/testing/TestCondition.cpp | 60 +++--- source/testing/TestManager.cpp | 18 +- source/testing/TestStep.cpp | 23 ++- 16 files changed, 269 insertions(+), 145 deletions(-) create mode 100644 example/diameter/launcher/resources/hex_examples/aaa.hex create mode 100644 example/diameter/launcher/resources/xml_examples/regexp_for_aar.xml diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index b141865..0fcfd52 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -12,6 +12,7 @@ #include // ceil #include #include // chdir +#include // Project #include @@ -792,8 +793,7 @@ throw(anna::RuntimeException) { a_communicator->accept(); } - -bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw() { +bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw(anna::RuntimeException) { // Get hex string static char buffer[8192]; std::ifstream infile(pathfile.c_str(), std::ifstream::in); @@ -808,7 +808,8 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl msg += hexString; anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); - anna::functions::fromHexString(hexString, db); + + anna::functions::fromHexString(hexString, db); // could launch exception // Close file infile.close(); return true; @@ -817,6 +818,21 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl return false; } +bool Launcher::getContentFromFile(const std::string &pathfile, std::string &content) const throw(anna::RuntimeException) { + + std::ifstream inFile(pathfile.c_str(), std::ifstream::in); + if(!inFile.good()) { + throw RuntimeException(anna::functions::asString("Unable to open file '%s'", pathfile.c_str()), ANNA_FILE_LOCATION); + } + + std::stringstream strStream; + strStream << inFile.rdbuf(); //read the file + content = strStream.str(); // holds the content of the file + inFile.close(); + + return true; +} + void Launcher::resetStatistics() throw() { if (a_workingNode) { a_workingNode->getCommEngine()->resetStatistics(); @@ -1222,16 +1238,6 @@ std::string Launcher::help() const throw() { result += "\n delay| Blocking step until the time lapse expires. Useful to give "; result += "\n some cadence control and time schedule for a specific case."; result += "\n A value of 0 could be used as a dummy step."; - result += "\n wait| Blocking step until condition is fulfilled. The message could"; - result += "\n received from entity (waitfe) or from client (waitfc)."; - result += "\n"; - result += "\n wait-regexp|"; - result += "\n Wait condition, from entity (waitfe-regexp) or client (waitfc-regexp)"; - result += "\n to match the serialized xml content for received messages. CPU cost"; - result += "\n is bigger than the former ones because the whole message must be"; - result += "\n decoded and converted to xml instead of doing a direct hexadecimal"; - result += "\n buffer search. The main advantage is the great flexibility to identify"; - result += "\n any content with a regular expression."; result += "\n"; result += "\n sh-command|