X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Ftesting%2FTestCase.cpp;h=818093b4de0483242e627eee14c56674978fecc4;hb=851ff2962362fd5bad874e8ed91445b296eaca24;hp=efaba5c3d02780c6c68477c7de96831aecf4e6d4;hpb=d723d5bf571eb48c641b092058eaa38bb6c4fcc8;p=anna.git diff --git a/source/testing/TestCase.cpp b/source/testing/TestCase.cpp index efaba5c..818093b 100644 --- a/source/testing/TestCase.cpp +++ b/source/testing/TestCase.cpp @@ -211,6 +211,12 @@ bool TestCase::reset(bool hard) throw() { // Soft reset if finished: if (!hard /* is soft reset */ && !isFinished()) return false; + // Dump as failed if still in progress (hard reset): + if (getState() == State::InProgress) { + addDebugSummaryHint("Testcase hard reset while in progress"); + setState(State::Failed); + } + // Clean stage //////////////////////////// // id is kept std::vector::iterator it; @@ -250,7 +256,7 @@ void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) throw(ann if (registerKeys) { TestManager &testManager = TestManager::instantiate(); - testManager.registerSessionId(anna::diameter::helpers::base::functions::getSessionId(db), this); + testManager.registerKey1(anna::diameter::helpers::base::functions::getSessionId(db), this); std::string subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_E164); @@ -258,7 +264,7 @@ void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) throw(ann subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_IMSI); if (subscriberId != "") - testManager.registerSubscriberId(subscriberId, this); + testManager.registerKey2(subscriberId, this); } } @@ -298,9 +304,24 @@ void TestCase::addSendxml2c(const anna::DataBlock &db, anna::diameter::comm::Ori assertInitialized(); assertMessage(db, false /* to client */); + if (stepNumber != -1) { + const TestStep *stepReferred = getStep(stepNumber); + if (!stepReferred) + throw anna::RuntimeException(anna::functions::asString("Step number (%d) do not exists (test case %llu)", stepNumber, a_id), ANNA_FILE_LOCATION); + + if (stepReferred->getType() != TestStep::Type::Wait) + throw anna::RuntimeException(anna::functions::asString("Step number (%d) must refer to a 'wait' step (test case %llu)", stepNumber, a_id), ANNA_FILE_LOCATION); + + const TestCondition &tc = (static_cast(stepReferred))->getCondition(); + if (tc.getCode() == "0") { // if regexp used, is not possible to detect this kind of errors + throw anna::RuntimeException(anna::functions::asString("Step number (%d) must refer to a 'wait for request' step (test case %llu)", stepNumber, a_id), ANNA_FILE_LOCATION); + } + } + TestStepSendxml2c *step = new TestStepSendxml2c(this); step->setMsgDataBlock(db); step->setOriginHost(host); + step->setWaitForRequestStepNumber(stepNumber); // -1 means, no reference addStep(step); } @@ -366,11 +387,25 @@ void TestCase::addWait(bool fromEntity, addStep(step); } -void TestCase::addWaitRegexp(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException) { +void TestCase::addWaitRegexpHex(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException) { + assertInitialized(); + + TestStepWait *step = new TestStepWait(this); + step->setConditionRegexpHex(fromEntity, regexp); + + LOGINFORMATION( + if (hasSameCondition(step->getCondition())) + anna::Logger::information(anna::functions::asString("The same wait condition has already been programmed in this test case (%llu). Are you sure ?", a_id), ANNA_FILE_LOCATION); + ); + + addStep(step); +} + +void TestCase::addWaitRegexpXml(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException) { assertInitialized(); TestStepWait *step = new TestStepWait(this); - step->setCondition(fromEntity, regexp); + step->setConditionRegexpXml(fromEntity, regexp); LOGINFORMATION( if (hasSameCondition(step->getCondition()))