X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=source%2Ftesting%2FTestManager.cpp;h=280a1988ebe17b2f17b8165fc47b6fe739932865;hp=a74ab6d16ec4b948d631f5084bda610773677b3e;hb=21054b5919e21b14627fac09e718262ae2812af4;hpb=882e3764e48fdf93aeb078c1832b10a956288da3 diff --git a/source/testing/TestManager.cpp b/source/testing/TestManager.cpp index a74ab6d..280a198 100644 --- a/source/testing/TestManager.cpp +++ b/source/testing/TestManager.cpp @@ -295,10 +295,38 @@ TestCase *TestManager::getTestCase(unsigned int id, const std::string &descripti return result; } -bool TestManager::clearPool() throw() { - if (!tests()) return false; - for (test_pool_it it = a_testPool.begin(); it != a_testPool.end(); it++) delete it->second; - // TODO: stop the possible command threads or there will be a core dump +bool TestManager::clearPool(std::string &result) throw() { + + result = ""; + + if (!tests()) { + result = "there are not programmed test cases to be removed"; + return false; + } + + int total = a_testPool.size(); + int unsafe = 0; + + test_pool_it it; + for (it = a_testPool.begin(); it != a_testPool.end(); it++) { + if (!it->second->safeToClear()) { // Check that non pending threads are running (command steps): + unsafe++; + } + } + + if (unsafe > 0) { + result = "some test cases cannot be removed ("; + result += anna::functions::asString(unsafe); + result += "/"; + result += anna::functions::asString(total); + result += "), mainly those having running-thread steps. Check for stuck external procedures or try later."; + return false; + } + + // Here is safe to clear: + for (it = a_testPool.begin(); it != a_testPool.end(); it++) { + delete it->second; + } a_testPool.clear(); a_key1TestCaseMap.clear(); @@ -307,6 +335,7 @@ bool TestManager::clearPool() throw() { a_poolCycle = 1; configureTTPS(0); // stop a_statSummary.clear(); + return true; } @@ -537,7 +566,7 @@ throw() { if (a_clock) { result->createAttribute("AsynchronousSendings", a_synchronousAmount); int ticksPerSecond = (a_synchronousAmount * 1000) / a_clock->getTimeout(); - result->createAttribute("TicksPerSecond", ticksPerSecond); + result->createAttribute("TicksPerSecond", a_clock->isActive() ? ticksPerSecond : 0); } if (a_currentTestIt != a_testPool.end()) { result->createAttribute("CurrentTestCaseId", (*a_currentTestIt).first);