From 932990242f7b76f7c1404bdfdda6587bbe588c5f Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Tue, 20 Oct 2015 00:54:10 +0200 Subject: [PATCH] Dummy step (delay 0) --- example/diameter/launcher/Launcher.cpp | 3 ++- example/diameter/launcher/testing/TestStep.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 8ea7511..1b7a7ee 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -1163,6 +1163,7 @@ std::string Launcher::help() const throw() { result += "\n"; 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"; @@ -2016,7 +2017,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if (numParams > 3) throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION); if(param3 == "") throw anna::RuntimeException("Missing milliseconds for 'delay' command in test id operation", ANNA_FILE_LOCATION); - anna::Millisecond delay = checkTimeMeasure("Test case delay step", param3); + anna::Millisecond delay = ((param3 == "0" /* special case */) ? (anna::Millisecond)0 : checkTimeMeasure("Test case delay step", param3)); testManager.getTestCase(id)->addDelay(delay); // creates / reuses } else if ((param2 == "waitfe")||(param2 == "waitfc")) { diff --git a/example/diameter/launcher/testing/TestStep.cpp b/example/diameter/launcher/testing/TestStep.cpp index cb1b0f9..524e0bd 100644 --- a/example/diameter/launcher/testing/TestStep.cpp +++ b/example/diameter/launcher/testing/TestStep.cpp @@ -483,12 +483,13 @@ throw() { anna::xml::Node* result = TestStep::asXML(parent); //parent->createChild("TestStepDelay"); - result->createAttribute("Delay", a_delay.asString()); + result->createAttribute("Delay", ((a_delay == 0) ? "dummy step, no delay" : a_delay.asString())); return result; } bool TestStepDelay::do_execute() throw() { + if (a_delay == 0) { complete(); return true; } // special case try { a_timer = TestManager::instantiate().createTimer((TestCaseStep*)this, a_delay, TestTimer::Type::Delay); } @@ -502,12 +503,14 @@ bool TestStepDelay::do_execute() throw() { } void TestStepDelay::do_complete() throw() { + if (a_delay == 0) return; // special case a_timer = NULL; next(); // next() invoked here because execute() is always false for delay and never advance the iterator // TODO, avoid this recursion } void TestStepDelay::do_reset() throw() { + if (a_delay == 0) return; // special case try { TestManager::instantiate().cancelTimer(a_timer); } -- 2.20.1